Пример #1
0
        private void ProcessEvents()
        {
            Event e = Event.current;

            switch (e.type)
            {
            case EventType.ContextClick:
                Menu(e);
                break;

            case EventType.MouseDown:
                selected = sm.GetSelected(e.mousePosition, null);
                if (selected)
                {
                    dragOffset = selected.Position - sm.DrawPosToRealPos(e.mousePosition);
                }
                else
                {
                    dragOffset = sm.DrawPosToRealPos(e.mousePosition);
                }
                break;

            case EventType.MouseUp:
                if (!selected)
                {
                    return;
                }
                Handle h = selected as Handle;
                if (h)
                {
                    h.Join(sm.GetSelected(sm.RealPosToDrawPos(h.Position), h));
                }
                else
                {
                    Selection.activeObject = selected;
                }
                selected = null;
                break;

            case EventType.MouseDrag:
                if (selected)
                {
                    Vector2 p = sm.DrawPosToRealPos(e.mousePosition) + dragOffset;
                    selected.Drag(p - selected.Position);
                }
                else
                {
                    Vector2 o = sm.DrawPosToRealPos(e.mousePosition) - dragOffset;
                    sm.drawOffset += o;
                }
                break;

            case EventType.ScrollWheel:
                sm.Zoom += e.delta.y * scrollwheelMultiplier;
                break;
            }
        }
Пример #2
0
        protected override void RemoveNext(SMElementEditor e)
        {
            Handle startHandle = e as Handle;

            if (!startHandle || !Next.Contains(startHandle))
            {
                return;
            }

            RemoveNext(startHandle);
        }
Пример #3
0
        protected override void RemoveBack(SMElementEditor e)
        {
            Handle endHandle = e as Handle;

            if (!endHandle || !Back.Contains(endHandle))
            {
                return;
            }

            RemoveBack(endHandle);
        }
Пример #4
0
        protected override void AddNext(SMElementEditor e)
        {
            Handle startHandle = e as Handle;

            if (!startHandle || startHandle.Back != null || startHandle.Next == null)
            {
                return;
            }

            AddNext(startHandle);
        }
Пример #5
0
        protected override void AddBack(SMElementEditor e)
        {
            Handle endHandle = e as Handle;

            if (!endHandle || endHandle.Back == null || endHandle.Next != null)
            {
                return;
            }

            AddBack(endHandle);
        }
Пример #6
0
        private void Menu(Event e)
        {
            GenericMenu menu = new GenericMenu();

            SMElementEditor elem = sm.GetSelected(e.mousePosition, null);

            if (elem)
            {
                elem.Menu(menu);
            }
            else
            {
                menu.AddItem(new GUIContent("Add State"), false, () => { StateEditor s = StateEditor.CreateState(sm, sm.DrawPosToRealPos(e.mousePosition)); });
                menu.AddItem(new GUIContent("Add Transition"), false, () => { TransitionEditor s = TransitionEditor.CreateTransition(sm, sm.DrawPosToRealPos(e.mousePosition)); });
            }

            menu.ShowAsContext();
        }
 protected virtual void RemoveNext(SMElementEditor e)
 {
     Next.Remove(e);
 }
 protected virtual void RemoveBack(SMElementEditor e)
 {
     Back.Remove(e);
 }
 protected virtual void AddNext(SMElementEditor e)
 {
     Next.Add(e);
 }
        }                                                            //save changes

        //Add and remove methods for Next and Back elements
        protected virtual void AddBack(SMElementEditor e)
        {
            Back.Add(e);
        }