diff --git a/Editor/Shading/ShowIfMaterialPropertyDrawer.cs b/Editor/Shading/ShowIfDrawer.cs similarity index 73% rename from Editor/Shading/ShowIfMaterialPropertyDrawer.cs rename to Editor/Shading/ShowIfDrawer.cs index b73ed40..01b9382 100644 --- a/Editor/Shading/ShowIfMaterialPropertyDrawer.cs +++ b/Editor/Shading/ShowIfDrawer.cs @@ -19,7 +19,7 @@ namespace StansAssets.Foundation.Editor.Shading /// public class ShowIfDrawer : MaterialPropertyDrawer { - string[] m_RequiredKeywords; + readonly string[] m_RequiredKeywords; bool m_IsElementHidden; /// @@ -28,7 +28,7 @@ public class ShowIfDrawer : MaterialPropertyDrawer public ShowIfDrawer( string keyword0) { - m_RequiredKeywords = new string[] {keyword0}; + m_RequiredKeywords = new[] {keyword0}; } /// @@ -38,7 +38,7 @@ public ShowIfDrawer( string keyword0, string keyword1) { - m_RequiredKeywords = new string[] {keyword0, keyword1}; + m_RequiredKeywords = new[] {keyword0, keyword1}; } /// @@ -49,7 +49,7 @@ public ShowIfDrawer( string keyword1, string keyword2) { - m_RequiredKeywords = new string[] {keyword0, keyword1, keyword2}; + m_RequiredKeywords = new[] {keyword0, keyword1, keyword2}; } /// @@ -61,7 +61,7 @@ public ShowIfDrawer( string keyword2, string keyword3) { - m_RequiredKeywords = new string[] {keyword0, keyword1, keyword2, keyword3}; + m_RequiredKeywords = new[] {keyword0, keyword1, keyword2, keyword3}; } public override void OnGUI( @@ -72,15 +72,15 @@ public override void OnGUI( { m_IsElementHidden = false; - for (int i = 0; i < editor.targets.Length; ++i) + foreach (var target in editor.targets) { - Material mat = editor.targets[i] as Material; + var mat = target as Material; if (mat != null) { - for (int j = 0; j < m_RequiredKeywords.Length; ++j) + foreach (var keyword in m_RequiredKeywords) { - if (!mat.IsKeywordEnabled(m_RequiredKeywords[j])) + if (!mat.IsKeywordEnabled(keyword)) { m_IsElementHidden = true; break; @@ -95,6 +95,13 @@ public override void OnGUI( } } + /// + /// Will always return 0 + /// + /// The to make the custom GUI for. + /// The label of this property. + /// Current material editor. + /// Property height in pixels public override float GetPropertyHeight ( MaterialProperty prop, string label, diff --git a/Editor/Shading/ShowIfMaterialPropertyDrawer.cs.meta b/Editor/Shading/ShowIfDrawer.cs.meta similarity index 100% rename from Editor/Shading/ShowIfMaterialPropertyDrawer.cs.meta rename to Editor/Shading/ShowIfDrawer.cs.meta