public void EditMesh(PlaytimePainter painter, bool editCopy) { if (!painter || painter == target) { return; } if (target) { StopEditingMesh(); } target = painter; targetTransform = painter.transform; editedMesh = new EditableMesh(painter); if (editCopy) { painter.SharedMesh = new Mesh(); } Redraw(); InitGridIfNull(); UndoMoves.Clear(); RedoMoves.Clear(); UndoMoves.Add(editedMesh.Encode().ToString()); MeshTool.OnSelectTool(); }
public void EditMesh(PlaytimePainter pntr, bool EditCopy) { if ((pntr == null) || (pntr == target)) { return; } if (target != null) { DisconnectMesh(); } target = pntr; edMesh = new EditableMesh(); edMesh.Edit(pntr); if (EditCopy) { pntr.meshFilter.sharedMesh = new Mesh(); } Redraw(); pntr.meshNameHolder = edMesh.meshName; InitVertsIfNUll(); SelectedLine = null; SelectedTris = null; SelectedUV = null; undoMoves.Clear(); redoMoves.Clear(); undoMoves.Add(edMesh.Encode().ToString()); MeshTool.OnSelectTool(); }
public bool Inspect() { var changed = false; EditableMesh.inspected = editedMesh; pegi.nl(); target.PreviewShaderToggleInspect().changes(ref changed); if (!target.NotUsingPreview && "preview".select(45, ref MeshShaderMode.selected, MeshShaderMode.AllModes).nl(ref changed)) { MeshShaderMode.ApplySelected(); } var previousTool = MeshTool; if ("tool:".select_Index(35, ref Cfg.meshTool, MeshToolBase.AllTools).changes(ref changed)) { Grid.vertexPointMaterial.SetColor("_Color", MeshTool.VertexColor); previousTool.OnDeSelectTool(); MeshTool.OnSelectTool(); } if (DocsEnabled && pegi.FullWindowService.DocumentationClick("About {0} tool".F(MeshTool.NameForDisplayPEGI()))) { pegi.FullWindowService.DocumentationOpen(MeshTool.Tooltip + (MeshTool.ShowGrid ? GridNavigator.ToolTip : "")); } if (target.skinnedMeshRenderer) { pegi.FullWindowService.WarningDocumentationClickOpen ("When using Skinned Mesh Renderer, the mesh will be transformed by it, so mesh points will not be in the correct position, and it is impossible to do any modifications on mesh with the mouse. It is still possible to do automatic processes like " + "changing mesh profile and everything that doesn't require direct input from mouse over the object. It is recommended to edit the object separately from the skinned mesh." , "Skinned mesh detected"); } pegi.nl(); var mt = MeshTool; mt.Inspect().nl(ref changed); foreach (var p in CameraModuleBase.MeshToolPlugins) { p.MeshToolInspection(mt).nl(ref changed); } pegi.nl(); Grid.vertexPointMaterial.SetColor("_Color", MeshTool.VertexColor); EditableMesh.inspected = null; if (changed) { MeshTool.SetShaderKeywords(); } return(changed); }
public bool PEGI() { bool changed = false; EditableMesh.inspected = edMesh; pegi.newLine(); if (edMesh != null) { if ("Mesh ".foldout(ref inspectMesh).nl()) { changed |= edMesh.Nested_Inspect().nl(); } } pegi.Space(); pegi.newLine(); changed |= target.PreviewShaderToggle_PEGI(); if ((!target.IsOriginalShader) && ("preview".select(45, ref meshSHaderMode.selected, meshSHaderMode.allModes).nl())) { meshSHaderMode.selected.Apply(); } pegi.Space(); pegi.newLine(); var previousTool = MeshTool; if ("tool".select(70, ref Cfg._meshTool, MeshToolBase.AllTools).nl()) { Grid.vertexPointMaterial.SetColor("_Color", MeshTool.VertColor); previousTool.OnDeSelectTool(); MeshTool.OnSelectTool(); } pegi.Space(); pegi.newLine(); "Mesh Name:".edit(70, ref target.meshNameHolder); #if UNITY_EDITOR if (((AssetDatabase.GetAssetPath(target.GetMesh()).Length == 0) || (String.Compare(target.meshNameHolder, target.GetMesh().name) != 0)) && (icon.Save.Click("Save Mesh As {0}".F(target.GenerateMeshSavePath()), 25).nl())) { target.SaveMesh(); } #endif pegi.newLine(); pegi.nl(); MeshTool.PEGI(); pegi.newLine(); if ("Hint".foldout(ref showTooltip).nl()) { pegi.writeHint(MeshTool.Tooltip); } if ("Merge Meshes".foldout(ref showCopyOptions).nl()) { if (!selectedPainters.Contains(target)) { if ("Copy Mesh".Click("Add Mesh to the list of meshes to be merged").nl()) { selectedPainters.Add(target); } if (selectedPainters.Count > 0) { if (edMesh.UV2distributeRow < 2 && "Enable EV2 Distribution".toggleInt("Each mesh's UV2 will be modified to use a unique portion of a texture.", ref edMesh.UV2distributeRow).nl()) { edMesh.UV2distributeRow = Mathf.Max(2, (int)Mathf.Sqrt(selectedPainters.Count)); } else { if (edMesh.UV2distributeCurrent > 0) { ("All added meshes will be distributed in " + edMesh.UV2distributeRow + " by " + edMesh.UV2distributeRow + " grid. By cancelling this added" + "meshes will have UVs unchanged and may use the same portion of Texture (sampled with UV2) as other meshes.").writeHint(); if ("Cancel Distribution".Click().nl()) { edMesh.UV2distributeRow = 0; } } else { "Row:".edit("Will change UV2 so that every mesh will have it's own portion of a texture.", 25, ref edMesh.UV2distributeRow, 2, 16).nl(); "Start from".edit(ref edMesh.UV2distributeCurrent).nl(); } pegi.write("Using " + (edMesh.UV2distributeCurrent + selectedPainters.Count + 1) + " out of " + (edMesh.UV2distributeRow * edMesh.UV2distributeRow).ToString() + " spots"); pegi.newLine(); } "Will Merge with the following:".nl(); for (int i = 0; i < selectedPainters.Count; i++) { if (selectedPainters[i] == null) { selectedPainters.RemoveAt(i); i--; } else { if (icon.Delete.Click(25)) { selectedPainters.RemoveAt(i); i--; } else { selectedPainters[i].gameObject.name.nl(); } } } if ("Merge!".Click().nl()) { foreach (var p in selectedPainters) { edMesh.MergeWith(p); } edMesh.Dirty = true; } } } else { if ("Remove from Copy Selection".Click().nl()) { selectedPainters.Remove(target); } } } pegi.newLine(); Grid.vertexPointMaterial.SetColor("_Color", MeshTool.VertColor); if ((!Application.isPlaying) && ("references".foldout(ref showReferences).nl())) { "vertexPointMaterial".write(Grid.vertexPointMaterial); pegi.newLine(); "vertexPrefab".edit(ref Grid.vertPrefab).nl(); "Max Vert Markers ".edit(ref vertsShowMax).nl(); "pointedVertex".edit(ref Grid.pointedVertex.go).nl(); "SelectedVertex".edit(ref Grid.selectedVertex.go).nl(); } EditableMesh.inspected = null; return(changed); }