public Vector2 GUIToWorld(Vector2 guiPosition) { return(MeshModuleUtility.GUIToWorld(guiPosition)); }
public Vector3 GUIToWorld(Vector2 guiPosition, Vector3 planeNormal, Vector3 planePosition) { return(MeshModuleUtility.GUIToWorld(guiPosition, planeNormal, planePosition)); }
public void OnGUI() { m_ControlID = GUIUtility.GetControlID("BrushWeightEditor".GetHashCode(), FocusType.Passive); EventType eventType = Event.current.GetTypeForControl(controlID); weightEditor.selection = m_Selection; m_CircleVertexSelector.vertices = weightEditor.spriteMeshData.vertices; Vector2 position = MeshModuleUtility.GUIToWorld(Event.current.mousePosition); if (eventType == EventType.Layout && !Event.current.alt) { HandleUtility.AddControl(controlID, 0f); } if (GUIUtility.hotControl == 0 && HandleUtility.nearestControl == controlID && eventType == EventType.MouseDown && Event.current.button == 0 && !Event.current.alt) { GUIUtility.hotControl = controlID; GUI.changed = true; m_DeltaAcc = 0f; m_LastPosition = position; weightEditor.OnEditStart(true); OnBrush(hardness / 100f, position); Event.current.Use(); } if (GUIUtility.hotControl == controlID && eventType == EventType.MouseUp && Event.current.button == 0) { GUIUtility.hotControl = 0; weightEditor.OnEditEnd(); GUI.changed = true; Event.current.Use(); } if (HandleUtility.nearestControl == controlID && Event.current.shift && eventType == EventType.ScrollWheel) { float radiusDelta = HandleUtility.niceMouseDeltaZoom * k_WheelRadiusSpeed; radius = Mathf.Max(1f, radius + radiusDelta); UpdateSelection(position); Event.current.Use(); } if (GUIUtility.hotControl == 0 && HandleUtility.nearestControl == controlID && eventType == EventType.MouseMove) { UpdateSelection(position); Event.current.Use(); } if (GUIUtility.hotControl == controlID && eventType == EventType.MouseDrag) { step = Mathf.Max(step, 1f); Vector2 delta = position - m_LastPosition; Vector2 direction = delta.normalized; Vector2 startPosition = m_LastPosition - direction * m_DeltaAcc; float magnitude = delta.magnitude; m_DeltaAcc += magnitude; if (m_DeltaAcc >= step) { Vector2 stepVector = direction * step; Vector2 currentPosition = startPosition; while (m_DeltaAcc >= step) { currentPosition += stepVector; OnBrush(hardness / 100f, currentPosition); m_DeltaAcc -= step; } } m_LastPosition = position; GUI.changed = true; Event.current.Use(); } if ((GUIUtility.hotControl == controlID || (GUIUtility.hotControl == 0 && HandleUtility.nearestControl == controlID)) && eventType == EventType.Repaint) { Color oldColor = Handles.color; Handles.color = Color.white; if (isSecondaryAction) { Handles.color = Color.red; } if (GUIUtility.hotControl == controlID) { Handles.color = Color.yellow; } Handles.DrawWireDisc(position, Vector3.forward, radius); Handles.color = oldColor; } }