Пример #1
0
    void ListKeywords(Material mat, GUIContent label, float buttonSize)
    {
        keywordsList.Clear();
        foreach (string s in mat.shaderKeywords)
        {
            keywordsList.Add(s);
        }

        if (MGUI.LinkButton(label, buttonSize, buttonSize, (MGUI.GetInspectorWidth() / 2.0f) - 11.0f))
        {
            displayKeywords = !displayKeywords;
        }

        if (displayKeywords)
        {
            MGUI.Space8();
            string infoString = "";
            if (keywordsList.Capacity == 0)
            {
                infoString = "NO KEYWORDS FOUND";
            }
            else
            {
                infoString = "\nKeywords Used:\n\n";
                foreach (string s in keywordsList)
                {
                    infoString += " " + s + "\n";
                }
            }
            MGUI.DisplayText(infoString);
            MGUI.SpaceN8();
        }
        GUILayout.Space(buttonSize - 10);
    }
 void DoVariantArea()
 {
     MGUI.PropertyGroup(() => {
         me.ShaderProperty(workflow, Tips.standWorkflow);
         me.ShaderProperty(blendMode, Tips.standBlendMode);
         me.ShaderProperty(samplingMode, Tips.samplingMode);
         if (blendMode.floatValue > 0)
         {
             me.ShaderProperty(useAlphaMask, Tips.separateAlpha);
         }
         if (samplingMode.floatValue == 3)
         {
             me.ShaderProperty(triplanarFalloff, Tips.triplanarFalloff);
         }
         if (samplingMode.floatValue == 4)
         {
             me.ShaderProperty(edgeFadeMin, "Edge Fade Min");
             me.ShaderProperty(edgeFadeMax, "Edge Fade Max");
         }
         if (blendMode.floatValue == 1)
         {
             me.ShaderProperty(alphaCutoff, Tips.alphaCutoffText);
         }
         me.ShaderProperty(useSmoothness, Tips.useSmoothness);
         if (workflow.floatValue > 0 && samplingMode.floatValue < 3)
         {
             me.ShaderProperty(useHeight, Tips.useHeight);
         }
     });
 }
 void DoSubsurfaceArea()
 {
     MGUI.PropertyGroup(() => {
         me.ShaderProperty(subsurface, "Enable");
         MGUI.ToggleGroup(subsurface.floatValue == 0);
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.TexturePropertySingleLine(Tips.thicknessMapText, thicknessMap, thicknessMap.textureValue ? thicknessMapPower : null);
             if (thicknessMap.textureValue)
             {
                 MGUI.TexPropLabel("Power", 94);
             }
             me.ShaderProperty(scatterCol, Tips.scatterCol);
             me.ShaderProperty(scatterAlbedoTint, Tips.scatterAlbedoTint);
             MGUI.Space8();
             me.ShaderProperty(scatterIntensity, Tips.scatterIntensity);
             me.ShaderProperty(scatterAmbient, Tips.scatterAmbient);
             me.ShaderProperty(scatterPow, Tips.scatterPow);
             me.ShaderProperty(scatterDist, Tips.scatterDist);
             me.ShaderProperty(wrappingFactor, Tips.wrappingFactor);
             MGUI.SpaceN2();
         });
         MGUI.ToggleGroupEnd();
     });
 }
    static void SetMaterialKeywords(Material material)
    {
        // Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
        // (MaterialProperty value might come from renderer material property block)
        int workflow      = material.GetInt("_Workflow");
        int samplingMode  = material.GetInt("_SamplingMode");
        int blendModeEnum = material.GetInt("_BlendMode");

        MGUI.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
        MGUI.SetKeyword(material, "_WORKFLOW_PACKED_ON", workflow == 1);
        MGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
        MGUI.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
        MGUI.SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap"));
        MGUI.SetKeyword(material, "_REFLECTION_FALLBACK_ON", material.GetTexture("_ReflCube"));
        MGUI.SetKeyword(material, "_REFLECTION_OVERRIDE_ON", material.GetTexture("_ReflCubeOverride"));
        MGUI.SetKeyword(material, "_SCREENSPACE_REFLECTIONS_ON", material.GetInt("_SSR") == 1);
        MGUI.SetKeyword(material, "_SPECULARHIGHLIGHTS_OFF", material.GetInt("_SpecularHighlights") == 0);
        MGUI.SetKeyword(material, "_GLOSSYREFLECTIONS_OFF", material.GetInt("_GlossyReflections") == 0);
        MGUI.SetKeyword(material, "_STOCHASTIC_ON", samplingMode == 1);
        MGUI.SetKeyword(material, "_TSS_ON", samplingMode == 2);
        MGUI.SetKeyword(material, "_TRIPLANAR_ON", samplingMode == 3);
        MGUI.SetKeyword(material, "_DECAL_ON", samplingMode == 4);
        MGUI.SetKeyword(material, "_DETAIL_ROUGH_ON", material.GetTexture("_DetailRoughnessMap"));
        MGUI.SetKeyword(material, "_DETAIL_AO_ON", material.GetTexture("_DetailAOMap"));
        MGUI.SetKeyword(material, "_SUBSURFACE_ON", material.GetInt("_Subsurface") == 1);
        MGUI.SetKeyword(material, "_AUDIOLINK_ON", material.GetInt("_AudioLinkEmission") > 0);
        MGUI.SetKeyword(material, "_DETAIL_SAMPLEMODE_ON", material.GetInt("_DetailSamplingMode") == 1);
        MGUI.SetKeyword(material, "_ALPHAMASK_ON", blendModeEnum > 0 && material.GetInt("_UseAlphaMask") == 1);
        MGUI.SetKeyword(material, "_BICUBIC_SAMPLING_ON", material.GetInt("_BicubicLightmap") == 1);
        MGUI.SetKeyword(material, "BAKERY_SH", material.GetInt("_BakeryMode") == 1);
        MGUI.SetKeyword(material, "BAKERY_RNM", material.GetInt("_BakeryMode") == 2);
        MGUI.SetKeyword(material, "_FILTERING_ON", material.GetInt("_Filtering") == 1);

        if (samplingMode < 3)
        {
            if (!material.GetTexture("_PackedMap"))
            {
                MGUI.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            }
            else
            {
                MGUI.SetKeyword(material, "_PARALLAXMAP", material.GetInt("_UseHeight") == 1);
            }
        }
        else
        {
            MGUI.SetKeyword(material, "_PARALLAXMAP", false);
        }

        // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect
        // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color.
        // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color.
        MaterialEditor.FixupEmissiveFlag(material);
        bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0;

        MGUI.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);

        material.SetShaderPassEnabled("Always", material.GetInt("_SSR") == 1);
    }
Пример #5
0
 void OnGUI()
 {
     //GUI.Box(new Rect(0, 0, Screen.width, Screen.height), Background);
     GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Background);
     if (MGUI.HoveredButton(new Rect(MGUI.Margin, Screen.height - MGUI.menuButtonWidth - MGUI.Margin, MGUI.menuButtonWidth, MGUI.menuButtonWidth), MainMenuButton))
     {
         Application.LoadLevel("MainMenu");
     }
     if (MGUI.HoveredButton(new Rect(Screen.width - MGUI.menuButtonWidth - MGUI.Margin, Screen.height - MGUI.menuButtonWidth - MGUI.Margin, MGUI.menuButtonWidth, MGUI.menuButtonWidth), PlayButton))
     {
         StartCoroutine(WaitForEndOfMusic());
     }
 }
 void DoDetailArea()
 {
     MGUI.BoldLabel("Detail Textures");
     MGUI.PropertyGroup(() => {
         me.TexturePropertySingleLine(Tips.detailAlbedoText, detailAlbedoMap, detailAlbedoMap.textureValue ? detailAlbedoBlend : null);
         me.TexturePropertySingleLine(Tips.detailNormalMapText, detailNormalMap, detailNormalMap.textureValue ? detailNormalMapScale : null);
         me.TexturePropertySingleLine(Tips.detailRoughnessMapText, detailRoughnessMap, detailRoughnessMap.textureValue ? detailRoughBlend : null);
         MGUI.sRGBWarning(detailRoughnessMap);
         me.TexturePropertySingleLine(Tips.detailAOMapText, detailAOMap, detailAOMap.textureValue ? detailAOBlend : null);
         MGUI.sRGBWarning(detailAOMap);
         MGUI.SpaceN2();
     });
 }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        selectedGameName = "";


        currentLevel          = 1;
        gamesNumber           = gameList.Length;
        buttonBarHeight       = barHeightToScreenHeightRatio * Screen.height;
        gameSelectionTextures = new Texture[gamesNumber];
        previewTextures       = new Texture[gamesNumber];
        playButtonsTextures   = new Texture[gamesNumber];
        gameSelectionRects    = new Rect[gamesNumber];

        float buttonWidth = (Screen.width - MGUI.Margin * (gamesNumber + 1)) / gamesNumber;

        for (int i = 0; i < gamesNumber; i++)
        {
            gameSelectionTextures[i] = (Texture)Resources.Load("MainMenu/Buttons/" + gameList[i]);
            previewTextures[i]       = (Texture)Resources.Load("MainMenu/Previews/" + gameList[i]);
            playButtonsTextures[i]   = (Texture)Resources.Load("MenuCommon/play_" + gameList[i]);


            float buttonHeight = buttonWidth * gameSelectionTextures[i].height / gameSelectionTextures[i].width;
            gameSelectionRects[i] = new Rect(i * (buttonWidth) + (i + 1) * MGUI.Margin, centerPosition(buttonHeight, buttonBarHeight), buttonWidth, buttonHeight);
        }

        soundON         = (Texture)Resources.Load("MainMenu/Buttons/soundon");
        soundOff        = (Texture)Resources.Load("MainMenu/Buttons/soundoff");
        options         = (Texture)Resources.Load("MainMenu/Buttons/options_credits_btn");
        credits         = (Texture)Resources.Load("MainMenu/Buttons/roll_credits_btn");
        gameExitTexture = (Texture)Resources.Load("MainMenu/Buttons/button_exit");

        float titleHeight = Screen.height - buttonBarHeight - MGUI.Margin;
        float titleWidth  = titleHeight * gameTitleTexture.width / gameTitleTexture.width;

        gameTitleRect = new Rect(centerPosition(titleWidth, Screen.width), Screen.height - titleHeight, titleWidth, titleHeight);

        quitRect = new Rect(MGUI.Margin, Screen.height - MGUI.Margin - MGUI.menuButtonWidth, MGUI.menuButtonWidth, MGUI.menuButtonWidth);

        creditsRect = new Rect(Screen.width - MGUI.Margin - MGUI.menuButtonWidth, Screen.height - MGUI.Margin - MGUI.menuButtonWidth, MGUI.menuButtonWidth, MGUI.menuButtonWidth);

        float previewRatio  = (float)previewTextures[0].width / previewTextures[0].height;
        float previewWidth  = Screen.width * gamePreviewWidthToScreenWidthRatio;
        float previewHeight = Mathf.Min(previewWidth / previewRatio, Screen.height - buttonBarHeight - 2 * MGUI.Margin);

        gamePreviewRect   = new Rect(centerPosition(previewWidth, Screen.width), buttonBarHeight + MGUI.Margin, previewWidth, previewHeight);
        soundButtonRect   = MGUI.centerInRect(new Rect(Screen.width / 7, gamePreviewArrowHeightRation * gamePreviewRect.height, MGUI.menuButtonWidth, MGUI.menuButtonWidth), gamePreviewRect);
        creditsButtonRect = MGUI.centerInRect(new Rect(Screen.width / 9 - Screen.width / 4, gamePreviewArrowHeightRation * gamePreviewRect.height, MGUI.menuButtonWidth, MGUI.menuButtonWidth), gamePreviewRect);
        //TODO make centerRect method
        gamePreviewButtonRect = MGUI.centerInRect(new Rect(0, gamePreviewArrowHeightRation * gamePreviewRect.height, MGUI.menuButtonWidth, MGUI.menuButtonWidth), gamePreviewRect);        // new Rect(centerPosition(), centerPosition(), Screen.width/7, Screen.width/7);
    }
 void DoFilteringArea()
 {
     MGUI.PropertyGroup(() => {
         me.ShaderProperty(filtering, "Enable");
         MGUI.ToggleGroup(filtering.floatValue == 0);
         MGUI.BoldLabel("Base Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(hue, "Hue");
             me.ShaderProperty(saturation, "Saturation");
             me.ShaderProperty(brightness, "Brightness");
             me.ShaderProperty(contrast, "Contrast");
             MGUI.SpaceN2();
         });
         MGUI.Space4();
         MGUI.BoldLabel("Detail Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(hueDet, "Hue");
             me.ShaderProperty(saturationDet, "Saturation");
             me.ShaderProperty(brightnessDet, "Brightness");
             me.ShaderProperty(contrastDet, "Contrast");
             MGUI.SpaceN2();
         });
         if (emissionEnabled)
         {
             MGUI.Space4();
             MGUI.BoldLabel("Emission Color");
             MGUI.PropertyGroupLayer(() => {
                 MGUI.SpaceN1();
                 me.ShaderProperty(hueEmiss, "Hue");
                 me.ShaderProperty(saturationEmiss, "Saturation");
                 me.ShaderProperty(brightnessEmiss, "Brightness");
                 me.ShaderProperty(contrastEmiss, "Contrast");
                 MGUI.SpaceN2();
             });
         }
         MGUI.Space4();
         MGUI.BoldLabel("Global Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(huePost, "Hue");
             me.ShaderProperty(saturationPost, "Saturation");
             me.ShaderProperty(brightnessPost, "Brightness");
             me.ShaderProperty(contrastPost, "Contrast");
             MGUI.SpaceN2();
         });
         MGUI.ToggleGroupEnd();
     });
 }
 void DoRimArea()
 {
     MGUI.PropertyGroup(() => {
         me.ShaderProperty(rimTog, "Enable");
         MGUI.ToggleGroup(rimTog.floatValue == 0);
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN2();
             me.ShaderProperty(rimBlend, Tips.rimBlend);
             me.ShaderProperty(rimCol, Tips.rimCol);
             me.ShaderProperty(rimStr, Tips.rimStr);
             me.ShaderProperty(rimWidth, Tips.rimWidth);
             me.ShaderProperty(rimEdge, Tips.rimEdge);
             MGUI.SpaceN2();
         });
         MGUI.ToggleGroupEnd();
     });
 }
    void ApplyMaterialSettings(Material mat)
    {
        bool ssrToggle        = mat.GetInt("_SSR") == 1;
        int  vertMode         = mat.GetInt("_VertOffsetMode");
        int  reflMode         = mat.GetInt("_Reflections");
        int  specMode         = mat.GetInt("_Specular");
        int  foamToggle       = mat.GetInt("_FoamToggle");
        int  foamNormalToggle = mat.GetInt("_FoamNormalToggle");
        bool foamNormals      = foamToggle == 1 && foamNormalToggle == 1;

        MGUI.SetKeyword(mat, "_REFLECTIONS_ON", reflMode > 0);
        MGUI.SetKeyword(mat, "_REFLECTIONS_MANUAL_ON", reflMode == 2);
        MGUI.SetKeyword(mat, "_SPECULAR_ON", specMode > 0);
        MGUI.SetKeyword(mat, "_SCREENSPACE_REFLECTIONS_ON", ssrToggle);
        MGUI.SetKeyword(mat, "_VERTEX_OFFSET_ON", vertMode == 1);
        MGUI.SetKeyword(mat, "_GERSTNER_WAVES_ON", vertMode == 2);
        MGUI.SetKeyword(mat, "_FOAM_NORMALS_ON", foamNormals);
    }
    void DoFooter()
    {
        GUILayout.Space(20);
        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);
        }
    }
 void DoEmissionArea(Material material)
 {
     if (me.EmissionEnabledProperty())
     {
         emissionEnabled = true;
         bool hadEmissionTexture = emissionMap.textureValue != null;
         MGUI.ToggleGroup(!emissionEnabled);
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN2();
             me.LightmapEmissionFlagsProperty(0, true);
             me.ShaderProperty(audioLinkEmission, Tips.audioLinkEmission);
             me.ShaderProperty(emissPulseWave, Tips.emissPulseWave);
             if (audioLinkEmission.floatValue > 0)
             {
                 me.ShaderProperty(audioLinkEmissionStrength, Tips.audioLinkEmissionStrength);
             }
             if (emissPulseWave.floatValue > 0)
             {
                 me.ShaderProperty(emissPulseStrength, Tips.emissPulseStrength);
                 me.ShaderProperty(emissPulseSpeed, Tips.emissPulseSpeed);
             }
             MGUI.Space2();
             me.TexturePropertySingleLine(Tips.emissionText, emissionMap, emissionColorForRendering, emissIntensity);
             MGUI.TexPropLabel("Intensity", 105);
             MGUI.SpaceN2();
             me.TexturePropertySingleLine(Tips.maskText, emissionMask);
             MGUI.SpaceN4();
         });
         MGUI.ToggleGroupEnd();
         float brightness = emissionColorForRendering.colorValue.maxColorComponent;
         if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f)
         {
             emissionColorForRendering.colorValue = Color.white;
         }
     }
     else
     {
         emissionEnabled = false;
     }
 }
Пример #13
0
    void ApplyMaterialSettings(Material mat)
    {
        bool softening  = mat.GetInt("_Softening") == 1;
        bool distortion = mat.GetInt("_Distortion") == 1;
        bool distortUV  = mat.GetInt("_DistortMainTex") == 1 && distortion;
        bool layering   = mat.GetTexture("_SecondTex");
        bool pulse      = mat.GetInt("_Pulse") == 1;
        bool falloff    = mat.GetInt("_Falloff") == 1;
        bool flipbook   = mat.GetInt("_FlipbookBlending") == 1;
        bool cutout     = mat.GetInt("_IsCutout") == 1;
        bool filtering  = mat.GetInt("_Filtering") == 1;

        MGUI.SetKeyword(mat, "_ALPHATEST_ON", cutout);
        MGUI.SetKeyword(mat, "_FADING_ON", softening);
        MGUI.SetKeyword(mat, "_DISTORTION_ON", distortion);
        MGUI.SetKeyword(mat, "_DISTORTION_UV_ON", distortUV);
        MGUI.SetKeyword(mat, "_LAYERED_TEX_ON", layering);
        MGUI.SetKeyword(mat, "_PULSE_ON", pulse);
        MGUI.SetKeyword(mat, "_FALLOFF_ON", falloff);
        MGUI.SetKeyword(mat, "_FLIPBOOK_BLENDING_ON", flipbook);
        MGUI.SetKeyword(mat, "_FILTERING_ON", filtering);
        mat.SetShaderPassEnabled("Always", distortion);
        SetBlendMode(mat);
    }
 public override void AssignNewShaderToMaterial(Material mat, Shader oldShader, Shader newShader)
 {
     base.AssignNewShaderToMaterial(mat, oldShader, newShader);
     MGUI.ClearKeywords(mat);
 }
    public override void OnGUI(MaterialEditor me, MaterialProperty[] props)
    {
        if (!me.isVisible)
        {
            return;
        }

        ClearDictionaries();

        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }
        Material mat = (Material)me.target;

        if (m_FirstTimeApply)
        {
            m_FirstTimeApply = false;
        }

        header = "WaterHeader_Pro";
        if (!EditorGUIUtility.isProSkin)
        {
            header = "WaterHeader";
        }

        Texture2D headerTex    = (Texture2D)Resources.Load(header, typeof(Texture2D));
        Texture2D collapseIcon = (Texture2D)Resources.Load("CollapseIcon", typeof(Texture2D));

        GUILayout.Label(headerTex);
        MGUI.Space4();

        if (!foldouts.ContainsKey(mat))
        {
            foldouts.Add(mat, toggles);
        }

        EditorGUI.BeginChangeCheck(); {
            // Surface
            baseTabButtons.Add(() => { Toggles.CollapseFoldouts(mat, foldouts, 1); }, MGUI.collapseLabel);
            baseTabButtons.Add(() => { ResetSurface(); }, MGUI.resetLabel);
            Action surfaceTabAction = () => {
                MGUI.PropertyGroup(() => {
                    me.RenderQueueField();
                    me.ShaderProperty(_CullMode, "Culling Mode");
                    me.ShaderProperty(_ZWrite, "ZWrite");
                    me.ShaderProperty(_Opacity, "Opacity");
                    me.ShaderProperty(_DistortionStrength, "Distortion Strength");
                    MGUI.Space2();
                });
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(texLabel, _MainTex, _Color, _BaseColorStochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    MGUI.TextureSOScroll(me, _MainTex, _MainTexScroll);
                    me.ShaderProperty(_BaseColorOffset, Tips.parallaxOffsetLabel);
                    me.ShaderProperty(_BaseColorDistortionStrength, "Distortion Strength");
                });
                MGUI.DisplayInfo("   This shader requires a \"Depth Light\" prefab be present in the scene.\n   (Found in: Assets/Mochie/Unity/Prefabs)");
            };
            Foldouts.Foldout("BASE", foldouts, baseTabButtons, mat, me, surfaceTabAction);

            // Primary Normal
            norm0TabButtons.Add(() => { ResetPrimaryNormal(); }, MGUI.resetLabel);
            Action norm0TabAction = () => {
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap0, _Normal0StochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    me.ShaderProperty(_NormalStr0, "Strength");
                    MGUI.Vector2Field(_NormalMapScale0, "Scale");
                    MGUI.Vector2Field(_NormalMapScroll0, "Scrolling");
                    me.ShaderProperty(_Rotation0, "Rotation");
                    me.ShaderProperty(_NormalMapOffset0, Tips.parallaxOffsetLabel);
                });
            };
            Foldouts.Foldout("PRIMARY NORMAL", foldouts, norm0TabButtons, mat, me, norm0TabAction);

            // Secondary Normal
            norm1TabButtons.Add(() => { ResetSecondaryNormal(); }, MGUI.resetLabel);
            Action norm1TabAction = () => {
                me.ShaderProperty(_Normal1Toggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Normal1Toggle.floatValue == 0);
                    me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap1, _Normal1StochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    me.ShaderProperty(_NormalStr1, "Strength");
                    MGUI.Vector2Field(_NormalMapScale1, "Scale");
                    MGUI.Vector2Field(_NormalMapScroll1, "Scrolling");
                    me.ShaderProperty(_Rotation1, "Rotation");
                    me.ShaderProperty(_NormalMapOffset1, Tips.parallaxOffsetLabel);
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("SECONDARY NORMAL", foldouts, norm1TabButtons, mat, me, norm1TabAction);

            // Reflections & Specular
            reflSpecTabButtons.Add(() => { ResetReflSpec(); }, MGUI.resetLabel);
            Action reflSpecTabAction = () => {
                MGUI.Space4();
                me.ShaderProperty(_Roughness, Tips.waterRoughness);
                me.ShaderProperty(_Metallic, Tips.waterMetallic);
                MGUI.Space8();
                me.ShaderProperty(_Reflections, "Reflections");
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Reflections.floatValue == 0);
                    if (_Reflections.floatValue == 2)
                    {
                        me.TexturePropertySingleLine(cubeLabel, _ReflCube);
                        MGUI.Vector3Field(_ReflCubeRotation, "Rotation", false);
                    }
                    me.ShaderProperty(_ReflStrength, "Strength");

                    MGUI.ToggleFloat(me, "Screenspace Reflections", _SSR, _SSRStrength);
                    if (_SSR.floatValue > 0)
                    {
                        me.ShaderProperty(_EdgeFadeSSR, "Edge Fade");
                    }
                    me.ShaderProperty(_ReflTint, "Tint");
                    MGUI.ToggleGroupEnd();
                });
                MGUI.Space8();
                me.ShaderProperty(_Specular, "Specular");
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Specular.floatValue == 0);
                    if (_Specular.floatValue == 2)
                    {
                        MGUI.Vector3Field(_LightDir, "Light Direction", false);
                    }
                    me.ShaderProperty(_SpecStrength, "Strength");
                    me.ShaderProperty(_SpecTint, "Tint");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("REFLECTIONS & SPECULAR", foldouts, reflSpecTabButtons, mat, me, reflSpecTabAction);

            // Flow Mapping
            flowTabButtons.Add(() => { ResetFlowMapping(); }, MGUI.resetLabel);
            Action flowTabAction = () => {
                me.ShaderProperty(_FlowToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_FlowToggle.floatValue == 0);
                    me.TexturePropertySingleLine(flowLabel, _FlowMap);
                    MGUI.Vector2Field(_FlowMapScale, "Scale");
                    me.ShaderProperty(_FlowSpeed, "Speed");
                    me.ShaderProperty(_FlowStrength, "Strength");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("FLOW MAPPING", foldouts, flowTabButtons, mat, me, flowTabAction);

            // Vertex Offset
            vertTabButtons.Add(() => { ResetVertOffset(); }, MGUI.resetLabel);
            Action vertTabAction = () => {
                me.ShaderProperty(_VertOffsetMode, "Mode");
                MGUI.Space4();
                MGUI.ToggleGroup(_VertOffsetMode.floatValue == 0);
                if (_VertOffsetMode.floatValue == 1)
                {
                    MGUI.PropertyGroup(() => {
                        me.TexturePropertySingleLine(noiseLabel, _NoiseTex);
                        me.ShaderProperty(_NoiseTexBlur, "Blur");
                        MGUI.Vector2Field(_NoiseTexScale, "Scale");
                        MGUI.Vector2Field(_NoiseTexScroll, "Scrolling");
                    });
                    MGUI.PropertyGroup(() => {
                        MGUI.Vector3Field(_Offset, "Strength", false);
                        me.ShaderProperty(_WaveHeight, "Strength Multiplier");
                        MGUI.SliderMinMax(_VertRemapMin, _VertRemapMax, -1f, 1f, "Remap", 1);
                    });
                }
                else if (_VertOffsetMode.floatValue == 2)
                {
                    MGUI.BoldLabel("Global");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrengthGlobal, "Strength");
                        me.ShaderProperty(_WaveScaleGlobal, "Scale");
                        me.ShaderProperty(_WaveSpeedGlobal, "Speed");
                    });
                    MGUI.BoldLabel("Wave 1");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength0, "Strength");
                        me.ShaderProperty(_WaveScale0, "Scale");
                        me.ShaderProperty(_WaveSpeed0, "Speed");
                        me.ShaderProperty(_WaveDirection0, "Direction");
                    });
                    MGUI.BoldLabel("Wave 2");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength1, "Strength");
                        me.ShaderProperty(_WaveScale1, "Scale");
                        me.ShaderProperty(_WaveSpeed1, "Speed");
                        me.ShaderProperty(_WaveDirection1, "Direction");
                    });
                    MGUI.BoldLabel("Wave 3");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength2, "Strength");
                        me.ShaderProperty(_WaveScale2, "Scale");
                        me.ShaderProperty(_WaveSpeed2, "Speed");
                        me.ShaderProperty(_WaveDirection2, "Direction");
                    });
                    MGUI.BoldLabel("Turbulence");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_Turbulence, Tips.turbulence);
                        me.ShaderProperty(_TurbulenceSpeed, "Speed");
                        me.ShaderProperty(_TurbulenceScale, "Scale");
                    });
                }
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("VERTEX OFFSET", foldouts, vertTabButtons, mat, me, vertTabAction);

            // Caustics
            causticsTabButtons.Add(() => { ResetCaustics(); }, MGUI.resetLabel);
            Action causticsTabAction = () => {
                me.ShaderProperty(_CausticsToggle, "Enable");
                MGUI.ToggleGroup(_CausticsToggle.floatValue == 0);
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_CausticsOpacity, "Strength");
                    me.ShaderProperty(_CausticsDisp, "Phase");
                    me.ShaderProperty(_CausticsSpeed, "Speed");
                    me.ShaderProperty(_CausticsScale, "Scale");
                    me.ShaderProperty(_CausticsFade, Tips.causticsFade);
                    MGUI.Vector3Field(_CausticsRotation, "Rotation", false);
                });
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_CausticsDistortion, "Distortion Strength");
                    me.ShaderProperty(_CausticsDistortionScale, "Distortion Scale");
                    MGUI.Vector2Field(_CausticsDistortionSpeed, "Distortion Speed");
                });
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("CAUSTICS", foldouts, causticsTabButtons, mat, me, causticsTabAction);

            // Foam
            foamTabButtons.Add(() => { ResetFoam(); }, MGUI.resetLabel);
            Action foamTabAction = () => {
                me.ShaderProperty(_FoamToggle, "Enable");
                MGUI.Space4();
                MGUI.ToggleGroup(_FoamToggle.floatValue == 0);
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(foamLabel, _FoamTex, _FoamColor, _FoamStochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    MGUI.Space2();
                    MGUI.Vector2Field(_FoamTexScale, "Scale");
                    MGUI.Vector2Field(_FoamTexScroll, "Scrolling");
                    me.ShaderProperty(_FoamOffset, Tips.parallaxOffsetLabel);
                    me.ShaderProperty(_FoamDistortionStrength, "Distortion Strength");
                    MGUI.ToggleFloat(me, Tips.foamNormal, _FoamNormalToggle, _FoamNormalStrength);
                });
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(noiseLabel, _FoamNoiseTex);
                    MGUI.Vector2Field(_FoamNoiseTexScale, "Scale");
                    MGUI.Vector2Field(_FoamNoiseTexScroll, "Scrolling");
                    me.ShaderProperty(_FoamNoiseTexStrength, Tips.foamNoiseTexStrength);
                    me.ShaderProperty(_FoamNoiseTexCrestStrength, Tips.foamNoiseTexCrestStrength);
                });
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_FoamRoughness, Tips.foamRoughness);
                    me.ShaderProperty(_FoamPower, Tips.foamPower);
                    me.ShaderProperty(_FoamOpacity, Tips.foamOpacity);
                    me.ShaderProperty(_FoamCrestStrength, Tips.foamCrestStrength);
                    me.ShaderProperty(_FoamCrestThreshold, Tips.foamCrestThreshold);
                });
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("FOAM", foldouts, foamTabButtons, mat, me, foamTabAction);

            // Depth Fog
            fogTabButtons.Add(() => { ResetFog(); }, MGUI.resetLabel);
            Action fogTabAction = () => {
                me.ShaderProperty(_FogToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_FogToggle.floatValue == 0);
                    me.ShaderProperty(_FogTint, "Color");
                    me.ShaderProperty(_FogPower, "Power");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("DEPTH FOG", foldouts, fogTabButtons, mat, me, fogTabAction);

            // Edge Fade
            edgeFadeTabButtons.Add(() => { ResetEdgeFade(); }, MGUI.resetLabel);
            Action edgeFadeTabAction = () => {
                me.ShaderProperty(_EdgeFadeToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_EdgeFadeToggle.floatValue == 0);
                    me.ShaderProperty(_EdgeFadePower, "Power");
                    me.ShaderProperty(_EdgeFadeOffset, "Offset");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("EDGE FADE", foldouts, edgeFadeTabButtons, mat, me, edgeFadeTabAction);

            // Rain
            rainTabButtons.Add(() => { ResetRain(); }, MGUI.resetLabel);
            Action rainTabAction = () => {
                me.ShaderProperty(_RainToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_RainToggle.floatValue == 0);
                    me.ShaderProperty(_RippleStr, "Strength");
                    me.ShaderProperty(_RippleSpeed, "Speed");
                    me.ShaderProperty(_RippleScale, "Scale");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("RAIN", foldouts, rainTabButtons, mat, me, rainTabAction);
        }
        ApplyMaterialSettings(mat);

        GUILayout.Space(20);
        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);
        }
    }
Пример #16
0
    public override void OnGUI(MaterialEditor me, MaterialProperty[] props)
    {
        if (!me.isVisible)
        {
            return;
        }

        ClearDictionaries();

        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }
        if (_DstBlend.floatValue == 0)
        {
            _DstBlend.floatValue = 10;
        }
        Material mat = (Material)me.target;

        if (m_FirstTimeApply)
        {
            CacheRenderersUsingThisMaterial(mat);
            m_FirstTimeApply = false;
        }

        header = "ParticleHeader_Pro";
        if (!EditorGUIUtility.isProSkin)
        {
            header = "ParticleHeader";
        }

        Texture2D headerTex    = (Texture2D)Resources.Load(header, typeof(Texture2D));
        Texture2D collapseIcon = (Texture2D)Resources.Load("CollapseIcon", typeof(Texture2D));

        GUILayout.Label(headerTex);
        MGUI.Space4();

        List <ParticleSystemVertexStream> streams = new List <ParticleSystemVertexStream>();

        streams.Add(ParticleSystemVertexStream.Position);
        streams.Add(ParticleSystemVertexStream.UV);
        streams.Add(ParticleSystemVertexStream.AnimBlend);
        streams.Add(ParticleSystemVertexStream.Custom1X);
        streams.Add(ParticleSystemVertexStream.Center);
        streams.Add(ParticleSystemVertexStream.Color);

        string warnings = "";
        List <ParticleSystemVertexStream> rendererStreams = new List <ParticleSystemVertexStream>();

        foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial)
        {
            if (renderer != null)
            {
                renderer.GetActiveVertexStreams(rendererStreams);
                bool streamsValid = rendererStreams.SequenceEqual(streams);
                if (!streamsValid)
                {
                    warnings += "  " + renderer.name + "\n";
                }
            }
        }

        EditorGUI.BeginChangeCheck(); {
            foreach (var obj in _BlendMode.targets)
            {
                ApplyMaterialSettings((Material)obj);
            }

            if (!foldouts.ContainsKey(mat))
            {
                foldouts.Add(mat, toggles);
            }

            // -----------------
            // Render Settings
            // -----------------
            baseTabButtons.Add(() => { Toggles.CollapseFoldouts(mat, foldouts, 1); }, MGUI.collapseLabel);
            baseTabButtons.Add(() => { ResetBase(); }, MGUI.resetLabel);
            Action baseTabAction = () => {
                if (warnings != "")
                {
                    EditorGUILayout.HelpBox("Incorrect or missing vertex streams detected:\n" + warnings, MessageType.Warning, true);
                    if (GUILayout.Button(applyStreamsText, EditorStyles.miniButton))
                    {
                        foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial)
                        {
                            if (renderer != null)
                            {
                                if (renderer != null)
                                {
                                    renderer.SetActiveVertexStreams(streams);
                                }
                            }
                        }
                    }
                }

                // Blending mode dropdown
                MGUI.PropertyGroup(() => {
                    me.RenderQueueField();
                    me.ShaderProperty(_BlendMode, "Blending Mode");
                    me.ShaderProperty(_Culling, "Culling");
                    me.ShaderProperty(_ZTest, "ZTest");
                });
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_Opacity, "Opacity");
                    MGUI.ToggleSlider(me, "Cutout", _IsCutout, _Cutoff);
                    MGUI.ToggleSlider(me, Tips.falloffMode, _Softening, _SoftenStr);
                    me.ShaderProperty(_FlipbookBlending, Tips.flipbookBlending);
                });
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(texLabel, _MainTex, _Color);
                    me.TexturePropertySingleLine(tex2Label, _SecondTex, _SecondColor, _SecondTex.textureValue ? _TexBlendMode : null);
                    if (_SecondTex.textureValue)
                    {
                        MGUI.TexPropLabel("Blending", 113);
                    }
                });
            };
            Foldouts.Foldout("BASE", foldouts, baseTabButtons, mat, me, baseTabAction);

            // Filtering
            filterTabButtons.Add(() => { ResetFiltering(); }, MGUI.resetLabel);
            Action filterTabAction = () => {
                me.ShaderProperty(_Filtering, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Filtering.floatValue == 0);
                    me.ShaderProperty(_AutoShift, Tips.autoShift);
                    if (_AutoShift.floatValue == 1)
                    {
                        me.ShaderProperty(_AutoShiftSpeed, "Speed");
                    }
                    else
                    {
                        me.ShaderProperty(_Hue, "Hue");
                    }
                    me.ShaderProperty(_Saturation, "Saturation");
                    me.ShaderProperty(_Brightness, "Brightness");
                    me.ShaderProperty(_Contrast, "Contrast");
                    me.ShaderProperty(_HDR, "HDR");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("FILTERING", foldouts, filterTabButtons, mat, me, filterTabAction);

            // Distortion
            distortTabButtons.Add(() => { ResetDistortion(); }, MGUI.resetLabel);
            Action distortTabAction = () => {
                me.ShaderProperty(_Distortion, "Enable");
                MGUI.Space4();
                MGUI.ToggleGroup(_Distortion.floatValue == 0);
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(normalLabel, _NormalMap, _DistortMainTex);
                    MGUI.TexPropLabel("Distort UVs", 124);
                    MGUI.Vector2Field(_NormalMapScale, "Scale");
                    MGUI.SpaceN3();
                    MGUI.Vector2Field(_DistortionSpeed, "Scrolling");
                    me.ShaderProperty(_DistortionStr, "Strength");
                    me.ShaderProperty(_DistortionBlend, "Blend");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("DISTORTION", foldouts, distortTabButtons, mat, me, distortTabAction);

            // Pulse
            pulseTabButtons.Add(() => { ResetPulse(); }, MGUI.resetLabel);
            Action pulseTabAction = () => {
                me.ShaderProperty(_Pulse, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Pulse.floatValue == 0);
                    me.ShaderProperty(_Waveform, "Waveform");
                    me.ShaderProperty(_PulseStr, "Strength");
                    me.ShaderProperty(_PulseSpeed, "Speed");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("PULSE", foldouts, pulseTabButtons, mat, me, pulseTabAction);

            // Falloff
            falloffTabButtons.Add(() => { ResetFalloff(); }, MGUI.resetLabel);
            Action falloffTabAction = () => {
                me.ShaderProperty(_Falloff, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Falloff.floatValue == 0);
                    me.ShaderProperty(_FalloffMode, Tips.falloffMode);
                    MGUI.Space4();
                    me.ShaderProperty(_MinRange, "Far Min Range");
                    me.ShaderProperty(_MaxRange, "Far Max Range");
                    MGUI.Space4();
                    me.ShaderProperty(_NearMinRange, "Near Min Range");
                    me.ShaderProperty(_NearMaxRange, "Near Max Range");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("FALLOFF", foldouts, falloffTabButtons, mat, me, falloffTabAction);
        }

        GUILayout.Space(20);
        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);
        }
    }
 void DoPrimaryArea(Material material)
 {
     MGUI.PropertyGroup(() => {
         me.TexturePropertySingleLine(Tips.albedoText, albedoMap, albedoColor);
         if (useAlphaMask.floatValue == 1 && blendMode.floatValue > 0)
         {
             me.TexturePropertySingleLine(Tips.alphaMaskText, alphaMask, alphaMaskOpacity, alphaMaskChannel);
         }
         GUIContent roughLabel    = Tips.roughnessText;
         GUIContent roughStrLabel = Tips.roughnessPackedText;
         if (useSmoothness.floatValue == 1)
         {
             roughLabel.text    = "Smoothness";
             roughStrLabel.text = "Smoothness Strength";
         }
         else
         {
             roughLabel.text    = "Roughness";
             roughStrLabel.text = "Roughness Strength";
         }
         if (workflow.floatValue == 1)
         {
             me.TexturePropertySingleLine(Tips.packedMapText, packedMap);
             MGUI.sRGBWarning(packedMap);
             if (packedMap.textureValue)
             {
                 MGUI.PropertyGroupLayer(() => {
                     MGUI.SpaceN3();
                     me.ShaderProperty(metallicChannel, "Metallic");
                     me.ShaderProperty(roughChannel, roughLabel.text);
                     me.ShaderProperty(occlusionChannel, "Occlusion");
                     if (useHeight.floatValue == 1 && samplingMode.floatValue < 3)
                     {
                         me.ShaderProperty(heightChannel, "Height");
                     }
                     MGUI.SpaceN3();
                 });
                 MGUI.PropertyGroupLayer(() => {
                     MGUI.SpaceN2();
                     MGUI.ToggleSlider(me, Tips.metallicPackedText, metalMult, metallic);
                     MGUI.ToggleSlider(me, roughStrLabel, roughMult, roughness);
                     MGUI.ToggleSlider(me, Tips.occlusionPackedText, occMult, occlusionStrength);
                     if (useHeight.floatValue == 1 && samplingMode.floatValue < 3)
                     {
                         MGUI.ToggleSlider(me, Tips.heightMapPackedText, heightMult, heightMapScale);
                         me.ShaderProperty(steps, Tips.stepsText);
                         me.ShaderProperty(parallaxOfs, Tips.parallaxOfsText);
                     }
                     MGUI.SpaceN2();
                 });
                 MGUI.Space8();
             }
             if (useHeight.floatValue == 1 && samplingMode.floatValue < 3)
             {
                 me.TexturePropertySingleLine(Tips.heightMaskText, parallaxMask);
             }
         }
         else
         {
             me.TexturePropertySingleLine(Tips.metallicMapText, metallicMap, metallic);
             MGUI.sRGBWarning(metallicMap);
             me.TexturePropertySingleLine(roughLabel, roughnessMap, roughness);
             MGUI.sRGBWarning(roughnessMap);
             me.TexturePropertySingleLine(Tips.occlusionText, occlusionMap, occlusionMap.textureValue ? occlusionStrength : null);
             MGUI.sRGBWarning(occlusionMap);
             if (samplingMode.floatValue < 3)
             {
                 me.TexturePropertySingleLine(Tips.heightMapText, heightMap, heightMap.textureValue ? heightMapScale : null);
                 MGUI.sRGBWarning(heightMap);
                 if (heightMap.textureValue)
                 {
                     me.TexturePropertySingleLine(Tips.heightMaskText, parallaxMask);
                     me.ShaderProperty(steps, Tips.stepsText, 2);
                     me.ShaderProperty(parallaxOfs, Tips.parallaxOfsText, 2);
                 }
             }
         }
         me.TexturePropertySingleLine(Tips.normalMapText, bumpMap, bumpMap.textureValue ? bumpScale : null);
         me.TexturePropertySingleLine(Tips.reflOverrideText, reflOverride);
         me.TexturePropertySingleLine(Tips.reflCubeText, reflCube, reflCube.textureValue ? cubeThreshold : null);
         me.TexturePropertySingleLine(Tips.detailMaskText, detailMask, detailMask.textureValue ? detailMaskChannel : null);
         DoEmissionArea(material);
     });
 }
Пример #18
0
    void ShowBottomMenu()
    {
        // Left button
        if (MGUI.HoveredButton(new Rect(MGUI.Margin * 3, Screen.height - (Screen.width / 6), Screen.width / 7, Screen.width / 7), MainMenuButton))
        {
            switch (gameManager.GetGameState())
            {
            case GameManager.GameState.Paused:
                StartCoroutine(LoadMainMenu(audioSource));
                break;

            case GameManager.GameState.Over:
                StartCoroutine(LoadMainMenu(audio));
                break;
            }
        }

        // Middle button
        if (MGUI.HoveredButton(new Rect(Screen.width - (Screen.width / 2 + Screen.width / 14), Screen.height - (Screen.width / 6), Screen.width / 7, Screen.width / 7), Restart))
        {
            gameManager.RestartGame();
        }

        // Right button
        if (
            (gameManager.GetGameState() == GameManager.GameState.Over) &&
            (gameManager.GetMedal() == GameManager.Medal.None)
            )
        {
            GUI.enabled = false;               // Resume button is grayed out on the loss screen
        }
        if (MGUI.HoveredButton(new Rect(Screen.width - (Screen.width / 3 - Screen.width / 7), Screen.height - (Screen.width / 6), Screen.width / 7, Screen.width / 7), PlayButton))
        {
            if (gameManager.GetGameState() == GameManager.GameState.Paused)
            {
                gameManager.UnpauseGame();
            }
            if ((gameManager.GetGameState() == GameManager.GameState.Over))
            {
                StartCoroutine(WaitAndLoadNext());
            }
        }
        GUI.enabled = true;

        if (gameManager.GetGameState() == GameManager.GameState.Paused)
        {
            if (isSounON == "true")
            {
                if (MGUI.HoveredButton(creditsRect, soundON))
                {
                    PlayerPrefs.SetString("sound", "false");
                    isSounON = "false";
                    EnableSound();
                }
            }
            else
            {
                if (MGUI.HoveredButton(creditsRect, soundOff))
                {
                    PlayerPrefs.SetString("sound", "true");
                    isSounON = "true";
                    EnableSound();
                }
            }
        }
    }
    void DoUVArea()
    {
        bool needsHeightMaskUV = (((workflow.floatValue > 0 && useHeight.floatValue == 1) || (workflow.floatValue == 0 && heightMap.textureValue)) && parallaxMask.textureValue) && samplingMode.floatValue < 3;
        bool needsEmissMaskUV  = emissionEnabled && emissionMask.textureValue;
        bool needsAlphaMaskUV  = blendMode.floatValue > 0 && useAlphaMask.floatValue > 0;

        MGUI.PropertyGroup(() => {
            MGUI.BoldLabel("Primary");
            EditorGUI.BeginChangeCheck();
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                if (samplingMode.floatValue < 3)
                {
                    me.ShaderProperty(uvPri, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, albedoMap, uv0Scroll);
                }
                else
                {
                    MGUI.TextureSO(me, albedoMap);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset;
                }
                me.ShaderProperty(uv0Rot, "Rotation");
                MGUI.SpaceN2();
            });
            MGUI.Space4();
            MGUI.BoldLabel("Detail");
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                if (samplingMode.floatValue < 3)
                {
                    me.ShaderProperty(uvSetSecondary, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, detailAlbedoMap, uv1Scroll);
                }
                else
                {
                    MGUI.TextureSO(me, detailAlbedoMap);
                }
                me.ShaderProperty(uv1Rot, "Rotation");
                me.ShaderProperty(detailSamplingMode, Tips.detailSamplingMode);
                MGUI.SpaceN4();
            });
            if (needsHeightMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Height Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvHeightMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, parallaxMask, uv2Scroll);
                    MGUI.SpaceN2();
                });
            }
            if (needsEmissMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Emission Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvEmissMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, emissionMask, uv3Scroll);
                    me.ShaderProperty(uv3Rot, "Rotation");
                    MGUI.SpaceN2();
                });
            }
            if (needsAlphaMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Alpha Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvAlphaMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, alphaMask, uv4Scroll);
                    me.ShaderProperty(uv4Rot, "Rotation");
                    MGUI.SpaceN2();
                });
            }
        });
    }
Пример #20
0
    void OnGUI()
    {
        for (int i = 0; i < gamesNumber; i++)
        {
            if (MGUI.HoveredButton(gameSelectionRects[i], gameSelectionTextures[i]))
            {
                callOptions = false;
                SelectGame(i);
            }
        }

        if (selectedGame > -1 && callOptions == false)
        {
            GUI.DrawTexture(gamePreviewRect, previewTextures[selectedGame]);

            if (MGUI.HoveredButton(gamePreviewButtonRect, playButtonsTextures[selectedGame]))
            {
                Application.LoadLevel("TutorialScene");
            }
        }
        else if (callOptions == true)
        {
            GUI.DrawTexture(gamePreviewRect, previewTextures[1]);
            if (Sound == true)
            {
                if (MGUI.HoveredButton(soundButtonRect, soundON))
                {
                    PlayerPrefs.SetString("sound", "false");
                    Sound = false;
                    EnableSound();
                }
            }
            else
            {
                if (MGUI.HoveredButton(soundButtonRect, soundOff))
                {
                    PlayerPrefs.SetString("sound", "true");
                    Sound = true;
                    EnableSound();
                }
            }
            if (MGUI.HoveredButton(creditsButtonRect, credits))
            {
                Application.LoadLevel("CreditsScreen");
            }
        }
        else
        {
            GUI.DrawTexture(gameTitleRect, gameTitleTexture);
        }

        if (MGUI.HoveredButton(quitRect, gameExitTexture))
        {
            Application.Quit();
        }

        if (MGUI.HoveredButton(creditsRect, options))
        {
            callOptions = true;
        }
    }
    void DoRenderingArea(Material mat)
    {
        MGUI.PropertyGroup(() => {
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                if (samplingMode.floatValue != 4)
                {
                    me.ShaderProperty(culling, Tips.culling);
                }
                queueOffset.floatValue = (int)queueOffset.floatValue;
                me.ShaderProperty(queueOffset, Tips.queueOffset);
                MGUI.SpaceN1();
                MGUI.DummyProperty("Render Queue:", mat.renderQueue.ToString());
                MGUI.SpaceN4();
            });
            MGUI.Space1();
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                MGUI.ToggleFloat(me, Tips.useFresnel, useFresnel, fresnelStrength);
                MGUI.ToggleFloat(me, Tips.highlightsText, highlights, specularStrength);
                MGUI.ToggleFloat(me, Tips.reflectionsText, reflections, reflectionStrength);
                MGUI.ToggleFloat(me, Tips.ssrText, ssr, ssrStrength);
                if (ssr.floatValue == 1)
                {
                    me.ShaderProperty(edgeFade, Tips.edgeFadeText);
                }
                MGUI.ToggleFloat(me, Tips.reflVertexColor, reflVertexColor, reflVertexColorStrength);
                MGUI.ToggleFloat(me, Tips.reflShadows, reflShadows, reflShadowStrength);
                if (reflShadows.floatValue == 1)
                {
                    me.ShaderProperty(brightnessReflShad, "Brightness", 1);
                    me.ShaderProperty(contrastReflShad, "Contrast", 1);
                    me.ShaderProperty(hdrReflShad, "HDR", 1);
                }
                MGUI.ToggleFloat(me, Tips.gsaa, gsaa, gsaaStrength);
            });
            MGUI.Space1();
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN3();
                me.ShaderProperty(_BakeryMode, Tips.bakeryMode);
                me.ShaderProperty(_BAKERY_SHNONLINEAR, "Bakery Non-Linear SH");
                me.ShaderProperty(_BAKERY_LMSPEC, "Bakery Lightmap Specular");
                me.ShaderProperty(bicubicLightmap, Tips.bicubicLightmap);
                                #if LTCGI_INCLUDED
                me.ShaderProperty(ltcgi, "LTCGI");
                if (ltcgi.floatValue == 1)
                {
                    me.ShaderProperty(ltcgi_spec_off, "LTCGI Disable Specular");
                    me.ShaderProperty(ltcgi_diffuse_off, "LTCGI Disable Diffuse");
                }
                                #else
                ltcgi.floatValue = 0;
                mat.DisableKeyword("LTCGI");
                                #endif
                me.EnableInstancingField();
                MGUI.SpaceN2();
                me.DoubleSidedGIField();
                MGUI.SpaceN3();
            });

            if (ssr.floatValue == 1)
            {
                MGUI.DisplayInfo("\nScreenspace reflections in VRChat requires the \"Depth Light\" prefab found in: Assets/Mochie/Unity/Prefabs\n\nIt is also is VERY expensive, please use it sparingly!\n");
            }
            MGUI.Space1();
            // me.TexturePropertySingleLine(new GUIContent("RNM0"), _RNM0);
            // me.TexturePropertySingleLine(new GUIContent("RNM1"), _RNM1);
            // me.TexturePropertySingleLine(new GUIContent("RNM2"), _RNM2);
        });
    }
Пример #22
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);
        }
    }
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        me = materialEditor;
        Material material = materialEditor.target as Material;

        FindProperties(props, material);

        // Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
        // material to a standard shader.
        // Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
        if (m_FirstTimeApply)
        {
            MaterialChanged(material);
            m_FirstTimeApply = false;
        }

        // Add mat to foldout dictionary if it isn't in there yet
        if (!foldouts.ContainsKey(material))
        {
            foldouts.Add(material, toggles);
        }

        // Use default labelWidth
        EditorGUIUtility.labelWidth = 0f;

        // Detect any changes to the material
        EditorGUI.BeginChangeCheck(); {
            // Core Shader Variant
            MGUI.BoldLabel("Shader Variant");
            DoVariantArea();
            MGUI.Space2();

            // Primary properties
            MGUI.BoldLabel("Primary Textures");
            DoPrimaryArea(material);
            MGUI.Space2();

            // Detail properties
            DoDetailArea();
            MGUI.Space4();

            // Emission
            // bool emissFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Emission");
            // if (emissFoldout){
            //  DoEmissionArea(material);
            // }

            // Rim
            bool rimFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Rim");
            if (rimFoldout)
            {
                DoRimArea();
            }

            // Subsurface
            bool subsurfaceArea = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Subsurface Scattering");
            if (subsurfaceArea)
            {
                DoSubsurfaceArea();
            }

            // Filtering
            bool filteringFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Filtering");
            if (filteringFoldout)
            {
                DoFilteringArea();
            }

            // UVs
            bool uvFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "UVs");
            if (uvFoldout)
            {
                DoUVArea();
            }

            // Rendering options
            bool renderFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Render Settings");
            if (renderFoldout)
            {
                DoRenderingArea(material);
            }

            // Watermark and version display
            DoFooter();

            // Setup stuff for decal mode
            SetDecalRendering(material);
        }

        // Ensure settings are applied correctly if anything changed
        if (EditorGUI.EndChangeCheck())
        {
            foreach (var obj in blendMode.targets)
            {
                MaterialChanged((Material)obj);
            }
        }

        MGUI.Space8();
    }