protected void InitData() { if (Target == null) { return; } this.ListClip.Clear(); var animatorListClips = Target.animator.listClips; foreach (var clip in animatorListClips) { EditorClip eclip = new EditorClip(); eclip.name = clip.name; eclip.SetParam("clipName", clip.clipName); eclip.SetParam("param", clip.param); eclip.SetParam("length", clip.length.ToString()); eclip.SetParam("speed", clip.speed.ToString()); eclip.SetParam("fadeFactor", clip.fadeFactor.ToString()); eclip.SetParam("wrapMode", clip.wrapMode.ToString()); eclip.SetParam("crossMode", clip.crossMode.ToString()); foreach (var clipevent in clip.clipEvents) { EditorClipEvent ece = new EditorClipEvent(); ece.name = clipevent.name; ece.triggerTime = clipevent.trigger; ece.SetParam("param", clipevent.param); eclip.ListClipEvent.Add(ece); } this.ListClip.Add(eclip); } }
private void InitData() { if (Target == null) { return; } this.ListClip.Clear(); foreach (var clip in Target.listClips) { EditorClip eclip = new EditorClip(); eclip.name = clip.name; eclip.SetParam("detialName", clip.detialName); eclip.SetParam("param", clip.param); eclip.SetParam("loop", clip.loop.ToString()); eclip.SetParam("length", clip.length.ToString()); foreach (var clipevent in clip.clipEvents) { EditorClipEvent ece = new EditorClipEvent(); ece.name = clipevent.name; ece.triggerTime = clipevent.trigger; ece.SetParam("rate", clipevent.rate.ToString()); ece.SetParam("param", clipevent.param); eclip.ListClipEvent.Add(ece); } this.ListClip.Add(eclip); } }
protected void FixSelecter() { EditorClip newSelectClip = null; EditorClipEvent newSelectClipEvent = null; if (mSelectClip != null) { foreach (EditorClip eclip in ListClip) { if (eclip == mSelectClip) { newSelectClip = eclip; if (mSelectClipEvent != null) { foreach (EditorClipEvent eClipEvent in eclip.ListClipEvent) { if (mSelectClipEvent == eClipEvent) { newSelectClipEvent = eClipEvent; } } } } } } mSelectClip = newSelectClip; mSelectClipEvent = newSelectClipEvent; if (mSelectClip != null && mSelectClipEvent != null) { SetSelectListClipEvent(mSelectClip, mSelectClipEvent); } }
protected void EventMeauDeleteClipEvent(EditorClip clip, EditorClipMaker maker) { clip.BeginChange(); clip.ListClipEvent.Remove(this); clip.EndChange(); maker.ClearSelectClipEvent(); maker.MarkModified(); }
protected override void OnClickClip(EditorClip target) { int interval = Mathf.Abs(System.Environment.TickCount - m_ClipClickTick); m_ClipClickTick = System.Environment.TickCount; if (interval < 200) { ChangePreviewDetialStyle(); } }
public EditorClip Clone() { EditorClip ret = new EditorClip(); foreach (var item in this.ListClipEvent) { ret.ListClipEvent.Add(item.Clone()); } this.CopyCustomParamsTo(ret); return(ret); }
public new void Show() { base.Show(); if (!mIsShowing) { UnityEditor.Undo.undoRedoPerformed += Undo; } mIsShowing = true; mSelectClip = null; mSelectClipEvent = null; selectListClipEvent.Clear(); OnOpen(); }
public void SetSelectListClipEvent(EditorClip clip, EditorClipEvent clipEvent) { selectListClipEvent.Clear(); if (clip == null || clipEvent == null) { return; } foreach (EditorClipEvent item in clip.ListClipEvent) { if (item.triggerTime == clipEvent.triggerTime) { selectListClipEvent.Add(item); } } }
//绘制控制操作下来列表 protected void DrawCtlOptMeau(Rect rectArea) { if (Event.current.type == EventType.ContextClick && rectArea.Contains(Event.current.mousePosition)) { GenericMenu menu = new GenericMenu(); GenericMenu.MenuFunction2 callAddTrack = delegate(object userData) { this.BeginChange(); EditorClip clip = new EditorClip(); clip.name = "new clip"; this.ListClip.Add(clip); this.EndChange(); }; menu.AddItem(new GUIContent("Add Track"), false, callAddTrack, null); // Now create the menu, add items and show it if (menu != null) { menu.ShowAsContext(); } Event.current.Use(); } }
public void Draw(Rect rect, EditorClip clip, EditorClipMaker maker) { float x = 0; if (mDrag) { x = rect.width * m_DragTriggerTime; } else { x = rect.width * m_TriggerTime; } position = new Rect(rect.x + x - WidthNode / 2, rect.y, WidthNode, maker.heightTrack); EditorGUI.DrawRect(position, maker.GetColorSet(this.name)); if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && position.Contains(Event.current.mousePosition)) { // Now create the menu, add items and show it GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy Event"), false, EventMeauCopyClipEvent); menu.AddSeparator(""); menu.AddItem(new GUIContent("Delete Event"), false, (e) => { EventMeauDeleteClipEvent(clip, maker); }, null); menu.ShowAsContext(); Event.current.Use(); } else { if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (position.Contains(Event.current.mousePosition)) { mDrag = true; m_DragTriggerTime = rect.width * triggerTime; maker.SetSelectClip(clip); maker.SetSelectClipEvent(this); maker.SetSelectListClipEvent(clip, this); maker.SetClickOpera(this); maker.Repaint(); Event.current.Use(); } } else if (Event.current.type == EventType.MouseUp) { if (mDrag == true && m_DragTriggerTime != m_TriggerTime) { this.BeginChange(); m_TriggerTime = m_DragTriggerTime; this.EndChange(); maker.MarkModified(); } mDrag = false; } if (mDrag) { float dragDetlaPos = Mathf.Clamp(Event.current.mousePosition.x, rect.x, rect.x + rect.width) - rect.x; dragDetlaPos = Mathf.Clamp(dragDetlaPos, 0, rect.width); float newtrigger = Mathf.Max(dragDetlaPos / rect.width, 0); if (Mathf.Abs(newtrigger - m_DragTriggerTime) > Deadzoom) { m_DragTriggerTime = (float)System.Math.Round(newtrigger, 2); maker.SetSelectListClipEvent(clip, this); maker.Repaint(); // maker.MarkChange (); // colorFrame = frameColorselected; } } else { // colorFrame = getFrameColor(editorAAClip.Target); } } }
protected void Reset() { mSelectClip = null; mSelectClipEvent = null; selectListClipEvent.Clear(); }
//点击轨道 virtual protected void OnClickClip(EditorClip target) { }
public void SetSelectClip(EditorClip clip) { mSelectClip = clip; //为了失去焦点,更新显示值 GUI.FocusControl("None"); }
public void ClearSelectClip() { mSelectClip = null; }