[0]js 获取unity导入的资源相机 然后利用相机来激活射线
Laya.Scene3D.load("res/Scene/LayaScene_SimpleNaturePack_Demo/Conventional/SimpleNaturePack_Demo.ls",Laya.Handler.create(this,(scene)=>
{
var _scene = Laya.stage.addChild(scene);
Laya.stage.setChildIndex(_scene,0);
if(_scene == null) {console.log("获取场景节点失败!"); return;}
//console.log( _scene.getChildAt(2).name);
this._camera =_scene.getChildByName("Cameras").getChildByName("Camera1");
if(this._camera==null){console.log("获取场景Camera失败!"); return;}
let mainCamera = this._camera.getComponent(Laya.Camera);
console.log("mainCamera---->"+mainCamera);
this._camera.addComponent(CameraMoveManager);
console.log("开始注册mousedown 事件");
this.onMouseEvents();
}));
为啥获取到的mainCamera 为null
{
var _scene = Laya.stage.addChild(scene);
Laya.stage.setChildIndex(_scene,0);
if(_scene == null) {console.log("获取场景节点失败!"); return;}
//console.log( _scene.getChildAt(2).name);
this._camera =_scene.getChildByName("Cameras").getChildByName("Camera1");
if(this._camera==null){console.log("获取场景Camera失败!"); return;}
let mainCamera = this._camera.getComponent(Laya.Camera);
console.log("mainCamera---->"+mainCamera);
this._camera.addComponent(CameraMoveManager);
console.log("开始注册mousedown 事件");
this.onMouseEvents();
}));
为啥获取到的mainCamera 为null
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Laya_XS
赞同来自: