Example #1
0
        //CONTEXT
        void DoClipContextMenu()
        {
            var menu = new GenericMenu();

            if (multiSelection != null && multiSelection.Contains(this))
            {
                menu.AddItem(new GUIContent("Delete Clips"), false, () =>
                {
                    editor.SafeDoAction(() =>
                    {
                        foreach (var act in multiSelection.Select(b => b.action).ToArray())
                        {
                            (act.parent as Track).DeleteClip(act);
                        }
                        editor.InitClipWrappers();
                        multiSelection = null;
                    });
                });

                menu.ShowAsContext();
                e.Use();
                return;
            }


            menu.AddItem(new GUIContent("Copy Clip"), false, () =>
            {
                editor.SafeDoAction(() => { CutsceneUtility.CopyClip(action); });
            });

            var clips = action.parent.clips.FindAll((t) => { return(t.startTime == action.startTime && t.length <= action.length); });

            if (clips != null && clips.Count > 1)
            {
                int index = 0;
                foreach (var clip in clips)
                {
                    menu.AddItem(new GUIContent("重叠的clip/" + clip.name + "  " + index), false, () =>
                    {
                        CutsceneUtility.selectedObject = clip;
                    });
                    index++;
                }
            }

            menu.AddSeparator("/");

            menu.AddItem(new GUIContent("Delete Clip"), false, () =>
            {
                editor.SafeDoAction(() => { (action.parent as Track).DeleteClip(action); editor.InitClipWrappers(); });
            });

            menu.ShowAsContext();
            e.Use();
        }
Example #2
0
        void DoTrackContextMenu(Event e, Rect clipsPosRect, float cursorTime, System.Action action, System.Action <Track> onDragUpdated, System.Action <Track, float> onDragPerform)
        {
            if (e.type == EventType.ContextClick && clipsPosRect.Contains(e.mousePosition))
            {
                var attachableTypeInfos = new List <EditorTools.TypeMetaInfo>();

                foreach (var info in EditorTools.GetTypeMetaDerivedFrom(typeof(Clip), Prefs.isOld))
                {
                    if (info.attachableTypes != null && !info.attachableTypes.Contains(this.GetType()))
                    {
                        continue;
                    }
                    if (info.type != typeof(Clip))
                    {
                        attachableTypeInfos.Add(info);
                    }
                }
                var menu = new UnityEditor.GenericMenu();
                if (attachableTypeInfos.Count > 0)
                {
                    foreach (var _info in attachableTypeInfos)
                    {
                        var info  = _info;
                        var tName = info.name;
                        menu.AddItem(new GUIContent(tName), false, () =>
                        {
                            var clip       = ReflectionTools.CreateInstance(_info.type) as Clip;
                            clip.startTime = cursorTime;
                            AddNode(clip);
                            CutsceneUtility.selectedObject = clip;
                            if (action != null)
                            {
                                action();
                            }
                        });
                    }
                    e.Use();
                }
                if (CutsceneUtility.CanPastClip(attachableTypeInfos))
                {
                    menu.AddItem(new GUIContent("粘贴"), false, () =>
                    {
                        CutsceneUtility.PasteClip(this, cursorTime);
                    });
                }
                if (menu.GetItemCount() > 0)
                {
                    menu.ShowAsContext();
                }
                else
                {
                    menu = null;
                }
            }
            if (clipsPosRect.Contains(e.mousePosition) && e.type == EventType.DragUpdated)
            {
                if (onDragUpdated != null)
                {
                    onDragUpdated(this);
                }
            }

            if (clipsPosRect.Contains(e.mousePosition) && e.type == EventType.DragPerform)
            {
                if (onDragPerform != null)
                {
                    onDragPerform(this, cursorTime);
                }
                //for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                //{
                //    var o = DragAndDrop.objectReferences[i];
                //    if (o is AnimationClip && this is SkillAnimationTrack)
                //    {
                //        var aniClip = new SKillAnimationEvent();
                //        AddNode(aniClip);
                //        aniClip.startTime = cursorTime;
                //        aniClip.length = (o as AnimationClip).length;
                //        aniClip.animationClip = o as AnimationClip;
                //        if (action != null) action();
                //        CutsceneUtility.selectedObject = aniClip;
                //    }
                //}
                SortClips();
            }
        }