因为LayaAir 3 IDE 版本升级的代码更新(1)
感谢大家支持《LayaAir3实战入门课程》,因为LayaAir 3 IDE 的版本升级,在视频的3d项目中出现了无法正常运行的情况,请根据下面说明进行调整:
在LayaAir 3 IDE的属性面板中,如果需要手动设置在脚本中使用的关联属性,是在脚本代码中使用@property来实现的,早期的代码格式是 @property( )publie ‘属性名’:类型。例如给脚本添加一个在属性面板中设置的字符串,
早期的代码是:@property() public text: string = "";
在最新的IDE版本中需要显式声明property的类型 ,
@property({type: String }) public text: string = "";
如果@property() 括号里面不填写内容,目前可以通过编译,但无法在IDE的属性面板中显示。
具体到3D示例项目中,需要调整的代码如下:
CameraFellowscript.ts
@property({ type: Laya.Sprite3D 3}) public target: Laya.Sprite3D.
JoyStickScript.ts src\RPG
@property({ type: Laya.Sprite3D }) public target: Laya.Sprite3D.
ShieldScript.ts
@property({ type: Laya.Prefab }) public flashPrefab: Laya.Prefab;
SwordScript.ts
@property({ type: Laya.Sprite3D }) public tim: Laya.Sprite3D;
@property([ type: Laya.Sprite3D }) public shield: Laya.Sprite3D;

更多参考请查看LayaAir文档中关于property 的说明,链接如下:
https://layaair.layabox.com/3.x/doc/basics/common/Component/readme.html#12-property