private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); if (DisplayArea.Contains(Event.current.mousePosition)) { var baseAdd = "Add State/{0}"; var allStates = MecanimAnimationUtility.GetAllStateNames(AnimationTimeline.AffectedObject.gameObject, AnimationTrack.Layer); var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * AnimationTimeline.Sequence.Duration) / XScale; foreach (var state in allStates) { contextMenu.AddItem( new GUIContent(string.Format(baseAdd, state)), false, (obj) => AddNewState(((float)((object[])obj)[0]), ((string)((object[])obj)[1])), new object[] { newTime, state } // This object is passed through to the annonymous function that is passed through as the previous argument. ); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }
private void OnMouseDragStart(object?sender, MouseEventArgs e) { if (DisplayArea.Contains(e.Position.ToVector2())) { var element = new DragAndDrop(_ability); element.Show(Root.System); } }
private void OnMouseDragStart(object?sender, MouseEventArgs e) { if (DisplayArea.Contains(e.Position.ToVector2())) { var element = new DragAndDrop(_pack.Item); element.OnSuccesfullyDrop += () => { _pack.Remove(); }; element.Show(Root.System); } }
private void DropItem(DragAndDrop element) { if (DisplayArea.Contains(element.PositionOffset) && element.Icon != _slot.Item) { try { _slot.PutOn(element.Icon as IItem); element.SuccesfullyDrop(); } catch (ArgumentException e) { } } }
private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); foreach (var data in cachedEventRenderData) { if (data.RenderRect.Contains(Event.current.mousePosition)) { contextMenu.AddItem(new GUIContent("Remove Event"), false, () => { RemoveEvent(data.Event); }); contextMenu.AddSeparator(""); break; } } if (DisplayArea.Contains(Event.current.mousePosition)) { var baseAdd = "Add Event/"; var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * Duration) / XScale; var baseType = typeof(USEventBase); var types = USEditorUtility.GetAllSubTypes(baseType).Where(type => type.IsSubclassOf(baseType)); foreach (var type in types) { var fullAdd = baseAdd; var customAttributes = type.GetCustomAttributes(true).Where(attr => attr is USequencerEventAttribute).Cast <USequencerEventAttribute>(); foreach (var customAttribute in customAttributes) { fullAdd += customAttribute.EventPath; } contextMenu.AddItem(new GUIContent(fullAdd), false, (obj) => AddEvent(newTime, (Type)obj), (object)type); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }
private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * Duration) / XScale; USObserverKeyframe overKeyframe = null; foreach (var data in cachedObserverRenderData) { if (data.RenderRect.Contains(Event.current.mousePosition)) { contextMenu.AddItem(new GUIContent("Remove Observer Keyframe"), false, () => { RemoveKeyframe(data.Keyframe); }); contextMenu.AddSeparator(""); overKeyframe = data.Keyframe; break; } } var cameras = Resources.FindObjectsOfTypeAll(typeof(Camera)) as Camera[]; cameras = cameras.OrderBy(camera => camera.name).ToArray(); foreach (var camera in cameras) { if (!ObserverTimeline.IsValidCamera(camera)) { continue; } var assetPath = AssetDatabase.GetAssetPath(camera.gameObject.transform.root.gameObject); if (!string.IsNullOrEmpty(assetPath)) { continue; } var cutTransition = Shared.TypeOfTransition.Cut; var cutDuration = Shared.TransitionHelper.DefaultTransitionTimeFor(cutTransition); contextMenu.AddItem(new GUIContent(String.Format("Set Camera/Cut/{0}", camera.name)), false, (settingCamera) => SetCamera(overKeyframe, newTime, cutTransition, cutDuration, (Camera)settingCamera), camera); var transitions = Enum.GetValues(typeof(Shared.TypeOfTransition)).Cast <Shared.TypeOfTransition>(); foreach (var transition in transitions) { if (transition == Shared.TypeOfTransition.Cut) { continue; } var transitionType = transition; // Keep a local copy of this, so it's safed for our delegate. var transitionDuration = Shared.TransitionHelper.DefaultTransitionTimeFor(transitionType); contextMenu.AddItem(new GUIContent(String.Format("Set Camera/Transition/{0}/{1}", camera.name, transitionType)), false, (settingCamera) => SetCamera(overKeyframe, newTime, transitionType, transitionDuration, (Camera)settingCamera), camera); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }