public void DrawArray(SerializedObject obj, string property, string title) { SerializedProperty sp = obj.FindProperty(property + ".Array.size"); int size = sp.intValue; int newSize = EditorGUILayout.IntField("Size", size); if (newSize != size) { //添加新的数组内容 obj.FindProperty(property + ".Array.size").intValue = newSize; DoTweenGroup player = target as DoTweenGroup; player.AnimationArray = new DoTweenAlpha[newSize]; } EditorGUI.indentLevel = 1; for (int i = 0; i < newSize; i++) { //随时保存变更的数组内容 SerializedProperty p = obj.FindProperty(string.Format("{0}.Array.data[{1}]", property, i)); EditorGUILayout.PropertyField(p); BaseDoTween anim = p.objectReferenceValue as BaseDoTween; DoTweenGroup player = target as DoTweenGroup; player.AnimationArray[i] = anim; } EditorGUI.indentLevel = 0; }
//停止动画 public void StopAtIndex(int index) { if (MyTweenGroups != null && MyTweenGroups.Length > index) { BaseDoTween anim = MyTweenGroups[index]; if (anim != null) { anim.Stop(); } } }
//播放自己拥有的UI动画[美术挂在这个UI上的动画] public void PlayAtIndex(int index, Action callBack = null) { if (MyTweenGroups != null && MyTweenGroups.Length > index) { BaseDoTween anim = MyTweenGroups[index]; if (anim != null) { SelectPlayGroupIndex = index; if (callBack != null) { anim.OnCompleteAction = callBack; } anim.Play(); } } }
protected void DrawCommonProperties() { BaseDoTween doTween = target as BaseDoTween; GUI.changed = false; BaseDoTween.Style style = (BaseDoTween.Style)EditorGUILayout.EnumPopup("Play Style", doTween.style); AnimationCurve curve = EditorGUILayout.CurveField("Animation Curve", doTween.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f)); GUILayout.BeginHorizontal(); float dur = EditorGUILayout.FloatField("Duration", doTween.duration, GUILayout.Width(170f)); GUILayout.Label("seconds"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); float del = EditorGUILayout.FloatField("Start Delay", doTween.delay, GUILayout.Width(170f)); GUILayout.Label("seconds"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); SerializedProperty sp = serializedObject.FindProperty("OnComplete"); EditorGUILayout.PropertyField(sp, new GUIContent("OnComplete")); GUILayout.EndHorizontal(); if (GUI.changed) { doTween.animationCurve = curve; doTween.style = style; doTween.duration = dur; doTween.delay = del; doTween.OnComplete = sp.objectReferenceValue as BaseDoTween; #if UNITY_EDITOR if (doTween) { UnityEditor.EditorUtility.SetDirty(doTween); } #endif } }