void Awake()
        {
            m_uiModuleModelObject = this.GetComponent <UIModuleModelObject>();
            initialRotation       = UIModuleModelUtils.NormalizeRotation(m_uiModuleModelObject.TargetRotation);

            SetupEvents();
        }
        IEnumerator SnapBack(float time)
        {
            var timeStarted = Time.time;

            float   percentageComplete = 0f;
            Vector3 snapStartRotation  = UIModuleModelUtils.NormalizeRotation(m_uiModuleModelObject.TargetRotation);

            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)
            {
                m_uiModuleModelObject.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);
            }

            m_uiModuleModelObject.TargetRotation = initialRotation;
        }
Exemplo n.º 3
0
        public void Cleanup()
        {
            m_texture2D     = null;
            m_sprite        = null;
            m_renderTexture = null;
            m_targetBounds  = default(Bounds);

            if (m_container != null)
            {
                UIModuleModelUtils.UnRegisterTargetContainer(this);

                DestroyImmediate(m_container.gameObject);
                m_container = null;
            }
        }
Exemplo n.º 4
0
 void OnDestroy()
 {
     UIModuleModelUtils.UnRegisterTargetContainer(this);
 }