public static void RefreshStep(object collection, int index)
        {
            var materials = (List <Material>)collection;

            Stepper.title   = "Updating " + materials.Count + " Materials";
            Stepper.message = "Updating material : " + materials[index].name;
            VariableMaterial.Refresh(true, materials[index]);
        }
        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);
                }
            }
        }
 public static void Refresh(params UnityObject[] targets)
 {
     VariableMaterial.Refresh(false, targets);
 }