Unity NGUI 描点控件的位移动画
2 3 4 5 6 7 |
public Transform sourceFrom;
public Transform targetTo; static public TweenPosition Begin(GameObject go, float duration, Transform targetTo) { return Begin(go, duration, go.transform.parent.InverseTransformPoint(targetTo.position)); } |
2 3 4 5 6 7 8 9 10 11 12 13 14 |
protected override void OnUpdate (float factor, bool isFinished)
{ if (sourceFrom != null) { from = cachedTransform.parent.InverseTransformPoint(sourceFrom.position); sourceFrom = null; } if (targetTo != null) { to = cachedTransform.parent.InverseTransformPoint(targetTo.position); targetTo = null; } value = from * (1f - factor) + to * factor; } |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public class TweenPositionEditor : UITweenerEditor
{ public override void OnInspectorGUI () { GUILayout.Space(6f); NGUIEditorTools.SetLabelWidth(120f); TweenPosition tw = target as TweenPosition; GUI.changed = false; Vector3 from = EditorGUILayout.Vector3Field("From", tw.from); Transform sourceFrom = EditorGUILayout.ObjectField("Or From", tw.sourceFrom, typeof(Transform), true) as Transform; Vector3 to = EditorGUILayout.Vector3Field("To", tw.to); Transform targetTo = EditorGUILayout.ObjectField("Or To", tw.targetTo, typeof(Transform), true) as Transform; if (GUI.changed) { NGUIEditorTools.RegisterUndo("Tween Change", tw); tw.from = from; tw.to = to; tw.sourceFrom = sourceFrom; tw.targetTo = targetTo; NGUITools.SetDirty(tw); } DrawCommonProperties(); } } |
2 3 4 5 6 |
public enum Trigger
{ OnClick, …… OnEnableTrue, } |
2 3 4 5 6 7 8 9 |
void OnEnable ()
{ …… if (trigger == Trigger.OnEnableTrue) { Play(true); } } |
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。