private Editor GetSelectedMaterialInspector() { ProceduralMaterial selectedMaterial = this.GetSelectedMaterial(); Editor materialInspector; if (selectedMaterial && this.m_MaterialInspector != null && this.m_MaterialInspector.target == selectedMaterial) { materialInspector = this.m_MaterialInspector; } else { EditorGUI.EndEditingActiveTextField(); UnityEngine.Object.DestroyImmediate(this.m_MaterialInspector); this.m_MaterialInspector = null; if (selectedMaterial) { this.m_MaterialInspector = Editor.CreateEditor(selectedMaterial); if (!(this.m_MaterialInspector is ProceduralMaterialInspector) && this.m_MaterialInspector != null) { if (selectedMaterial.shader != null) { Debug.LogError("The shader: '" + selectedMaterial.shader.name + "' is using a custom editor deriving from MaterialEditor, please derive from ShaderGUI instead. Only the ShaderGUI approach works with Procedural Materials. Search the docs for 'ShaderGUI'"); } UnityEngine.Object.DestroyImmediate(this.m_MaterialInspector); this.m_MaterialInspector = Editor.CreateEditor(selectedMaterial, typeof(ProceduralMaterialInspector)); } ProceduralMaterialInspector proceduralMaterialInspector = (ProceduralMaterialInspector)this.m_MaterialInspector; proceduralMaterialInspector.DisableReimportOnDisable(); } materialInspector = this.m_MaterialInspector; } return(materialInspector); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { base.OnPreviewGUI(r, background); if (base.target != null) { ProceduralMaterial proceduralMaterial = (base.target as ProceduralTexture).GetProceduralMaterial(); if (((proceduralMaterial != null) && ProceduralMaterialInspector.ShowIsGenerating(proceduralMaterial)) && (r.width > 50f)) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Generating..."); } } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { base.OnPreviewGUI(r, background); if (!(bool)this.target) { return; } ProceduralMaterial proceduralMaterial = (this.target as ProceduralTexture).GetProceduralMaterial(); if (!(bool)((Object)proceduralMaterial) || !ProceduralMaterialInspector.ShowIsGenerating(proceduralMaterial) || (double)r.width <= 50.0) { return; } EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Generating..."); }
public void OnDisable() { if (this.m_EditorCache != null) { this.m_EditorCache.Dispose(); } if (this.m_MaterialInspector != null) { ProceduralMaterialInspector proceduralMaterialInspector = (ProceduralMaterialInspector)this.m_MaterialInspector; proceduralMaterialInspector.ReimportSubstancesIfNeeded(); UnityEngine.Object.DestroyImmediate(this.m_MaterialInspector); } SubstanceImporterInspector.s_CachedSelectedMaterialInstanceName = this.m_SelectedMaterialInstanceName; if (this.m_PreviewUtility != null) { this.m_PreviewUtility.Cleanup(); this.m_PreviewUtility = null; } }