Beispiel #1
0
 internal class GC_Separator : GUICommand { public override void OnGUI()
                                            {
                                                if (MaterialInspector_Hybrid.ShowNextProperty)
                                                {
                                                    TCP2_GUI.SeparatorSimple();
                                                }
                                            }
Beispiel #2
0
        void OnGUI()
        {
            TCP2_GUI.UseNewHelpIcon = true;

            EditorGUILayout.BeginHorizontal();
            TCP2_GUI.HeaderBig("TCP 2 - SMOOTHED NORMALS UTILITY");
            TCP2_GUI.HelpButton("Smoothed Normals Utility");
            EditorGUILayout.EndHorizontal();
            TCP2_GUI.Separator();

            TCP2_GUI.UseNewHelpIcon = false;

            /*
             * mFormat = EditorGUILayout.TextField(new GUIContent("Axis format", "Normals axis may need to be swapped before being packed into vertex colors/tangent/uv2 data. See documentation for more information."), mFormat);
             * mFormat = Regex.Replace(mFormat, @"[^xyzXYZ-]", "");
             * EditorGUILayout.BeginHorizontal();
             * GUILayout.Label("Known formats:");
             * if(GUILayout.Button("XYZ", EditorStyles.miniButtonLeft)) { mFormat = "XYZ"; GUI.FocusControl(null); }
             * if(GUILayout.Button("-YZ-X", EditorStyles.miniButtonMid)) { mFormat = "-YZ-X"; GUI.FocusControl(null); }
             * if(GUILayout.Button("-Z-Y-X", EditorStyles.miniButtonRight)) { mFormat = "-Z-Y-X"; GUI.FocusControl(null); }
             * EditorGUILayout.EndHorizontal();
             */

            if (mMeshes != null && mMeshes.Count > 0)
            {
                GUILayout.Space(4);
                TCP2_GUI.Header("Meshes ready to be processed:", null, true);
                mScroll = EditorGUILayout.BeginScrollView(mScroll);
                TCP2_GUI.SeparatorSimple();
                bool hasSkinnedMeshes = false;
                foreach (var sm in mMeshes.Values)
                {
                    GUILayout.Space(2);
                    GUILayout.BeginHorizontal();
                    var label = sm.name;
                    if (label.Contains(mFilenameSuffix))
                    {
                        label = label.Replace(mFilenameSuffix, "\n" + mFilenameSuffix);
                    }
                    GUILayout.Label(label, EditorStyles.wordWrappedMiniLabel, GUILayout.Width(260));
                    sm.isSkinned      = GUILayout.Toggle(sm.isSkinned, new GUIContent(" Skinned", "Should be checked if the mesh will be used on a SkinnedMeshRenderer"));
                    hasSkinnedMeshes |= sm.isSkinned;
                    GUILayout.Space(6);
                    GUILayout.EndHorizontal();
                    GUILayout.Space(2);
                    TCP2_GUI.SeparatorSimple();
                }
                EditorGUILayout.EndScrollView();
                GUILayout.FlexibleSpace();

                if (hasSkinnedMeshes)
                {
                    EditorGUILayout.HelpBox("Smoothed Normals for Skinned meshes will be stored in Tangents only. See Help to know why.", MessageType.Warning);
                }

                if (GUILayout.Button(mMeshes.Count == 1 ? "Generate Smoothed Mesh" : "Generate Smoothed Meshes", GUILayout.Height(30)))
                {
                    try
                    {
                        var   selection = new List <Object>();
                        float progress  = 1;
                        float total     = mMeshes.Count;
                        foreach (var sm in mMeshes.Values)
                        {
                            if (sm == null)
                            {
                                continue;
                            }

                            EditorUtility.DisplayProgressBar("Hold On", (mMeshes.Count > 1 ? "Generating Smoothed Meshes:\n" : "Generating Smoothed Mesh:\n") + sm.name, progress / total);
                            progress++;
                            Object o = CreateSmoothedMeshAsset(sm);
                            if (o != null)
                            {
                                selection.Add(o);
                            }
                        }
                        Selection.objects = selection.ToArray();
                    }
                    finally
                    {
                        EditorUtility.ClearProgressBar();
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Select one or multiple meshes to create a smoothed normals version.\n\nYou can also select models directly in the Scene, the new mesh will automatically be assigned.", MessageType.Info);
                GUILayout.FlexibleSpace();
                using (new EditorGUI.DisabledScope(true))
                    GUILayout.Button("Generate Smoothed Mesh", GUILayout.Height(30));
            }

            TCP2_GUI.Separator();

            smoothedNormalChannel = (Utils.SmoothedNormalsChannel)EditorGUILayout.EnumPopup(TCP2_GUI.TempContent("Vertex Data Target", "Defines where to store the smoothed normals in the mesh; use a target where there isn't any data already."), smoothedNormalChannel);
            EditorGUI.BeginDisabledGroup(smoothedNormalChannel == Utils.SmoothedNormalsChannel.Tangents || smoothedNormalChannel == Utils.SmoothedNormalsChannel.VertexColors);
            smoothedNormalUVType = (Utils.SmoothedNormalsUVType)EditorGUILayout.EnumPopup(TCP2_GUI.TempContent("UV Data Type", "Defines where and how to store the smoothed normals in the target vertex UV channel."), smoothedNormalUVType);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.HelpBox("You will need to select the proper option in the Material Inspector depending on the selected target/format!", MessageType.Info);

            /*
             * if (smoothedNormalChannel == Utils.SmoothedNormalsChannel.UV1 || smoothedNormalChannel == Utils.SmoothedNormalsChannel.UV3 || smoothedNormalChannel == Utils.SmoothedNormalsChannel.UV4 ||
             *      (smoothedNormalChannel == Utils.SmoothedNormalsChannel.UV2 && smoothedNormalUVType != Utils.SmoothedNormalsUVType.CompressedXY))
             * {
             *      EditorGUILayout.HelpBox("Only shaders made with the Shader Generator 2 support all texture coordinates.\nOther shaders only support UV2 with 'Compressed XY' option. UV1, UV3, UV4 won't work with them, as well as 'Full XYZ' and 'Compressed ZW' data types.", MessageType.Warning);
             * }
             */

            TCP2_GUI.Separator();

            TCP2_GUI.Header("Options", null, true);
            mFilenameSuffix  = EditorGUILayout.TextField(TCP2_GUI.TempContent("File name suffix"), mFilenameSuffix);
            mAlwaysOverwrite = EditorGUILayout.Toggle(new GUIContent("Always Overwrite", "Will always overwrite existing [TCP2 Smoothed] meshes"), mAlwaysOverwrite);
            mCustomDirectory = EditorGUILayout.Toggle(new GUIContent("Custom Output Directory", "Save the generated smoothed meshes in a custom directory"), mCustomDirectory);
            using (new EditorGUI.DisabledScope(!mCustomDirectory))
            {
                EditorGUILayout.BeginHorizontal();
                mCustomDirectoryPath = EditorGUILayout.TextField(GUIContent.none, mCustomDirectoryPath);
                if (GUILayout.Button("Select...", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                {
                    var outputPath = Utils.OpenFolderPanel_ProjectPath("Choose custom output directory for generated smoothed meshes", mCustomDirectoryPath);
                    if (!string.IsNullOrEmpty(outputPath))
                    {
                        mCustomDirectoryPath = outputPath;
                    }
                }
                EditorGUILayout.EndHorizontal();
            };

            GUILayout.Space(10);
        }
Beispiel #3
0
 protected override void DrawGUI(Rect position, Config config)
 {
     TCP2_GUI.SeparatorSimple();
 }
 protected override void DrawGUI(Rect position, Config config, bool labelClicked)
 {
     TCP2_GUI.SeparatorSimple();
 }