public void InstantDestroyAllRipples(bool alsoResetHighlight = true) { if (rippleData != null) { if (rippleData.RippleParent != null) { Ripple[] ripples = rippleData.RippleParent.GetComponentsInChildren <Ripple>(); for (int i = 0; i < ripples.Length; i++) { ripples[i].InstantContract(); } m_CurrentRipple = null; if (highlightWhen != HighlightActive.Never) { highlightGraphic.color = m_NormalColor; CheckTransparency(); m_AnimState = 0; } } } }
/// <summary> /// Begins the current ripple's contract animation and destroys it upon completion. /// </summary> private void DestroyRipple() { if (m_CurrentRipple) { m_CurrentRipple.Contract(); m_CurrentRipple = null; } }
/// <summary> /// Creates a new Ripple and adds it to the queue. /// </summary> private void CreateRipple() { Ripple ripple = PrefabManager.InstantiateGameObject("Ripple", FindObjectOfType <CanvasScaler>().transform).GetComponent <Ripple>(); ripple.Create(rippleCount, rippleImageData); rippleCount++; ReleaseRipple(ripple); }
/// <summary> /// Resets a ripple's data, ready to reuse. /// </summary> /// <param name="ripple">The ripple.</param> private void ResetRipple(Ripple ripple) { ripple.rectTransform.SetParent(transform); ripple.rectTransform.localScale = Vector3.zero; ripple.rectTransform.sizeDelta = Vector2.zero; ripple.rectTransform.anchoredPosition = Vector2.zero; ripple.color = Color.clear; ripple.canvasGroup.alpha = 0f; ripple.ClearData(); }
/// <summary> /// Creates a new ripple and sets its RippleData, then starts its expand animation. /// </summary> /// <param name="position">The position to create the Ripple.</param> /// <param name="oscillate">Should the Ripple oscillate in size?</param> private void CreateRipple(Vector2 position, bool oscillate = false) { if (!m_RipplesEnabled) { return; } m_CurrentRipple = RippleManager.instance.GetRipple(); m_CurrentRipple.Setup(rippleData, position, this, oscillate); m_CurrentRipple.Expand(); }
/// <summary> /// Gets the next queued ripple. /// If none available, one will be created. /// </summary> /// <returns>A ripple object, ready to Setup and expand.</returns> public Ripple GetRipple() { if (m_QueuedRipples.Count <= 0) { CreateRipple(); } Ripple ripple = m_QueuedRipples.Dequeue(); m_ActiveRipples.Add(ripple); ripple.gameObject.SetActive(true); return(ripple); }
/// <summary> /// See MonoBehaviour.OnApplicationQuit. /// </summary> void OnApplicationQuit() { Ripple.ResetMaterial(); }
/// <summary> /// Calls <see cref="ResetRipple"/> with the specified ripple and adds it back into the queue. /// </summary> /// <param name="ripple">The ripple to reset and queue.</param> public void ReleaseRipple(Ripple ripple) { ResetRipple(ripple); ripple.gameObject.SetActive(false); m_QueuedRipples.Enqueue(ripple); }