Ejemplo n.º 1
0
                // ---------------------------------------------------------------------------
                // Create Prefabs Section
                // ---------------------------------------------------------------------------
                private void GUICreatePrefabs()
                {
                    // -------------------------------------
                    // Section header
                    // -------------------------------------
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);
                    EditorGUILayout.LabelField("Step 5:  Create Prefabs", EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("Extract meshes, then generate and save prefabs.");
                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();

                    GUILayout.Space(5f);

                    EditorGUILayout.BeginVertical();

                    EditorGUILayout.BeginHorizontal();

                    // "Add Mesh Collider" checkbox
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);
                    flagAddMeshCollider = GUILayout.Toggle(flagAddMeshCollider, "Add Mesh Collider");
                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();

                    // "Add Empty Parent" checkbox
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);
                    flagAddEmptyParent = GUILayout.Toggle(flagAddEmptyParent, "Add Empty Parent");
                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();

                    // "Split Mesh by Material" checkbox
                    //GUI.enabled = false;
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);

                    //MAST_PrepModels.MergeMethod mergeMethod
                    mergeMethod = (MAST.Tools.Prefab_Creator.MergeMethod)EditorGUILayout.EnumPopup(mergeMethod);

                    //flagPreserveModelHierarchy = GUILayout.Toggle(flagPreserveModelHierarchy,
                    //    new GUIContent("Preserve Model Hierarchy", "Create a Prefab that has the same parent/child relationships as the Model"));
                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();
                    //GUI.enabled = true;

                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.EndVertical();

                    GUILayout.Space(5f);

                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);

                    // "Create Prefabs" button
                    if (GUILayout.Button(new GUIContent("Create Prefabs", "Create prefabs")))
                    {
                        PrepModels.CreatePrefabs(modelPath, sourceMat, new List <string>(sourceMatName),
                                                 conMatPointer, conMatName, conMat,
                                                 flagAddMeshCollider, flagAddEmptyParent, mergeMethod);
                    }

                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();
                }
Ejemplo n.º 2
0
                // ---------------------------------------------------------------------------
                // Link Materials Section
                // ---------------------------------------------------------------------------
                private void GUILinkMaterials()
                {
                    #region Error Handling
                    // If the material organization process not complete
                    try
                    {
                        if (conMatName.Length == 0)
                        {
                            // Go back a step
                            processStep = 2;
                            return;
                        }
                    }
                    catch
                    {
                        // Go back a step
                        processStep = 2;
                        return;
                    }
                    #endregion

                    // -------------------------------------
                    // Section header
                    // -------------------------------------
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);
                    EditorGUILayout.LabelField("Step 4:  Link Materials", EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("Link model materials to saved materials in project");
                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();

                    GUILayout.Space(5f);

                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);

                    EditorGUILayout.LabelField("Consolidated Materials (Name > Path)");

                    conMatScrollPos = EditorGUILayout.BeginScrollView(conMatScrollPos);

                    linkMatSelection = GUILayout.SelectionGrid(linkMatSelection, linkMatSelGridData, 1);

                    EditorGUILayout.EndScrollView();

                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(5f);
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);

                    // Substitute Selected Material button
                    if (GUILayout.Button(new GUIContent("Substitute Selected Material",
                                                        "Choose a Material to subtitute for the selected material")))
                    {
                        // Show choose Material file dialog
                        string matPath =
                            EditorUtility.OpenFilePanelWithFilters("Choose substitute Material for " + conMatName[linkMatSelection],
                                                                   lastFolderSelected, new[] { "Material files", "mat" });

                        // If a material was chosen (Cancel was not clicked)
                        if (matPath != "")
                        {
                            // Convert to project local path "Assets/..."
                            matPath = matPath.Replace(Application.dataPath, "Assets");

                            // Add matpath to array
                            conMatPath[linkMatSelection] = matPath;

                            // Link to new asset
                            conMat[linkMatSelection] = (Material)AssetDatabase.LoadAssetAtPath(conMatPath[linkMatSelection], typeof(Material));

                            // Recreate selection grid data
                            linkMatSelGridData = CombineStringsWithinArrays(conMatName, this.conMatPath, " > ");

                            // Remember this folder for next time
                            lastFolderSelected = matPath;
                        }
                    }

                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(5f);
                    GUILayout.BeginVertical("MAST Toolbar BG Inset");
                    GUILayout.Space(5f);

                    // Done with Substituting Materials button
                    if (GUILayout.Button(new GUIContent("Done with Substituting Materials", "Go to next step")))
                    {
                        // GoTo next step
                        processStep = 4;

                        // Reset "Create Prefab" section options
                        flagAddMeshCollider = true;
                        flagAddEmptyParent  = true;
                        mergeMethod         = MAST.Tools.Prefab_Creator.MergeMethod.MergeChildren;
                        //flagPreserveModelHierarchy = false;
                    }

                    GUILayout.Space(5f);
                    EditorGUILayout.EndVertical();
                }