Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            MeshGenerator generator = (MeshGenerator)target;

            if (generator.baked)
            {
                GUILayout.Label("BAKED. DOES NOT UPDATE.");
                if (GUILayout.Button("Revert Bake"))
                {
                    generator.Unbake();
                    EditorUtility.SetDirty(target);
                }
                return;
            }
            EditorGUI.BeginChangeCheck();
            BaseGUI();
            ShowInfo();
            if (GUILayout.Button("Bake Mesh"))
            {
                bakeWindow = EditorWindow.GetWindow <BakeMeshWindow>();
                bakeWindow.Init(generator);
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(target);
            }
        }
Esempio n. 2
0
 protected override void FooterGUI()
 {
     base.FooterGUI();
     showInfo = EditorGUILayout.Foldout(showInfo, "Info & Components");
     if (showInfo)
     {
         MeshGenerator generator = (MeshGenerator)target;
         MeshFilter    filter    = generator.GetComponent <MeshFilter>();
         if (filter == null)
         {
             return;
         }
         MeshRenderer renderer = generator.GetComponent <MeshRenderer>();
         string       str      = "";
         if (filter.sharedMesh != null)
         {
             str = "Vertices: " + filter.sharedMesh.vertexCount + "\r\nTriangles: " + (filter.sharedMesh.triangles.Length / 3);
         }
         else
         {
             str = "No info available in prefab mode";
         }
         EditorGUILayout.HelpBox(str, MessageType.Info);
         bool showFilter = filter.hideFlags == HideFlags.None;
         bool last       = showFilter;
         showFilter = EditorGUILayout.Toggle("Show Mesh Filter", showFilter);
         if (last != showFilter)
         {
             if (showFilter)
             {
                 filter.hideFlags = HideFlags.None;
             }
             else
             {
                 filter.hideFlags = HideFlags.HideInInspector;
             }
         }
         bool showRenderer = renderer.hideFlags == HideFlags.None;
         last         = showRenderer;
         showRenderer = EditorGUILayout.Toggle("Show Mesh Renderer", showRenderer);
         if (last != showRenderer)
         {
             if (showRenderer)
             {
                 renderer.hideFlags = HideFlags.None;
             }
             else
             {
                 renderer.hideFlags = HideFlags.HideInInspector;
             }
         }
     }
     if (GUILayout.Button("Bake Mesh"))
     {
         MeshGenerator generator = (MeshGenerator)target;
         bakeWindow = EditorWindow.GetWindow <BakeMeshWindow>();
         bakeWindow.Init(generator);
     }
 }