[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
已邀请:

Laya_XS

赞同来自:

从u3d里导出相机,如果相机本身挂载了脚本组件,我们是不做导出处理的,这个需要你手动重新添加。

要回复问题请先

商务合作
商务合作