private void DestroyHBCameras() { #if UNITY_EDITOR Camera[] sceneViewCameras = UnityEditor.SceneView.GetAllSceneCameras(); foreach (Camera camera in sceneViewCameras) { HBCamera hbCamera = camera.GetComponent <HBCamera>(); if (hbCamera != null) { DestroyImmediate(hbCamera); } } #endif Camera[] cameras = GameObject.FindObjectsOfType <Camera>(); foreach (Camera camera in cameras) { HBCamera hbCamera = camera.GetComponent <HBCamera>(); if (hbCamera != null) { #if UNITY_EDITOR DestroyImmediate(hbCamera); #else Destroy(hbCamera); #endif } } }
private void CreateHBCameras() { #if UNITY_EDITOR Camera[] sceneViewCameras = UnityEditor.SceneView.GetAllSceneCameras(); foreach (Camera camera in sceneViewCameras) { HBCamera hbCamera = camera.GetComponent <HBCamera>(); if (hbCamera == null) { hbCamera = camera.gameObject.AddComponent <HBCamera>(); } hbCamera.SceneViewCamera = true; } #endif Camera[] cameras = GameObject.FindObjectsOfType <Camera>(); foreach (Camera camera in cameras) { HBCamera hbCamera = camera.GetComponent <HBCamera>(); if (hbCamera == null) { camera.gameObject.AddComponent <HBCamera>(); } } }