public void LateUpdate() { Camera nowcurrent = cameraStruct.GetCurrent(root); if (nowcurrent == null) { OnRemove(); return; } if (current != null && current.Camera == nowcurrent) { return; } OnRemove(); current = nowcurrent.gameObject.AddComponent <CameraEffects>(); current.current = parent; }
public void OnRemove() { if (current != null) { parent.RestoreCamera(); #if UNITY_EDITOR if (!Application.isPlaying) { UnityEngine.Object.DestroyImmediate(current); } else { UnityEngine.Object.Destroy(current); } #else UnityEngine.Object.Destroy(current); #endif current = null; } }