public void CreateMainCamera(bool active) { // 逻辑层初始化 IRenderSystem renderSys = RareEngine.Instance().GetRenderSystem(); if (renderSys == null) { Log.Error("RenderSystem is null!"); // return; } // 设置主Camera string strCameraName = "MainCamera"; ICamera cam = renderSys.GetCamera(ref strCameraName); if (cam != null) { cam.Enable(active); return; } cam = renderSys.CreateCamera(ref strCameraName, 0.3f, 140f, 45f, -1, CameraClearFlags.Skybox); if (cam != null) { Camera camera = cam.GetNode().GetTransForm().gameObject.GetComponent <Camera>(); AudioListener listener = camera.transform.GetComponent <AudioListener>(); if (listener != null) { GameObject.Destroy(listener); } CameraFollow.Instance.camera = cam; Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null) { audio.SetListener(CameraFollow.Instance.CreateAudioListener()); } camera.cullingMask = -1 - (1 << LayerMask.NameToLayer("UI")) - (1 << LayerMask.NameToLayer("ShowModel")) - (1 << LayerMask.NameToLayer("UIHide")); camera.tag = strCameraName; cam.SetDepth((float)Engine.CameraDepth.Scene); cam.LookAt(new Vector3(0, 3, 5), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); UnityEngine.MonoBehaviour.DontDestroyOnLoad(camera.gameObject); cam.Enable(active); } }