/// <summary> /// Create a TweenRot Component and start a tween /// </summary> /// <param name="go">GameObject to apply tween too</param> /// <param name="duration">Duration of tween</param> /// <param name="rot">The ending value for the tween</param> /// <param name="finished">A optional Callback to fire when the tween is done</param> /// <returns>Return reference to the new TweenRot component</returns> public static TweenRot Tween(GameObject go, float duration, Quaternion rot, UnityAction finished = null) { TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, finished); cls.from = cls.value.eulerAngles; cls.to = rot.eulerAngles; cls.Start(); return(cls); }
/// <summary> /// Create a TweenRot Component and start a tween /// </summary> /// <param name="go">GameObject to apply tween too</param> /// <param name="duration">Duration of tween</param> /// <param name="fromVal">The starting value for the tween</param> /// <param name="toVal">The ending value for the tween</param> /// <param name="style">The style of tween (Once, Looped, PingPong)</param> /// <param name="method">The Interpolation method of the tween</param> /// <param name="finished">A optional Callback to fire when the tween is done</param> /// <returns>Return reference to the new TweenRot component</returns> public static TweenRot Tween(GameObject go, float duration, Quaternion fromVal, Quaternion toVal, Style style, Method method, UnityAction finished = null) { TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, style, method, finished); cls.from = fromVal.eulerAngles; cls.to = toVal.eulerAngles; cls.Start(); return(cls); }
/// <summary> /// Create a TweenRot Component, and starts a tween. /// </summary> /// <param name="go">GameObject to Apply the tween too</param> /// <param name="duration">How long the tween will take</param> /// <param name="rot">The Fianl Value at the end of the tween</param> /// <param name="method">The tweening method</parm> /// <param name="finished">The method execute at the end of the tween</param> /// <returns>Reference to the TweenRot component</returns> static public TweenRot Tween(GameObject go, float duration, Quaternion rot, Style style = Style.Once, Method method = Method.Linear, UnityAction finished = null, bool newObj = true) { TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, style, method, finished, newObj); cls.from = cls.value.eulerAngles; cls.to = rot.eulerAngles; cls.Start(); return(cls); }
void IPointerDownHandler.OnPointerDown(PointerEventData eventData) { if (enabled) { if (!_Started) { Start(); } TweenRot.Tween(target.gameObject, duration, rect.rotation, _Rot * Quaternion.Euler(pressed), style, method); } }
void IPointerExitHandler.OnPointerExit(PointerEventData eventData) { hovered = false; if (enabled) { if (!_Started) { Start(); } TweenRot.Tween(target.gameObject, duration, rect.rotation, _Rot, TweenMain.Style.Once, method); } }
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) { hovered = true; if (enabled) { if (!_Started) { Start(); } TweenRot.Tween(target.gameObject, duration, rect.rotation, _Rot * Quaternion.Euler(hover), style, method); } }
void OnDisable() { if (_Started && target != null) { TweenRot tc = target.GetComponent <TweenRot>(); if (tc != null) { tc.value = _Rot; tc.enabled = false; } } }
void IPointerUpHandler.OnPointerUp(PointerEventData eventData) { if (enabled) { if (!_Started) { Start(); } if (hovered) { TweenRot.Tween(target.gameObject, duration, rect.rotation, _Rot * Quaternion.Euler(hover), style, method); } else { TweenRot.Tween(target.gameObject, duration, rect.rotation, _Rot, TweenMain.Style.Once, method); } } }
public override void OnInspectorGUI() { TweenRot self = (TweenRot)target; EditorGUILayout.BeginHorizontal(); self.from = EditorGUILayout.Vector3Field("From", self.from); if (GUILayout.Button("\u25C0", GUILayout.Width(24f))) { self.FromCurrentValue(); } EditorGUILayout.EndHorizontal(); self.fromOffset = EditorGUILayout.Toggle("Offset", self.fromOffset); EditorGUILayout.BeginHorizontal(); self.to = EditorGUILayout.Vector3Field("To", self.to); if (GUILayout.Button("\u25C0", GUILayout.Width(24f))) { self.ToCurrentValue(); } EditorGUILayout.EndHorizontal(); self.toOffset = EditorGUILayout.Toggle("Offset", self.toOffset); BaseTweenerProperties(); }