Example #1
0
        /// <summary>
        /// Draws the GUI
        /// </summary>
        /// <param name="materialEditor">Material editor provided by the custom inspector</param>
        /// <param name="properties">Array of materialProperties provided by the custom inspector</param>
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            //if is the first cycle it runs, do the initializzations needed on the start function
            if (isFirstCycle)
            {
                Start(materialEditor, properties);
                isFirstCycle = false;
            }
            TSFunctions.DrawHeader(EditorGUIUtility.currentViewWidth, 10);

            //Temporary code for converting back HDR colors
#if UNITY_2018_1_OR_NEWER
            if (FindProperty("_NeedsFix", properties).floatValue == 1)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Convert HDR colors back to 2017 look"))
                {
                    foreach (MaterialProperty m in properties)
                    {
                        if (m.flags == MaterialProperty.PropFlags.HDR)
                        {
                            m.colorValue = m.colorValue.linear;
                        }
                    }
                    FindProperty("_NeedsFix", properties).floatValue = 0;
                }
                if (GUILayout.Button("Keep current colors"))
                {
                    FindProperty("_NeedsFix", properties).floatValue = 0;
                }
                EditorGUILayout.EndHorizontal();
            }
#endif

            //if a keyword is used to apply the effects on the shader caused by enabling/disabling a section, it needs to be set every update
            foreach (Material mat in _SpecularOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0));
                TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0);
            }

            //draw main section
            if (inspectorLevel == InspectorLevel.Basic)
            {
                basicMain.DrawSection(materialEditor);
            }
            else
            {
                main.DrawSection(materialEditor);
            }
            group.DrawSectionsList(materialEditor, properties);
            group.DrawAddButton(properties);

            TSFunctions.DrawFooter();
        }
Example #2
0
        void OnGUI()
        {
            TSFunctions.DrawHeader(position.width, 20);
            EditorGUILayout.LabelField("Seems like this is your first time installing Toony Standard, first of all, thanks for using it, it makes me happy.", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Now, the only thing that you need to set immediately is the inspector level, this will tell the shader what features to expose based on your experience with making stuff in unity.", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("You can edit this choice later and modify other options by going on Window/Toony Standard/Settings ", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUI.BeginChangeCheck();
            inspectorLevel = (InspectorLevel)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.InspectorLevel, inspectorLevel);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)inspectorLevel);

                switch (inspectorLevel)
                {
                case InspectorLevel.Basic:
                    boxMessage = "The basic level is suited for people who are relatively new to avatar creation giving them just the basic stuff they need to get started.";
                    break;

                case InspectorLevel.Normal:
                    boxMessage = "Normal level will give the vast majority of the features this shader has to offer, this is the default setting and probably will be the most used one.";
                    break;

                case InspectorLevel.Expert:
                    boxMessage = "Warning, i expect you to be experienced in what you're doing in order to select this.\nThis level grants access to all the features and little adjustments that you can do with this shader, even if you don't know what the hell they do.";
                    break;
                }
            }

            EditorGUILayout.HelpBox(boxMessage, MessageType.Info);

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Done!", GUILayout.MinWidth(100)))
            {
                this.Close();
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);
        }
Example #3
0
        /// <summary>
        /// Main GUI update
        /// </summary>
        void OnGUI()
        {
            // If this is the first iteration since the window is opened, do the needed initializzations
            if (firstCycle)
            {
                Start();
            }
            // Check if for some reason the updater is not initialized, this eventuality tends to happen if some code gets recompiled while the window is open
            if (updater == null)
            {
                updater = new TSUpdater();
            }

            TSFunctions.DrawHeader(position.width, 10);

            section = (MultiWindowSection)GUILayout.Toolbar((int)section, Enum.GetNames(typeof(MultiWindowSection)), EditorStyles.toolbarButton, GUI.ToolbarButtonSize.Fixed);

            MainAreaScrollPos = EditorGUILayout.BeginScrollView(MainAreaScrollPos);
            GUILayout.Space(10);
            // Based on the section selected draw only the gui of said section
            switch (section)
            {
            case MultiWindowSection.Settings:
                DrawSettings();
                break;

            case MultiWindowSection.Updater:
                DrawUpdater();
                break;

            case MultiWindowSection.Credits:
                DrawCredits();
                break;

            default:
                EditorGUILayout.LabelField("Something went wrong, maybe you should contact the creator and report this");
                break;
            }
            EditorGUILayout.EndScrollView();

            TSFunctions.DrawFooter();
        }
Example #4
0
        /// <summary>
        /// Draws the GUI
        /// </summary>
        /// <param name="materialEditor">Material editor provided by the custom inspector</param>
        /// <param name="properties">Array of materialProperties provided by the custom inspector</param>
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            //if is the first cycle it runs, do the initializzations needed on the start function
            if (isFirstCycle)
            {
                Start(materialEditor, properties);
                isFirstCycle = false;
            }
            //Fetching properties is needed only if the start function has not run since the start function already fetches them once
            else
            {
                FindProperties(properties);
            }
            TSFunctions.DrawHeader(EditorGUIUtility.currentViewWidth, 10);

            //Temporary code for converting back HDR colors
            #if UNITY_2018_1_OR_NEWER
            if (FindProperty("_NeedsFix", properties).floatValue == 1)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Convert HDR colors back to 2017 look"))
                {
                    foreach (MaterialProperty m in properties)
                    {
                        if (m.flags == MaterialProperty.PropFlags.HDR)
                        {
                            m.colorValue = m.colorValue.linear;
                        }
                    }
                    FindProperty("_NeedsFix", properties).floatValue = 0;
                }
                if (GUILayout.Button("Keep current colors"))
                {
                    FindProperty("_NeedsFix", properties).floatValue = 0;
                }
                EditorGUILayout.EndHorizontal();
            }
            #endif

            //if a keyword is used to apply the effects on the shader caused by enabling/disabling a section, it needs to be set every update
            foreach (Material mat in _SpecularOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", mat.GetFloat(_SpecularOn.name) != 0);
                TSFunctions.SetKeyword(mat, "_DETAIL_MAP", mat.GetFloat(_DetailMapOn.name) != 0);
            }

            //draw main section
            if (inspectorLevel == InspectorLevel.Basic)
            {
                DrawBasicMainSection(materialEditor);
            }
            else
            {
                if (!_RampOn.hasMixedValue && _RampOn.floatValue == 0f)
                {
                    _Ramp.textureValue          = TSConstants.DefaultRamp;
                    _RampOffset.floatValue      = 0f;
                    _ShadowIntensity.floatValue = 0.4f;
                }
                DrawMainSection(materialEditor);
            }
            group.DrawSectionsList(materialEditor);
            group.DrawAddButton();

            TSFunctions.DrawFooter();
        }
Example #5
0
 void OnGUI()
 {
     TSFunctions.DrawHeader(position.width, 20);
     updater.DrawGUI();
 }