Пример #1
0
        void Awake()
        {
            UIObject3D      = this.GetComponent <UIObject3D>();
            initialRotation = UIObject3DUtilities.NormalizeRotation(UIObject3D.TargetRotation);

            SetupEvents();
        }
Пример #2
0
        /// <summary>
        /// Clear references to textures and delete the target objects.
        /// </summary>
        public void Cleanup()
        {
            _texture2D     = null;
            _sprite        = null;
            _renderTexture = null;

            _target          = null;
            _targetContainer = null;

            targetBounds = default(Bounds);
            _textureSize = default(Vector2);

            if (_container != null)
            {
                UIObject3DUtilities.UnRegisterTargetContainer(this);

                if (Application.isPlaying)
                {
                    Destroy(_container.gameObject);
                }
                else
                {
                    DestroyImmediate(_container.gameObject);
                }

                _container = null;
            }
        }
Пример #3
0
        IEnumerator SnapBack(float time)
        {
            var timeStarted = Time.time;

            float   percentageComplete = 0f;
            Vector3 snapStartRotation  = UIObject3DUtilities.NormalizeRotation(UIObject3D.TargetRotation);


            // This sort of works, but perhaps it would be best to simply go back the way we came?
            float desiredX = (Mathf.Abs(snapStartRotation.x - initialRotation.x) >= 180f) ? (initialRotation.x - 180f) : initialRotation.x;
            float desiredY = (Mathf.Abs(snapStartRotation.y - initialRotation.y) >= 180f) ? (initialRotation.y - 180f) : initialRotation.y;
            float desiredZ = (Mathf.Abs(snapStartRotation.z - initialRotation.z) >= 180f) ? (initialRotation.z - 180f) : initialRotation.z;

            while (percentageComplete < 1f)
            {
                //UIObject3D.TargetRotation = Vector3.Lerp(snapStartRotation, initialRotation, percentageComplete);
                UIObject3D.TargetRotation = new Vector3(
                    (RotateX ? Mathf.Lerp(snapStartRotation.x, desiredX, percentageComplete) : desiredX),
                    (RotateY ? Mathf.Lerp(snapStartRotation.y, desiredY, percentageComplete) : desiredY),
                    (RotateZ ? Mathf.Lerp(snapStartRotation.z, desiredZ, percentageComplete) : desiredZ)
                    );

                percentageComplete = (Time.time - timeStarted) / time;

                yield return(null);
            }

            UIObject3D.TargetRotation = initialRotation;
        }
Пример #4
0
 void OnDestroy()
 {
     UIObject3DUtilities.UnRegisterTargetContainer(this);
 }