private static void HandleNodeDrag(EditorInputInfo inputInfo) { if (inputInfo.editorState.action == EditorState.Action.Move) { LightUVEditor luv = inputInfo.editorState.editor as LightUVEditor; inputInfo.editorState.dragOffset = inputInfo.inputPos - inputInfo.editorState.dragMouseStart; luv.MoveNode(inputInfo.editorState.dragOffset); } }
private static void HandleNodeMouseUp(EditorInputInfo inputInfo) { if (inputInfo.editorState.action == EditorState.Action.Move) { LightUVEditor luv = inputInfo.editorState.editor as LightUVEditor; luv.node.ApplyOffset(); inputInfo.editorState.dragOffset = Vector2.zero; inputInfo.editorState.dragMouseStart = Vector2.zero; } inputInfo.editorState.action = EditorState.Action.None; }
public void DrawGizmos(LightUVEditor luv) { for (int i = 0; i < triangles.Length; i += 3) { int a = triangles[i]; int b = triangles[i + 1]; int c = triangles[i + 2]; Vector3 pa = mesh.vertices[a]; Vector3 pb = mesh.vertices[b]; Vector3 pc = mesh.vertices[c]; Gizmos.DrawLine(pa, pb); Gizmos.DrawLine(pa, pc); Gizmos.DrawLine(pc, pb); } }
private static void HandleNodeMouseDown(EditorInputInfo inputInfo) { if (Event.current.button == 0) { LightUVEditor luv = inputInfo.editorState.editor as LightUVEditor; if (luv.node.GetSelectElementWithPoint(inputInfo.inputPos)) { inputInfo.editorState.action = EditorState.Action.Move; inputInfo.editorState.dragOffset = Vector2.zero; inputInfo.editorState.dragMouseStart = inputInfo.inputPos; } else { luv.node.SelectElement(-1); } } }
//public void Set public void Draw(LightUVEditor luv) { if (vertices.Length == 0) { return; } float zoom = luv.editorState.zoom; float len = luv.rectLength; using (new DrawMeshScope(luv.editorState.canvasRect, EditorGUIUtility.pixelsPerPoint)) { var offset = (Vector2)editorScreenPointOffset.GetValue(null); offset -= GUIUtility.GUIToScreenPoint(Vector2.zero); Color lineColor = Color.green; lineMaterial.SetColor("_Color", lineColor); lineMaterial.SetFloat("_Thickness", 1); lineMaterial.SetPass(0); Matrix4x4 matrix = Matrix4x4.TRS((luv.editorState.panOffset + Vector2.up * len) / zoom + offset, Quaternion.identity, new Vector3(len / zoom, -len / zoom, 1)); Graphics.DrawMeshNow(lineMesh, matrix, 0); vertexMaterial.SetColor("_Color", Color.white); vertexMaterial.SetFloat("_Radius", 3); vertexMaterial.SetPass(0); Graphics.DrawMeshNow(vertexMesh, matrix, 0); if (selectedElements.Count > 0) { matrix = Matrix4x4.TRS((luv.editorState.panOffset + Vector2.up * len + selectedElementOffset) / zoom + offset, Quaternion.identity, new Vector3(len / zoom, -len / zoom, 1)); lineMaterial.SetPass(0); Graphics.DrawMeshNow(currentElementLineMesh, matrix, 0); vertexMaterial.SetPass(0); Graphics.DrawMeshNow(currentElementVetexMesh, matrix, 0); //Rect selectRect = selectedElement.GetShowRect(); //EditorGUIUtility.AddCursorRect(selectRect, MouseCursor.MoveArrow); //selectRect.x += offset.x; //selectRect.y += offset.y; //EditorUtil.DrawRectWithQuadsLine(selectRect, EditorColor.SelectGridColor, 2f); } } }