EventGraphWindowItem NewItem(INodedEvent theEvent) { EventGraphWindowItem newItem = new EventGraphWindowItem(theEvent, RemoveItem, this); items.Add(newItem); return(newItem); }
public void BuildLink(UnityEngine.Object other) { Type otherType = other.GetType(); if (otherType == typeof(IBaseEvent) || !(other is IBaseEvent) || source == null) { Debug.LogError("Cette node n'accepte pas les liens 'Moment'. Elle n'implémente pas l'interface IEvent."); } else { BaseMoment moment = source.moments[momentIndex].moment; Type[] interfaces = otherType.FindInterfaces( InterfaceFilter, otherType); for (int i = 0; i < interfaces.Length; i++) { Type[] types = interfaces[i].GetGenericArguments(); if (moment.MatchWithGenericTypes(types)) { source.moments[momentIndex].moment.AddIEvent(other); break; } } } source = null; }
public void BuildLink(EventGraphWindowItem other) { if (source == null) { return; } BuildLink(other.myEvent.AsObject()); }
void ClearItems(bool repaint = true) { ongoingLink.source = null; items = null; lastHilighted = null; copyNode = null; Repaint(); }
public void SetSelectedItem(EventGraphWindowItem item) { if (item == null) { Selection.SetActiveObjectWithContext(null, null); } else { Selection.SetActiveObjectWithContext(item.myEvent.AsObject(), null); } }
public void HighLightItem(EventGraphWindowItem item) { if (lastHilighted != null) { lastHilighted.isHilighted = false; } lastHilighted = item; if (lastHilighted != null) { lastHilighted.isHilighted = true; } }
void RebuildItems() { ongoingLink.source = null; lastHilighted = null; graph.events.RemoveNulls(); items = new List <EventGraphWindowItem>(graph.events.Count); for (int i = 0; i < graph.events.Count; i++) { UnityEngine.Object obj = graph.events[i]; if (obj is INodedEvent) { NewItem(obj as INodedEvent); } } Repaint(); }
void RemoveItem(EventGraphWindowItem item) { Rect popupRect = new Rect(Vector2.zero, new Vector2(210, 65)); try { PopupWindow.Show(popupRect, new EventRemovePopup( delegate() { PopupWindow.focusedWindow.Close(); UnityEngine.Object obj = item.myEvent.AsObject(); DestroyImmediate(obj); SetSelectedItem(null); MarkSceneAsDirty(); })); } catch { } }
void OnGUI() { Event e = Event.current; EventType eventPastType = e.type; lastMousePos = e.mousePosition; if (e.type == EventType.ValidateCommand) { if (e.commandName == "Copy") { Copy(); e.Use(); } else if (e.commandName == "Paste") { Paste(); e.Use(); } } //On ouvre le minimenu else if (e.type == EventType.ContextClick) { EventGraphWindowItem item = GetItemOnMousePosition(lastMousePos); if (item != null) { item.OpenContextMenu(); e.Use(); return; } else { if (!graphInfoRect.Contains(lastMousePos)) { contextMenuMousePos = lastMousePos; e.Use(); OpenContextMenu(); } } } //On selectionne l'item else if (e.type == EventType.MouseDown) { EventGraphWindowItem newSelection = GetItemOnMousePosition(lastMousePos); if (newSelection == null) { //Cancel ongoing moment link if (ongoingLink.source != null && e.button == 0) { ongoingLink.source = null; } //Unselect the previous item if (!graphInfoRect.Contains(lastMousePos)) { ClearFocus(); Repaint(); } HighLightItem(null); } else { //Change selected item if (Selection.activeObject != newSelection.myEvent.AsObject()) { SetSelectedItem(newSelection); Repaint(); } HighLightItem(newSelection); ClearFocus(); } } else if (e.type == EventType.MouseDrag) { if (e.button == 2) { Vector2 delta = e.delta; for (int i = 0; i < items.Count; i++) { Rect rect = items[i].WindowRect; rect.position = rect.position + delta; items[i].WindowRect = rect; } Repaint(); } } // The position of the window BeginWindows(); //Window Count int winC = 0; //Graph info graphInfoRect = GUILayout.Window(winC++, graphInfoRect, Window_GraphInfo, "Graph Info"); //Items ! if (items != null) { for (int i = 0; i < items.Count; i++) { if (items[i].myEvent == null || items[i].myEvent.AsObject() == null) { graph.events.RemoveNulls(); ClearItems(false); break; } GUI.backgroundColor = items[i].myEvent.GUIColor(); items[i].WindowRect = GUILayout.Window(winC++, items[i].WindowRect, items[i].DrawNode, items[i].NodeLabel); } GUI.color = Color.white; } else if (eventPastType == EventType.repaint) { //Rebuild items ? if (graph != null) { SetGraph(graph); } } EndWindows(); //----------------Links----------------// if (items != null) { for (int i = 0; i < items.Count; i++) { items[i].DrawLinks(); } ongoingLink.Draw(lastMousePos); } }