Cocos3.3.2 TypeScript语言如何读取Prefad属性的Y和height



求大佬告知下怎么实现

可以直接读取 Prefab 的数据的~

我记得是:

prefab.data.y

by the way,用 VS 写 ts 代码还真是少见哈哈哈~

1赞

感谢大哥 :rofl:,我是搞UE开发的,想轻量级的做一个个人娱乐的

还是有点问题:

debug.ts:102 
        
       TypeError: Cannot read properties of undefined (reading 'height')
    at GameMain.onLoad (Game_Main.ts:20)
    at node-activator.ts:97
    at OneOffInvoker._invoke (component-scheduler.ts:233)
    at OneOffInvoker.invoke (component-scheduler.ts:148)
    at NodeActivator.activateNode (node-activator.ts:190)
    at Scene._activate (scene.ts:292)
    at Director.runSceneImmediate (director.ts:448)
    at main.js:1
    at asset-manager.ts:689
    at utilities.ts:317
error @ debug.ts:102

怎么写的 0.0

1赞



我是这样写的就想获取它的Y和H数值
但是报错 :sob:

image

item 不就是 Node 吗,为啥还要去 .node。。。

我建议你还是用 VSCode 来写 ts 代码吧。。。

1赞

我没VCode,工作用的VS

感谢大佬修复了

多下载一个 VSCode 占不了多少空间,但是能帮你省很多时间。。。

1赞

我搭建了云端的VsCode 我没把这个项目导入进去~感觉都一样

Up to you~

1赞

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。