Exemplo n.º 1
0
    private static void Space()
    {
        var color = EditorGUIUtility.isProSkin ? new Color(0.15f, 0.15f, 0.15f) : new Color(0.65f, 0.65f, 0.65f);

        TCP2_GUI.GUILine(color, 1);
        GUILayout.Space(1);
    }
Exemplo n.º 2
0
 static private void Space()
 {
     TCP2_GUI.GUILine(new Color(0.65f, 0.65f, 0.65f), 1);
     GUILayout.Space(1);
 }
Exemplo n.º 3
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        TCP2_GUI.HeaderBig("TCP 2 - SMOOTHED NORMALS UTILITY");
        TCP2_GUI.HelpButton("Smoothed Normals Utility");
        EditorGUILayout.EndHorizontal();
        TCP2_GUI.Separator();

        /*
         * 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.GUILine(Color.gray, 1);
//			for(int i = 0; i < mMeshes.Count; i++)
            foreach (SelectedMesh sm in mMeshes.Values)
            {
                GUILayout.Space(2);
                GUILayout.BeginHorizontal();
                string label = sm.name;
                if (label.Contains(MESH_SUFFIX))
                {
                    label = label.Replace(MESH_SUFFIX, "\n" + MESH_SUFFIX);
                }
                GUILayout.Label(label, EditorStyles.wordWrappedMiniLabel, GUILayout.Width(270));
                sm.isSkinned = GUILayout.Toggle(sm.isSkinned, new GUIContent("Skinned", "Should be checked if the mesh will be used on a SkinnedMeshRenderer"), EditorStyles.toolbarButton);
                GUILayout.Space(6);
                GUILayout.EndHorizontal();
                GUILayout.Space(2);
                TCP2_GUI.GUILine(Color.gray, 1);
            }
            EditorGUILayout.EndScrollView();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(mMeshes.Count == 1 ? "Generate Smoothed Mesh" : "Generate Smoothed Meshes", GUILayout.Height(30)))
            {
                List <Object> selection = new List <Object>();
                float         progress  = 1;
                float         total     = mMeshes.Count;
                foreach (SelectedMesh 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);
                    }
                }
                EditorUtility.ClearProgressBar();
                Selection.objects = selection.ToArray();
            }
        }
        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();
        }

        TCP2_GUI.Header("Store smoothed normals in:", "You will have to select the correct option in the Material Inspector when using outlines", true);

        int choice = 0;

        if (mTangents)
        {
            choice = 1;
        }
        if (mUV2)
        {
            choice = 2;
        }
        choice = TCP2_GUI.RadioChoice(choice, true, "Vertex Colors", "Tangents", "UV2");
        EditorGUILayout.HelpBox("Smoothed Normals for Skinned meshes will be stored in Tangents only. See Help to know why.", MessageType.Warning);

        mVColors  = (choice == 0);
        mTangents = (choice == 1);
        mUV2      = (choice == 2);

        TCP2_GUI.Header("Options", null, true);
        GUILayout.BeginHorizontal();
        mAlwaysOverwrite = EditorGUILayout.Toggle(new GUIContent("Always Overwrite", "Will always overwrite existing [TCP2 Smoothed] meshes"), mAlwaysOverwrite);
        if (GUILayout.Button(new GUIContent("Clear Progress Bar", "Clears the progress bar if it's hanging on screen after an error."), EditorStyles.miniButton, GUILayout.Width(164)))
        {
            EditorUtility.ClearProgressBar();
        }
        GUILayout.EndHorizontal();
    }