Ejemplo n.º 1
0
        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);
        }