Пример #1
0
 public static void Refresh(bool delay, params UnityObject[] targets)
 {
     VariableMaterial.delay = delay;
     foreach (var target in targets)
     {
         var  material = (Material)target;
         bool isFlat   = material.shader != null && material.shader.name.Contains("#");
         if (isFlat || VariableMaterial.IsBroken(material))
         {
             VariableMaterial.Flatten(target);
         }
     }
 }
        override public void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
        {
            EditorUI.Reset();
            this.editor   = editor;
            this.material = (Material)editor.target;
            bool matching = this.shader == this.material.shader;

            if (!matching || VariableMaterial.dirty)
            {
                this.Reload();
            }
            if (this.shader != null)
            {
                EditorGUILayout.BeginHorizontal();
                string[] keywords  = this.material.shaderKeywords;
                bool     isHook    = this.shader.name.EndsWith("#");
                bool     isFlat    = this.shader.name.Contains("#") && !isHook;
                bool     isUpdated = !isFlat || this.shader.name.Split("#")[1].Split(".")[0] == this.hash;
                GUI.enabled = !this.parent.IsNull() && (isHook || this.parent.extension != "zshader");
                if (isFlat && "Unflatten".ToLabel().DrawButton())
                {
                    VariableMaterial.Unflatten(editor.targets);
                }
                if (!isFlat && "Flatten".ToLabel().DrawButton())
                {
                    VariableMaterial.Flatten(true, editor.targets);
                }
                GUI.enabled = Event.current.shift || !isUpdated;
                if ("Update".ToLabel().DrawButton())
                {
                    VariableMaterial.force = true;
                    var materials = editor.targets.Cast <Material>().ToList();
                    Events.AddStepper("On Editor Update", VariableMaterialEditor.RefreshStep, materials, 50);
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
                this.DrawProperties(editor, properties);
                //this.DrawSimpleProperties(editor,properties);
                //editor.PropertiesDefaultGUI(properties);
                if (GUI.changed)
                {
                    editor.serializedObject.ApplyModifiedProperties();
                    ProxyEditor.SetDirty(editor.serializedObject.targetObject, false, true);
                }
                if (isFlat && !keywords.SequenceEqual(this.material.shaderKeywords))
                {
                    VariableMaterial.Refresh(editor.target);
                }
            }
        }
Пример #3
0
 public static void Flatten(bool force, params UnityObject[] targets)
 {
     VariableMaterial.force = force;
     VariableMaterial.Flatten(targets);
 }