// public delegate void dfff;// = UpdateVisibleClockCount; void Start() { if (original == null) { DontDestroyOnLoad (gameObject); original = this; isOriginal = true; } ClockSpawner.current.clocks.Add (this); if (MaxTimeOffScreen < 2) { MaxTimeOffScreen = 2; } if (original != this) { lifeSpan = Random.Range (0, MaxTimeOffScreen); startingPoint = ClockSpawner.current.SpawnPoint; } if (startingPoint == Vector3.zero && transform.position != Vector3.zero) { startingPoint = transform.position; } }
public static bool IsVisible(ClockBehaviour clock) { var wasOn = clock.isOnScreen; clock.isOnScreen = GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(Camera.main), clock.gameObject.GetComponent<Collider2D>().bounds); if (wasOn != clock.isOnScreen) { clock.fellOffAtTime = Time.fixedTime; } return clock.isOnScreen; }