Esempio n. 1
0
    public override T SerializeObject <T>(T obj, Action <T> onPreSerialize = null, string name = null)
    {
        CurrentName.Add(name);

        var fullName = GetFullName(name);

        if (!Foldouts.ContainsKey(fullName))
        {
            Foldouts[fullName] = true;
        }

        Foldouts[fullName] = EditorGUI.Foldout(Window.GetNextRect(ref Window.YPos), Foldouts[fullName], $"{name}", true);

        if (Foldouts[fullName])
        {
            Depth++;
            Window.IndentLevel++;
            obj.SerializeImpl(this);
            Window.IndentLevel--;
            Depth--;
        }

        CurrentName.RemoveAt(CurrentName.Count - 1);

        return(obj);
    }
Esempio n. 2
0
        private void OnEnable()
        {
            if (prefs == null)
            {
                prefs = BetterPrefs.GetEditorInstance();
            }

            if (foldouts == null)
            {
                foldouts = new Foldouts(prefs);
            }

            var component = target as Component;

            gameObject = component == null ? null : component.gameObject;

            targetType = target.GetType();

            id = RuntimeHelper.GetTargetID(target);

            _useUnityGUI = useUnityGUI;
            gui          = _useUnityGUI ? (BaseGUI) new TurtleGUI() : new RabbitGUI();

            Initialize();

            gui.OnEnable();
        }
 private void OnEnable()
 {
     dialogueSystemController       = target as DialogueSystemController;
     displaySettingsProperty        = serializedObject.FindProperty("displaySettings");
     persistentDataSettingsProperty = serializedObject.FindProperty("persistentDataSettings");
     foldouts = EditorPrefs.HasKey(InspectorEditorPrefsKey) ? JsonUtility.FromJson <Foldouts>(EditorPrefs.GetString(InspectorEditorPrefsKey)) : new Foldouts();
 }
Esempio n. 4
0
        private void OnEnable()
        {
            if (prefs == null)
            {
                prefs = BetterPrefs.GetEditorInstance();
            }

            if (foldouts == null)
            {
                foldouts = new Foldouts();
            }

            var component = target as Component;

            gameObject = component == null ? null : component.gameObject;

            targetType = target.GetType();

            id = RuntimeHelper.GetTargetID(target);

            Initialize();

            var rabbit = gui as RabbitGUI;

            if (rabbit != null && _membersDrawnByUnityLayout.Length > 0)
            {
                rabbit.OnFinishedLayoutReserve = DoUnityLayout;
            }

            gui.OnEnable();
        }
        public virtual void OnEnable()
        {
            var trigger = target as DialogueSystemTrigger;

            if (trigger == null)
            {
                return;
            }
            if (trigger.selectedDatabase == null)
            {
                if (EditorTools.selectedDatabase == null)
                {
                    EditorTools.selectedDatabase = EditorTools.FindInitialDatabase();
                }
                trigger.selectedDatabase = EditorTools.selectedDatabase;
            }
            else
            {
                EditorTools.selectedDatabase = trigger.selectedDatabase;
            }
            luaScriptWizard = new LuaScriptWizard(trigger.selectedDatabase);
            questPicker     = new QuestPicker(trigger.selectedDatabase, trigger.questName, trigger.useQuestNamePicker);
            questPicker.showReferenceDatabase = false;

            showSetQuestStateAction  = !string.IsNullOrEmpty(trigger.questName);
            showRunLuaCodeAction     = !string.IsNullOrEmpty(trigger.luaCode);
            showPlaySequenceAction   = !string.IsNullOrEmpty(trigger.sequence);                                                                                                       // || trigger.sequenceSpeaker != null || trigger.sequenceListener != null;
            showAlertAction          = !string.IsNullOrEmpty(trigger.alertMessage);                                                                                                   // || trigger.alertDuration > 0;
            showSendMessagesAction   = trigger.sendMessages.Length > 0;
            showBarkAction           = !string.IsNullOrEmpty(trigger.barkConversation) || !string.IsNullOrEmpty(trigger.barkText) || !string.IsNullOrEmpty(trigger.barkTextSequence); // || trigger.barker != null;
            showConversationAction   = !string.IsNullOrEmpty(trigger.conversation);                                                                                                   // || trigger.conversationActor != null || trigger.conversationConversant != null;
            showSetActiveAction      = trigger.setActiveActions.Length > 0;
            showSetEnabledAction     = trigger.setEnabledActions.Length > 0;
            showAnimatorStatesAction = trigger.setAnimatorStateActions.Length > 0;
            showUnityEventAction     = trigger.onExecute.GetPersistentEventCount() > 0;

            sendMessageList = new ReorderableList(serializedObject, serializedObject.FindProperty("sendMessages"), true, true, true, true);
            sendMessageList.drawHeaderCallback  = OnDrawSendMessageListHeader;
            sendMessageList.drawElementCallback = OnDrawSendMessageListElement;

            setActiveList = new ReorderableList(serializedObject, serializedObject.FindProperty("setActiveActions"), true, true, true, true);
            setActiveList.drawHeaderCallback  = OnDrawSetActiveListHeader;
            setActiveList.drawElementCallback = OnDrawSetActiveListElement;

            setEnabledList = new ReorderableList(serializedObject, serializedObject.FindProperty("setEnabledActions"), true, true, true, true);
            setEnabledList.drawHeaderCallback  = OnDrawSetEnabledListHeader;
            setEnabledList.drawElementCallback = OnDrawSetEnabledListElement;

            setAnimatorStateList = new ReorderableList(serializedObject, serializedObject.FindProperty("setAnimatorStateActions"), true, true, true, true);
            setAnimatorStateList.drawHeaderCallback  = OnDrawSetAnimatorStateListHeader;
            setAnimatorStateList.drawElementCallback = OnDrawSetAnimatorStateListElement;

            foldouts = EditorPrefs.HasKey(InspectorEditorPrefsKey) ? JsonUtility.FromJson <Foldouts>(EditorPrefs.GetString(InspectorEditorPrefsKey)) : new Foldouts();
            if (foldouts == null)
            {
                foldouts = new Foldouts();
            }
        }
Esempio n. 6
0
 public BaseDrawer()
 {
     if (prefs == null)
     {
         prefs = BetterPrefs.GetEditorInstance();
     }
     if (foldouts == null)
     {
         foldouts = new Foldouts(prefs);
     }
 }
Esempio n. 7
0
        public void OnEnable()
        {
            var trigger = target as ConditionObserver;

            if (trigger == null)
            {
                return;
            }
            if (EditorTools.selectedDatabase == null)
            {
                EditorTools.selectedDatabase = EditorTools.FindInitialDatabase();
            }
            luaScriptWizard = new LuaScriptWizard(EditorTools.selectedDatabase);
            questPicker     = new QuestPicker(EditorTools.selectedDatabase, trigger.questName, trigger.useQuestNamePicker);
            questPicker.showReferenceDatabase = false;
            sendMessageList = new ReorderableList(serializedObject, serializedObject.FindProperty("sendMessages"), true, true, true, true);
            sendMessageList.drawHeaderCallback  = OnDrawSendMessageListHeader;
            sendMessageList.drawElementCallback = OnDrawSendMessageListElement;
            foldouts = EditorPrefs.HasKey(InspectorEditorPrefsKey) ? JsonUtility.FromJson <Foldouts>(EditorPrefs.GetString(InspectorEditorPrefsKey)) : new Foldouts();
        }
Esempio n. 8
0
 static BaseDrawer()
 {
     foldouts = new Foldouts(prefs);
 }
    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);
        }
    }
    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);
        }
    }
    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();
    }