[0]加载prefab的代码编译失败,提示“Property 'transform' does not exist on type 'Node'”


我从unity工程导出prefab到layaair中使用,根据文档中的介绍,使用如下代码加载prefab资源,
            Laya.Sprite3D.load("res/prefabs/Conventional/SampleScene.lh", Laya.Handler.create(null, function(sp)
            {
                var layaMonkey2  = scene.addChild(sp);
                layaMonkey2.transform.localScale = new Laya.Vector3(4, 4, 4);
                layaMonkey2.transform.translate(new Laya.Vector3(-10, 13, 0));
            }));

但是编译时报如下错误:
[23:43:30] Starting 'compile'...
{ Error: D:/Workspace/LayaTest/demo010/src/script/GameUI.ts(50,17): semantic error TS2339: [31mProperty 'transform' does not exist on type 'Node'.[39m
at error (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup\dist\rollup.js:9402:30)
at Object.error (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup\dist\rollup.js:15621:24)
at Object.error (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup\dist\rollup.js:16065:38)
at RollupContext.error (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:17187:30)
at lodash_3 (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:24954:23)
at arrayEach (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:532:11)
at forEach (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:9360:14)
at printDiagnostics (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:24927:5)
at Object.transform (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:26760:17)
at Promise.resolve.then (D:\Software\Develop\LayaAirIDE\resources\app\node_modules\rollup\dist\rollup.js:15768:25)
id: 'D:/Workspace/LayaTest/demo010/src/script/GameUI.ts',
hook: 'transform',
code: 'PLUGIN_ERROR',
plugin: 'rpt2' }
[23:43:31] Finished 'compile' after 1.38 s

附件中是导出资源的unity工程,导出的资源位于“Exports”目录下
已邀请:

Laya_z

赞同来自:

指定一对象的类型var layaMonkey2:Laya.Sprite3D  = scene.addChild(sp) as Laya.Sprite3D;

要回复问题请先

商务合作
商务合作