DestroyMaterial() private method

private DestroyMaterial ( ProceduralMaterial material ) : void
material UnityEngine.ProceduralMaterial
return void
Ejemplo n.º 1
0
        private void MaterialManagement()
        {
            SubstanceImporter importer = this.GetImporter();

            if (this.m_PrototypeNames == null)
            {
                this.m_PrototypeNames = importer.GetPrototypeNames();
            }
            ProceduralMaterial selectedMaterial = this.GetSelectedMaterial();

            GUILayout.BeginHorizontal(this.m_SubstanceStyles.toolbar, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
            {
                if (this.m_PrototypeNames.Length > 1)
                {
                    Rect rect = GUILayoutUtility.GetRect(this.m_SubstanceStyles.iconToolbarPlus, this.m_SubstanceStyles.toolbarDropDown);
                    if (EditorGUI.DropdownButton(rect, this.m_SubstanceStyles.iconToolbarPlus, FocusType.Passive, this.m_SubstanceStyles.toolbarDropDown))
                    {
                        GenericMenu genericMenu = new GenericMenu();
                        for (int i = 0; i < this.m_PrototypeNames.Length; i++)
                        {
                            genericMenu.AddItem(new GUIContent(this.m_PrototypeNames[i]), false, new GenericMenu.MenuFunction2(this.InstanciatePrototype), this.m_PrototypeNames[i]);
                        }
                        genericMenu.DropDown(rect);
                    }
                }
                else if (this.m_PrototypeNames.Length == 1)
                {
                    if (GUILayout.Button(this.m_SubstanceStyles.iconToolbarPlus, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        this.m_SelectedMaterialInstanceName = this.GetImporter().InstantiateMaterial(this.m_PrototypeNames[0]);
                        this.ApplyAndRefresh(true);
                    }
                }
                using (new EditorGUI.DisabledScope(selectedMaterial == null))
                {
                    if (GUILayout.Button(this.m_SubstanceStyles.iconToolbarMinus, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        if (this.GetSortedMaterials().Length > 1)
                        {
                            this.SelectNextMaterial();
                            importer.DestroyMaterial(selectedMaterial);
                            this.ApplyAndRefresh(true);
                        }
                    }
                    if (GUILayout.Button(this.m_SubstanceStyles.iconDuplicate, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        string text = importer.CloneMaterial(selectedMaterial);
                        if (text != "")
                        {
                            this.m_SelectedMaterialInstanceName = text;
                            this.ApplyAndRefresh(true);
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        private void MaterialManagement()
        {
            SubstanceImporter importer = this.GetImporter();

            if (this.m_PrototypeNames == null)
            {
                this.m_PrototypeNames = importer.GetPrototypeNames();
            }
            ProceduralMaterial selectedMaterial = this.GetSelectedMaterial();

            GUILayout.BeginHorizontal(this.m_SubstanceStyles.toolbar, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);
            if (this.m_PrototypeNames.Length > 1)
            {
                Rect rect = GUILayoutUtility.GetRect(this.m_SubstanceStyles.iconToolbarPlus, this.m_SubstanceStyles.toolbarDropDown);
                if (EditorGUI.ButtonMouseDown(rect, this.m_SubstanceStyles.iconToolbarPlus, FocusType.Passive, this.m_SubstanceStyles.toolbarDropDown))
                {
                    GenericMenu genericMenu = new GenericMenu();
                    for (int index = 0; index < this.m_PrototypeNames.Length; ++index)
                    {
                        genericMenu.AddItem(new GUIContent(this.m_PrototypeNames[index]), false, new GenericMenu.MenuFunction2(this.InstanciatePrototype), (object)this.m_PrototypeNames[index]);
                    }
                    genericMenu.DropDown(rect);
                }
            }
            else if (this.m_PrototypeNames.Length == 1 && GUILayout.Button(this.m_SubstanceStyles.iconToolbarPlus, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]))
            {
                this.m_SelectedMaterialInstanceName = this.GetImporter().InstantiateMaterial(this.m_PrototypeNames[0]);
                this.ApplyAndRefresh(true);
            }
            EditorGUI.BeginDisabledGroup((UnityEngine.Object)selectedMaterial == (UnityEngine.Object)null);
            if (GUILayout.Button(this.m_SubstanceStyles.iconToolbarMinus, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]) && this.GetSortedMaterials().Length > 1)
            {
                this.SelectNextMaterial();
                importer.DestroyMaterial(selectedMaterial);
                this.ApplyAndRefresh(true);
            }
            if (GUILayout.Button(this.m_SubstanceStyles.iconDuplicate, this.m_SubstanceStyles.toolbarButton, new GUILayoutOption[0]))
            {
                string str = importer.CloneMaterial(selectedMaterial);
                if (str != string.Empty)
                {
                    this.m_SelectedMaterialInstanceName = str;
                    this.ApplyAndRefresh(true);
                }
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
        }