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); } } |
原文地址:http://blog.csdn.net/akof1314/article/details/38978709