// Destroying the attached Behaviour will result in the game or Scene receiving OnDestroy private void OnDestroy() { // Nullify the singleton instance if needed if (Instance == this) { Instance = null; } }
public void OnEnable() { p_target = (TDS_Camera)target; zForwardBoundProp = serializedObject.FindProperty("zForwardBound"); zBackwardBoundProp = serializedObject.FindProperty("zBackwardBound"); cameraOrientationProp = serializedObject.FindProperty("cameraOrientation"); xOffsetProp = serializedObject.FindProperty("xOffset"); yOffsetProp = serializedObject.FindProperty("yOffset"); zOffsetProp = serializedObject.FindProperty("zOffset"); maxSpeedProp = serializedObject.FindProperty("maxSpeed"); doMoveOnZProp = serializedObject.FindProperty("doMoveOnZ"); Otarget = serializedObject.FindProperty("target"); }
private void Awake() { // Set the instance if needed if (!Instance) { Instance = this; } else { TDS_CustomDebug.CustomDebugLog("There is already a camera instance in this scene ! Destroys CameraBehaviour script", "Lucas"); Destroy(this); return; } }
// Awake is called when the script instance is being loaded private void Awake() { // Set the singleton instance if null if (!Instance) { Instance = this; } else { Destroy(this); return; } // Debug warning is missing bound(s) if (!topBound || !leftBound || !rightBound || !bottomBound) { Debug.LogWarning($"Missing bound(s) for the Camera \"{name}\""); } // Calculate aspect SetCameraAspect(); }
private void OnDestroy() { // Nullifies the instance Instance = null; }