コード例 #1
0
        private void UpdateBounds(Camera oldCam, Camera newCam)
        {
            if (newCam == null || !newCam.orthographic)
            {
                windowBounds.Value = Vector2.zero;
                return;
            }

            Vector2 bounds = UnityEngineUtils.WorldOrthographicSize(newCam);

            windowBounds.Value = bounds;
        }
コード例 #2
0
        private bool IsOnScreen()
        {
            if (camera == null || camera.Value == null)
            {
                return(false);
            }
            Camera main = camera.Value;

            Vector2 size   = UnityEngineUtils.WorldOrthographicSize(main);
            Bounds  bounds = new Bounds((Vector2)main.transform.position + cameraOffset,
                                        size * cameraScale + cameraSizeInc);

            return(bounds.Contains((Vector2)transform.position));
        }
コード例 #3
0
        public void Register(bool destroyOnRegister = false)
        {
            if (registered)
            {
                return;
            }

            toRegister = GetComponent <T>();
            Assert.IsNotNull(toRegister, "Component not present in RegisterVar " + this.name);
            Assert.IsNotNull(ArrayVar, "ArrayVar not present in RegisterVar " + this.name);
            ArrayVar.Add(toRegister);

            registered = true;

            if (UnityEngineUtils.IsInPlayModeOrAboutToPlay())
            {
                if (destroyOnRegister)
                {
                    Destroy(this);
                }
            }
        }