예제 #1
0
        /// <summary>
        /// Copies this RippleData.
        /// </summary>
        /// <returns>A copy of this RippleData.</returns>
        public RippleData Copy()
        {
            RippleData data = new RippleData();

            data.AutoSize          = AutoSize;
            data.SizePercent       = SizePercent;
            data.ManualSize        = ManualSize;
            data.SizeMode          = SizeMode;
            data.Speed             = Speed;
            data.Color             = Color;
            data.StartAlpha        = StartAlpha;
            data.EndAlpha          = EndAlpha;
            data.MoveTowardCenter  = MoveTowardCenter;
            data.RippleParent      = RippleParent;
            data.PlaceRippleBehind = PlaceRippleBehind;
            return(data);
        }
예제 #2
0
        /// <summary>
        /// Sets the ripple's transform and rippleData, and prepares it to start expanding.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="positon">The positon.</param>
        /// <param name="creator">The creator to send callbacks to.</param>
        /// <param name="oscillate">If true, the ripple will oscillate when expanded.</param>
        public void Setup(RippleData data, Vector2 positon, IRippleCreator creator, bool oscillate = false)
        {
            m_RippleData   = data;
            m_RippleParent = (RectTransform)data.RippleParent;
            rectTransform.SetParent(m_RippleParent);
            rectTransform.SetSiblingIndex(0);
            m_Oscillate             = oscillate;
            rectTransform.sizeDelta = Vector2.zero;

            Camera camera = FindObjectOfType <Camera>();

            switch (GetComponentInParent <Canvas>().renderMode)
            {
            case RenderMode.ScreenSpaceOverlay:
                rectTransform.position = new Vector3(positon.x, positon.y, m_RippleParent.position.z);
                break;

            case RenderMode.ScreenSpaceCamera:
                rectTransform.position = new Ray(camera.transform.position, camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, m_RippleParent.position.z))).GetPoint(Vector3.Distance(camera.transform.position, m_RippleParent.position));
                break;

            case RenderMode.WorldSpace:
                rectTransform.position = new Ray(camera.transform.position, camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, m_RippleParent.position.z))).GetPoint(Vector3.Distance(camera.transform.position, m_RippleParent.position));
                break;
            }

            rectTransform.localEulerAngles = Vector3.zero;
            color               = data.Color;
            canvasGroup.alpha   = data.StartAlpha;
            m_AnimationDuration = 4f / data.Speed;
            m_RippleCreator     = creator;

            if (data.PlaceRippleBehind)
            {
                int index = m_RippleParent.GetSiblingIndex();
                rectTransform.SetParent(m_RippleParent.parent);
                rectTransform.SetSiblingIndex(index);
            }
        }
예제 #3
0
 /// <summary>
 /// Clears the rippleData, call when resetting the ripple.
 /// </summary>
 public void ClearData()
 {
     m_RippleData = null;
 }