/// <summary> /// 当前选中的对象已经改变 /// </summary> public void OnSelectObjChanged(AnimationClip clip, string path) { this.clip = clip; this.path = path; if (clip != null) { AnimationEvent[] arr = AnimationUtility.GetAnimationEvents(clip); event_list = new List <AnimationEvent>(arr); int count = arr.Length; if (key_point_list != null) { key_point_list.Clear(); } key_point_list = new List <KeyPointData>(); for (int i = 0; i < count; i++) { KeyPointData data = new KeyPointData(arr[i].functionName, arr[i].floatParameter, arr[i].intParameter, arr[i].stringParameter, arr[i].time); key_point_list.Add(data); } } kp = null; }
public void RecievePointRelease(KeyPointData keyPointData) { if (selectedKeyPoint != null) { selectedKeyPoint.deselect(); } keyPointData.select(); selectedKeyPoint = keyPointData; }
/// <summary> /// 当前选中的显示列表中条目数据改变 /// </summary> /// <param name="obj"></param> /// <param name="colId"></param> void OnSelectChange(object obj, int colId) { if (selectObj == obj) { return; } selectObj = obj; kp = (KeyPointData)selectObj; kp_Id = key_point_list.IndexOf(kp); int count = key_point_list.Count; for (int i = 0; i < count; i++) { if (key_point_list[i] != null) { key_point_list.Reverse(); } } }
public void OnGUI(Rect pos) { if (clip == null) { return; } //left Rect rect = new Rect(pos.x + list_width, pos.y + list_height, pos.width / 2 - list_width * 2 - rect_offset, pos.height - list_height * 2); GUILayout.BeginArea(rect, EditorConst.WindowBackground); { if (view != null) { view.Draw(new Rect(0, 0, rect.width, rect.height)); view.RefreshData(EditorTool.ToObjectList(key_point_list)); } } GUILayout.EndArea(); //right rect = new Rect(pos.width / 2 - list_width, pos.y + list_height, +pos.width / 2 - list_width * 2 - rect_offset, pos.height - list_height * 2); GUILayout.BeginArea(rect, EditorConst.WindowBackground); { //view.Draw(new Rect(0, 0, rect.width, rect.height)); //view.RefreshData(EditorTool.ToObjectList(event_list)); GUILayout.BeginVertical(); if (clip != null) { GUILayout.Label(" Animation Event "); //basic options EditorGUILayout.Space(); //动画文件信息 EditorGUILayout.LabelField("Animation Clip Name", clip.name); EditorGUILayout.LabelField("Animation Clip Length", string.Format("{0} s", clip.length.ToString())); EditorGUILayout.LabelField("Animation Clip Frame Rate", clip.frameRate.ToString()); } if (kp != null) { //动画事件信息 Action_Event_Type curr = GetActionEventTypeEnum(kp.functionName); Action_Event_Type type = (Action_Event_Type)EditorGUILayout.EnumPopup("Function Type", curr); if (type != curr) { curr = type; kp.functionName = type.ToString(); } EditorGUILayout.LabelField("Function 描述", action_event_type_desc[(int)curr], GUILayout.MinHeight(100)); kp.floatParameter = EditorGUILayout.FloatField("Float", kp.floatParameter); kp.intParameter = EditorGUILayout.IntField("Int", kp.intParameter); kp.stringParameter = EditorGUILayout.TextField("String", kp.stringParameter); kp.time = EditorGUILayout.Slider("Time", kp.time, 0, clip.length); } GUILayout.BeginHorizontal(); if (GUILayout.Button(" Add(no save) ")) { kp = new KeyPointData(Action_Event_Type.OnStartEffect.ToString(), 0, 0, null, 0.1f); key_point_list.Add(kp); kp_Id = key_point_list.Count - 1; } if (GUILayout.Button(" Delete ")) { if (kp == null) { return; } key_point_list.RemoveAt(kp_Id); int count = key_point_list.Count; event_list = new List <AnimationEvent>(); for (int i = 0; i < count; i++) { key_point_list[i].Revert(); AnimationEvent ae = key_point_list[i].GetAnimationEvent(clip.length); event_list.Add(ae); } kp = null; kp_Id = 0; SaveAnimationEventInfo(); } if (GUILayout.Button(" Save ")) { if (kp == null || event_list.Count <= view.CurSelectIndex - 1) { return; } int count = key_point_list.Count; event_list = new List <AnimationEvent>(); for (int i = 0; i < count; i++) { if (kp_Id != i) { key_point_list[i].Revert(); } AnimationEvent ae = key_point_list[i].GetAnimationEvent(clip.length); event_list.Add(ae); } SaveAnimationEventInfo(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.EndArea(); }