Example #1
0
    public override void OnGUI(MaterialEditor me, MaterialProperty[] props)
    {
        Material material = (Material)me.target;

        isTransparent = material.shader.name.Contains("(Transparent)");
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }

        EditorGUI.BeginChangeCheck(); {
            MGUI.BoldLabel("Image");
            MGUI.Space2();
            if (_FlipbookMode.floatValue == 0)
            {
                me.TexturePropertySingleLine(mainTex, _MainTex, _FlipbookMode);
                MGUI.TexPropLabel("Flipbook", 105);
                me.ShaderProperty(_Color, "Color");
                if (_MainTex.textureValue)
                {
                    MGUI.TextureSOScroll(me, _MainTex, _UVScroll);
                    MGUI.Space6();
                }
            }
            else
            {
                me.TexturePropertySingleLine(flipbookTex, _Flipbook, _FlipbookMode);
                MGUI.TexPropLabel("Flipbook", 105);
                if (_Flipbook.textureValue)
                {
                    MGUI.TextureSO(me, _MainTex);
                    MGUI.SpaceN2();
                    me.ShaderProperty(_FPS, "FPS");
                    MGUI.Space6();
                }
            }
            MGUI.SetKeyword(material, "_FLIPBOOK_MODE", material.GetInt("_FlipbookMode") == 1);
            me.TexturePropertySingleLine(smoothTex, _SpecGlossMap, _Glossiness);
            MGUI.TextureSO(me, _SpecGlossMap, _SpecGlossMap.textureValue);
            MGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            MGUI.Space4();

            MGUI.SetKeyword(material, "_EMISSION", true);
            me.ShaderProperty(_EmissionIntensity, "Emission Strength");
            me.ShaderProperty(_LightmapEmissionScale, "Lightmap Emission Strength");
            me.ShaderProperty(_BoostAmount, "Boost Multiplier");
            me.ShaderProperty(_BoostThreshold, "Boost Threshold");
            material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
            MGUI.Space4();

            MGUI.BoldLabel("Panel");
            MGUI.Space2();
            me.TexturePropertySingleLine(RGBMatrixTex, _RGBSubPixelTex);
            MGUI.TextureSO(me, _RGBSubPixelTex, _RGBSubPixelTex.textureValue);
            me.ShaderProperty(_Backlight, "Backlit");
            MGUI.Space4();
            MGUI.BoldLabel("Render Settings");
            if (isTransparent)
            {
                me.ShaderProperty(_ZWrite, "ZWrite");
            }
            me.RenderQueueField();
            MGUI.Space8();
        }

        MGUI.Space20();
        float buttonSize = 35f;
        Rect  footerRect = EditorGUILayout.GetControlRect();

        footerRect.x     += (MGUI.GetInspectorWidth() / 2f) - buttonSize - 5f;
        footerRect.width  = buttonSize;
        footerRect.height = buttonSize;
        if (GUI.Button(footerRect, MGUI.patIconTex))
        {
            Application.OpenURL("https://www.patreon.com/mochieshaders");
        }
        footerRect.x += buttonSize + 5f;
        footerRect.y += 17f;
        GUIStyle formatting = new GUIStyle();

        formatting.fontSize  = 15;
        formatting.fontStyle = FontStyle.Bold;
        if (EditorGUIUtility.isProSkin)
        {
            formatting.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 1);
            formatting.hover.textColor  = new Color(0.8f, 0.8f, 0.8f, 1);
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogoPro);
            GUILayout.Space(90);
        }
        else
        {
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogo);
            GUILayout.Space(90);
        }
    }