public void EditSceneGUI() { Transform transform = m_LineRenderer.useWorldSpace ? null : m_LineRenderer.transform; if (m_LineRenderer.positionCount == 0) { return; } PointEditor.SelectPoints(this, transform, ref m_Selection); PointEditor.Draw(this, transform, m_Selection, true); PointEditor.MovePoints(this, transform, m_Selection); if (showWireframe) { DrawWireframe(); } HandleEditMenuHotKeyCommands(); }
public bool OnSceneGUI(Transform transform) { if (!m_Group.enabled) { return(m_Editing); } if (Event.current.type == EventType.Layout) { //If the group has moved / scaled since last frame need to retetra);) if (m_LastPosition != m_Group.transform.position || m_LastRotation != m_Group.transform.rotation || m_LastScale != m_Group.transform.localScale) { MarkSourcePositionsDirty(); } m_LastPosition = m_Group.transform.position; m_LastRotation = m_Group.transform.rotation; m_LastScale = m_Group.transform.localScale; } //Need to cache this as select points will use it! var mouseUpEvent = Event.current.type == EventType.MouseUp; if (m_Editing) { if (PointEditor.SelectPoints(this, transform, ref m_Selection)) { Undo.RegisterCompleteObjectUndo(new Object[] { m_Group, m_SerializedSelectedProbes }, "Select Probes"); } } //Special handling for paste (want to be able to paste when not in edit mode!) if ((Event.current.type == EventType.ValidateCommand || Event.current.type == EventType.ExecuteCommand) && Event.current.commandName == EventCommandNames.Paste) { if (Event.current.type == EventType.ValidateCommand) { if (CanPasteProbes()) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { if (PasteProbes()) { Event.current.Use(); m_Editing = true; } } } if (drawTetrahedra) { DrawTetrahedra(); } PointEditor.Draw(this, transform, m_Selection, true); if (!m_Editing) { return(m_Editing); } HandleEditMenuHotKeyCommands(); if (m_Editing && PointEditor.MovePoints(this, transform, m_Selection)) { Undo.RegisterCompleteObjectUndo(new Object[] { m_Group, m_SerializedSelectedProbes }, "Move Probes"); if (LightProbeVisualization.dynamicUpdateLightProbes) { MarkSourcePositionsDirty(); } } if (m_Editing && mouseUpEvent && !LightProbeVisualization.dynamicUpdateLightProbes) { MarkSourcePositionsDirty(); } return(m_Editing); }
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int controlID = GUIUtility.GetControlID(FocusType.Passive); bool result; if (Event.current.alt && Event.current.type != EventType.Repaint) { result = false; } else { bool flag = false; Event current = Event.current; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlID || firstSelect) && current.button == 0) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag = true; } PointEditor.s_SelectionStart = new List <int>(selection); GUIUtility.hotControl = controlID; PointEditor.s_StartMouseDragPosition = current.mousePosition; PointEditor.s_StartDragSelection = new List <int>(selection); current.Use(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID && current.button == 0) { if (!PointEditor.s_DidDrag) { int num = PointEditor.FindNearest(PointEditor.s_StartMouseDragPosition, cloudTransform, points); if (num != -1) { if (!current.shift && !EditorGUI.actionKey) { selection.Add(num); } else { int num2 = selection.IndexOf(num); if (num2 != -1) { selection.RemoveAt(num2); } else { selection.Add(num); } } } GUI.changed = true; flag = true; } PointEditor.s_StartDragSelection = null; PointEditor.s_StartMouseDragPosition = Vector2.zero; PointEditor.s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID && current.button == 0) { PointEditor.s_DidDrag = true; selection.Clear(); selection.AddRange(PointEditor.s_StartDragSelection); Rect rect = PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int i = 0; i < points.Count; i++) { Vector2 point = HandleUtility.WorldToGUIPoint(points.GetPosition(i)); if (rect.Contains(point)) { if (EditorGUI.actionKey) { if (PointEditor.s_SelectionStart.Contains(i)) { selection.Remove(i); } } else if (!PointEditor.s_SelectionStart.Contains(i)) { selection.Add(i); } } } Handles.matrix = matrix; GUI.changed = true; current.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == controlID && current.mousePosition != PointEditor.s_StartMouseDragPosition) { GUIStyle gUIStyle = "SelectionRect"; Handles.BeginGUI(); gUIStyle.Draw(PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); } break; case EventType.Layout: HandleUtility.AddDefaultControl(controlID); break; } if (flag) { selection = selection.Distinct <int>().ToList <int>(); } result = flag; } return(result); }
public bool OnSceneGUI(Transform transform) { if (!m_Group.enabled) { return(m_Editing); } if (Event.current.type == EventType.Layout) { //If the group has moved / scaled since last frame need to retetra);) if (m_LastPosition != m_Group.transform.position || m_LastRotation != m_Group.transform.rotation || m_LastScale != m_Group.transform.localScale) { MarkTetrahedraDirty(); } m_LastPosition = m_Group.transform.position; m_LastRotation = m_Group.transform.rotation; m_LastScale = m_Group.transform.localScale; } //See if we should enter edit mode! bool firstSelect = false; if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { //We have no probes selected and have clicked the mouse... Did we click a probe if (SelectedCount == 0) { var selected = PointEditor.FindNearest(Event.current.mousePosition, transform, this); var clickedProbe = selected != -1; if (clickedProbe && !m_Editing) { m_Inspector.StartEditMode(); m_Editing = true; firstSelect = true; } } } //Need to cache this as select points will use it! var mouseUpEvent = Event.current.type == EventType.MouseUp; if (m_Editing) { if (PointEditor.SelectPoints(this, transform, ref m_Selection, firstSelect)) { Undo.RegisterCompleteObjectUndo(new Object[] { m_Group, m_SerializedSelectedProbes }, "Select Probes"); } } //Special handling for paste (want to be able to paste when not in edit mode!) if ((Event.current.type == EventType.ValidateCommand || Event.current.type == EventType.ExecuteCommand) && Event.current.commandName == EventCommandNames.Paste) { if (Event.current.type == EventType.ValidateCommand) { if (CanPasteProbes()) { Event.current.Use(); } } if (Event.current.type == EventType.ExecuteCommand) { if (PasteProbes()) { Event.current.Use(); m_Editing = true; } } } if (drawTetrahedra) { DrawTetrahedra(); } PointEditor.Draw(this, transform, m_Selection, true); if (!m_Editing) { return(m_Editing); } HandleEditMenuHotKeyCommands(); if (m_Editing && PointEditor.MovePoints(this, transform, m_Selection)) { Undo.RegisterCompleteObjectUndo(new Object[] { m_Group, m_SerializedSelectedProbes }, "Move Probes"); if (LightProbeVisualization.dynamicUpdateLightProbes) { MarkTetrahedraDirty(); } } if (m_Editing && mouseUpEvent && !LightProbeVisualization.dynamicUpdateLightProbes) { MarkTetrahedraDirty(); } return(m_Editing); }
public bool OnSceneGUI(Transform transform) { if (!this.m_Group.enabled) { return(this.m_Editing); } if (Event.current.type == EventType.Layout) { if (this.m_LastPosition != this.m_Group.transform.position || this.m_LastRotation != this.m_Group.transform.rotation || this.m_LastScale != this.m_Group.transform.localScale) { this.MarkTetrahedraDirty(); } this.m_LastPosition = this.m_Group.transform.position; this.m_LastRotation = this.m_Group.transform.rotation; this.m_LastScale = this.m_Group.transform.localScale; } bool firstSelect = false; if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && (this.SelectedCount == 0 && PointEditor.FindNearest(Event.current.mousePosition, transform, (IEditablePoint)this) != -1) && !this.m_Editing) { this.m_Editing = true; firstSelect = true; } bool flag = Event.current.type == EventType.MouseUp; if (this.m_Editing && PointEditor.SelectPoints((IEditablePoint)this, transform, ref this.m_Selection, firstSelect)) { Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[2] { (UnityEngine.Object) this.m_Group, (UnityEngine.Object) this.m_SerializedSelectedProbes }, "Select Probes"); } if (this.m_Editing && flag && this.SelectedCount == 0) { this.m_Editing = false; this.MarkTetrahedraDirty(); } if ((Event.current.type == EventType.ValidateCommand || Event.current.type == EventType.ExecuteCommand) && Event.current.commandName == "Paste") { if (Event.current.type == EventType.ValidateCommand && LightProbeGroupEditor.CanPasteProbes()) { Event.current.Use(); } if (Event.current.type == EventType.ExecuteCommand && this.PasteProbes()) { Event.current.Use(); this.m_Editing = true; } } this.DrawTetrahedra(); PointEditor.Draw((IEditablePoint)this, transform, this.m_Selection, true); if (!this.m_Editing) { return(this.m_Editing); } this.HandleEditMenuHotKeyCommands(); if (this.m_Editing && PointEditor.MovePoints((IEditablePoint)this, transform, this.m_Selection)) { Undo.RegisterCompleteObjectUndo(new UnityEngine.Object[2] { (UnityEngine.Object) this.m_Group, (UnityEngine.Object) this.m_SerializedSelectedProbes }, "Move Probes"); if (LightmapVisualization.dynamicUpdateLightProbes) { this.MarkTetrahedraDirty(); } } if (this.m_Editing && flag && !LightmapVisualization.dynamicUpdateLightProbes) { this.MarkTetrahedraDirty(); } return(this.m_Editing); }
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int controlId = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.alt && Event.current.type != EventType.Repaint) { return(false); } bool flag = false; Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlId || firstSelect) && current.button == 0) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag = true; } GUIUtility.hotControl = controlId; PointEditor.s_StartMouseDragPosition = current.mousePosition; PointEditor.s_StartDragSelection = new List <int>((IEnumerable <int>)selection); current.Use(); break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId && current.button == 0) { if (!PointEditor.s_DidDrag) { int nearest = PointEditor.FindNearest(PointEditor.s_StartMouseDragPosition, cloudTransform, points); if (nearest != -1) { if (!current.shift && !EditorGUI.actionKey) { selection.Add(nearest); } else { int index = selection.IndexOf(nearest); if (index != -1) { selection.RemoveAt(index); } else { selection.Add(nearest); } } } GUI.changed = true; flag = true; } PointEditor.s_StartDragSelection = (List <int>)null; PointEditor.s_StartMouseDragPosition = Vector2.zero; PointEditor.s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId && current.button == 0) { PointEditor.s_DidDrag = true; selection.Clear(); selection.AddRange((IEnumerable <int>)PointEditor.s_StartDragSelection); Rect rect = PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int idx = 0; idx < points.Count; ++idx) { Vector2 guiPoint = HandleUtility.WorldToGUIPoint(points.GetPosition(idx)); if (rect.Contains(guiPoint)) { selection.Add(idx); } } Handles.matrix = matrix; GUI.changed = true; current.Use(); break; } break; case EventType.Repaint: if (GUIUtility.hotControl == controlId && current.mousePosition != PointEditor.s_StartMouseDragPosition) { GUIStyle guiStyle = (GUIStyle)"SelectionRect"; Handles.BeginGUI(); guiStyle.Draw(PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); break; } break; case EventType.Layout: HandleUtility.AddDefaultControl(controlId); break; } selection = selection.Distinct <int>().ToList <int>(); return(flag); }