Esempio n. 1
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        MatEditor = materialEditor;
        m_isValid = true;

        if (!m_inited)
        {
            AlloySceneDrawer.Register(this, MatEditor);
            OnEnable(properties);
        }

        if (!m_isValid)
        {
            EditorGUILayout.LabelField("There's a problem with the inspector. Reselect the material to fix");
            EditorApplication.delayCall += () => MatEditor.Repaint();
            return;
        }

        if (HasMutlipleShaders())
        {
            EditorGUILayout.HelpBox("Can't edit materials with different shaders!", MessageType.Warning);
            return;
        }

        GUILayout.Space(10.0f);
        if (MatEditor.isVisible)
        {
            OnAlloyShaderGUI(properties);
        }

        m_inited = true;
    }
Esempio n. 2
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        MatEditor = materialEditor;
        IsValid   = true;

        if (!m_inited)
        {
            AlloySceneDrawer.Register(this, MatEditor);
            OnEnable();
        }

        if (!IsValid)
        {
            EditorGUILayout.LabelField("There's a problem with the inspector. Reselect the material to fix");
            EditorApplication.delayCall += () => MatEditor.Repaint();
            return;
        }

        if (Target != null)
        {
            var ns = Target.shader;

            if (ns != m_oldShader)
            {
                EditorApplication.delayCall += OnEnable;
                MatEditor.Repaint();

                return;
            }
        }

        OnInspectorGUI();

        if (GUI.changed)
        {
            MaterialEditor.ApplyMaterialPropertyDrawers(Targets);
        }

        m_inited = true;
    }