コード例 #1
0
    public void DrawGrouperInspector()
    {
        EditorGUILayout.HelpBox("This component helps you group meshes that are close together so they can be combined together." +
                                " It generates multiple MB3_MeshBaker objects from the List Of Objects to be combined in the MB3_TextureBaker component." +
                                " Objects that are close together will be grouped together and added to a new child MB3_MeshBaker object.\n\n" +
                                " TIP: Try the new agglomerative cluster type. It's awsome!", MessageType.Info);
        MB3_MeshBakerGrouper grouper = (MB3_MeshBakerGrouper)target;

        EditorGUILayout.PropertyField(clusterType, gc_ClusterType);
        MB3_MeshBakerGrouper.ClusterType gg = (MB3_MeshBakerGrouper.ClusterType)clusterType.enumValueIndex;
        if ((gg == MB3_MeshBakerGrouper.ClusterType.none && !(grouper.grouper is MB3_MeshBakerGrouperNone)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.grid && !(grouper.grouper is MB3_MeshBakerGrouperGrid)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.pie && !(grouper.grouper is MB3_MeshBakerGrouperPie)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.agglomerative && !(grouper.grouper is MB3_MeshBakerGrouperCluster))
            )
        {
            grouper.CreateGrouper(gg, grouper.data);
            grouper.clusterType = gg;
        }

        if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.grid)
        {
            EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
            EditorGUILayout.PropertyField(cellSize, gc_CellSize);
        }
        else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.pie)
        {
            EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
            EditorGUILayout.PropertyField(numSegments, gc_NumSegements);
            EditorGUILayout.PropertyField(pieAxis, gc_PieAxis);
            EditorGUILayout.PropertyField(pieRingSpacing, gc_PieRingSpacing);
            EditorGUILayout.PropertyField(pieCombineAllInCenterRing, gc_PieCombineAllInCenterRing);
        }
        else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.agglomerative)
        {
            float dist    = clusterDistance.floatValue;
            float maxDist = 100f;
            float minDist = .000001f;
            MB3_MeshBakerGrouperCluster cl = null;
            if (grouper.grouper is MB3_MeshBakerGrouperCluster)
            {
                cl      = (MB3_MeshBakerGrouperCluster)grouper.grouper;
                maxDist = cl._ObjsExtents;
                minDist = cl._minDistBetweenClusters;
                if (dist < minDist)
                {
                    dist = Mathf.Lerp(minDist, maxDist, .11f);
                }
            }

            dist = EditorGUILayout.Slider(gc_ClusterDistance, dist, minDist, maxDist);
            clusterDistance.floatValue = dist;

            string btnName = "Refresh Clusters";
            if (cl.cluster == null || cl.cluster.clusters == null || cl.cluster.clusters.Length == 0)
            {
                btnName = "Click To Build Clusters";
            }
            if (GUILayout.Button(btnName))
            {
                if (grouper.grouper is MB3_MeshBakerGrouperCluster)
                {
                    MB3_MeshBakerGrouperCluster cg = (MB3_MeshBakerGrouperCluster)grouper.grouper;
                    MB3_TextureBaker            tb = grouper.GetComponent <MB3_TextureBaker>();
                    if (tb != null)
                    {
                        //MB3_EditorMethods em = new MB3_EditorMethods();
                        cg.BuildClusters(tb.GetObjectsToCombine(), updateProgressBar);
                        EditorUtility.ClearProgressBar();
                        Repaint();
                    }
                }
            }
        }

        EditorGUILayout.PropertyField(clusterOnLMIndex, gc_ClusterOnLMIndex);
        EditorGUILayout.PropertyField(clusterByLODLevel, gc_ClusterByLODLevel);
        EditorGUILayout.PropertyField(includeCellsWithOnlyOneRenderer, gc_IncludeCellsWithOnlyOneRenderer);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Mesh Baker Settings", EditorStyles.boldLabel);
        EditorGUILayout.HelpBox("These settings will be shared by all created Mesh Bakers.", MessageType.Info);

        UnityEngine.Object oldObjVal = mbSettingsAsset.objectReferenceValue;
        EditorGUILayout.PropertyField(mbSettingsAsset, gc_Settings);

        if (mbSettingsAsset.objectReferenceValue == null)
        {
            meshBakerSettingsMe.DrawGUI(grouper.meshBakerSettings, true);
        }
        else
        {
            if (meshBakerSettingsExternal == null || oldObjVal != mbSettingsAsset.objectReferenceValue)
            {
                meshBakerSettingsExternal = new MB_MeshBakerSettingsEditor();
                meshBakerSettingsExternal.OnEnable(((MB3_MeshCombinerSettings)mbSettingsAsset.objectReferenceValue).GetMeshBakerSettingsAsSerializedProperty());
            }

            meshBakerSettingsExternal.DrawGUI(((MB3_MeshCombinerSettings)mbSettingsAsset.objectReferenceValue).data, false);
        }
    }
コード例 #2
0
        public void DrawGrouperInspector()
        {
            EditorGUILayout.HelpBox("This component helps you group meshes that are close together so they can be combined together." +
                                    " It generates multiple MB3_MeshBaker objects from the List Of Objects to be combined in the MB3_TextureBaker component." +
                                    " Objects that are close together will be grouped together and added to a new child MB3_MeshBaker object.\n\n" +
                                    " TIP: Try the new agglomerative cluster type. It's awsome!", MessageType.Info);
            MB3_MeshBakerGrouper tbg = (MB3_MeshBakerGrouper)target;

            MB3_TextureBaker tb = tbg.GetComponent <MB3_TextureBaker>();

            Transform pgo = (Transform)EditorGUILayout.ObjectField(gc_ParentSceneObject, parentSceneObject.objectReferenceValue, typeof(Transform), true);

            if (pgo != null && MB_Utility.IsSceneInstance(pgo.gameObject))
            {
                parentSceneObject.objectReferenceValue = pgo;
            }
            else
            {
                parentSceneObject.objectReferenceValue = null;
            }

            EditorGUILayout.PropertyField(clusterType, gc_ClusterType);
            MB3_MeshBakerGrouper.ClusterType gg = (MB3_MeshBakerGrouper.ClusterType)clusterType.enumValueIndex;
            if ((gg == MB3_MeshBakerGrouper.ClusterType.none && !(tbg.grouper is MB3_MeshBakerGrouperNone)) ||
                (gg == MB3_MeshBakerGrouper.ClusterType.grid && !(tbg.grouper is MB3_MeshBakerGrouperGrid)) ||
                (gg == MB3_MeshBakerGrouper.ClusterType.pie && !(tbg.grouper is MB3_MeshBakerGrouperPie)) ||
                (gg == MB3_MeshBakerGrouper.ClusterType.agglomerative && !(tbg.grouper is MB3_MeshBakerGrouperCluster))
                )
            {
                tbg.CreateGrouper(gg, tbg.data);
                tbg.clusterType = gg;
            }

            if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.grid)
            {
                EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
                EditorGUILayout.PropertyField(cellSize, gc_CellSize);
            }
            else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.pie)
            {
                EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
                EditorGUILayout.PropertyField(numSegments, gc_NumSegements);
                EditorGUILayout.PropertyField(pieAxis, gc_PieAxis);
                EditorGUILayout.PropertyField(pieRingSpacing, gc_PieRingSpacing);
                EditorGUILayout.PropertyField(pieCombineAllInCenterRing, gc_PieCombineAllInCenterRing);
            }
            else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.agglomerative)
            {
                float dist    = clusterDistance.floatValue;
                float maxDist = 100f;
                float minDist = .000001f;
                MB3_MeshBakerGrouperCluster cl = null;
                if (tbg.grouper is MB3_MeshBakerGrouperCluster)
                {
                    cl      = (MB3_MeshBakerGrouperCluster)tbg.grouper;
                    maxDist = cl._ObjsExtents;
                    minDist = cl._minDistBetweenClusters;
                    if (dist < minDist)
                    {
                        dist = Mathf.Lerp(minDist, maxDist, .11f);
                    }
                }

                dist = EditorGUILayout.Slider(gc_ClusterDistance, dist, minDist, maxDist);
                clusterDistance.floatValue = dist;

                string btnName = "Refresh Clusters";
                if (cl.cluster == null || cl.cluster.clusters == null || cl.cluster.clusters.Length == 0)
                {
                    btnName = "Click To Build Clusters";
                }
                if (GUILayout.Button(btnName))
                {
                    if (tbg.grouper is MB3_MeshBakerGrouperCluster)
                    {
                        MB3_MeshBakerGrouperCluster cg = (MB3_MeshBakerGrouperCluster)tbg.grouper;
                        if (tb != null)
                        {
                            cg.BuildClusters(tb.GetObjectsToCombine(), updateProgressBar);
                            EditorUtility.ClearProgressBar();
                            Repaint();
                        }
                    }
                }
            }

            EditorGUILayout.PropertyField(clusterOnLMIndex, gc_ClusterOnLMIndex);
            EditorGUILayout.PropertyField(clusterByLODLevel, gc_ClusterByLODLevel);
            EditorGUILayout.PropertyField(includeCellsWithOnlyOneRenderer, gc_IncludeCellsWithOnlyOneRenderer);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Prefab Output Settings", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(prefabOptions_autoGeneratePrefabs, gc_prefabOptions_autoGeneratePrefabs);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(prefabOptions_outputFolder, gc_prefabOptions_outputFolder);
            if (GUILayout.Button("Browse"))
            {
                string path = EditorUtility.OpenFolderPanel("Browse For Output Folder", "", "");
                path = MB_BatchPrefabBakerEditorFunctions.ConvertFullPathToProjectRelativePath(path);
                prefabOptions_outputFolder.stringValue = path;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Mesh Baker Settings", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("These settings will be shared by all created Mesh Bakers.", MessageType.Info);

            UnityEngine.Object oldObjVal = mbSettingsAsset.objectReferenceValue;
            EditorGUILayout.PropertyField(mbSettingsAsset, gc_Settings);

            bool doingTextureArrays = false;

            if (tb != null && tb.textureBakeResults != null)
            {
                doingTextureArrays = tb.textureBakeResults.resultType == MB2_TextureBakeResults.ResultType.textureArray;
            }
            if (mbSettingsAsset.objectReferenceValue == null)
            {
                meshBakerSettingsMe.DrawGUI(tbg.meshBakerSettings, true, doingTextureArrays);
            }
            else
            {
                if (meshBakerSettingsExternal == null || oldObjVal != mbSettingsAsset.objectReferenceValue)
                {
                    UnityEngine.Object targetObj;
                    string             propertyName;
                    ((MB3_MeshCombinerSettings)mbSettingsAsset.objectReferenceValue).GetMeshBakerSettingsAsSerializedProperty(out propertyName, out targetObj);
                    SerializedProperty meshBakerSettings = new SerializedObject(targetObj).FindProperty(propertyName);
                }

                meshBakerSettingsExternal.DrawGUI(((MB3_MeshCombinerSettings)mbSettingsAsset.objectReferenceValue).data, false, doingTextureArrays);
            }
        }
コード例 #3
0
    public void DrawGrouperInspector()
    {
        EditorGUILayout.HelpBox("This component helps you group meshes that are close together so they can be combined together." +
                                " It generates multiple MB3_MeshBaker objects from the List Of Objects to be combined in the MB3_TextureBaker component." +
                                " Objects that are close together will be grouped together and added to a new child MB3_MeshBaker object.\n\n" +
                                " TIP: Try the new agglomerative cluster type. It's awsome!", MessageType.Info);
        MB3_MeshBakerGrouper grouper = (MB3_MeshBakerGrouper)target;

        EditorGUILayout.PropertyField(clusterType, gc_ClusterType);
        MB3_MeshBakerGrouper.ClusterType gg = (MB3_MeshBakerGrouper.ClusterType)clusterType.enumValueIndex;
        if ((gg == MB3_MeshBakerGrouper.ClusterType.none && !(grouper.grouper is MB3_MeshBakerGrouperNone)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.grid && !(grouper.grouper is MB3_MeshBakerGrouperGrid)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.pie && !(grouper.grouper is MB3_MeshBakerGrouperPie)) ||
            (gg == MB3_MeshBakerGrouper.ClusterType.agglomerative && !(grouper.grouper is MB3_MeshBakerGrouperCluster))
            )
        {
            grouper.CreateGrouper(gg, grouper.data);
            grouper.clusterType = gg;
        }
        if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.grid)
        {
            EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
            EditorGUILayout.PropertyField(cellSize, gc_CellSize);
        }
        else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.pie)
        {
            EditorGUILayout.PropertyField(gridOrigin, gc_GridOrigin);
            EditorGUILayout.PropertyField(numSegments, gc_NumSegements);
            EditorGUILayout.PropertyField(pieAxis, gc_PieAxis);
        }
        else if (clusterType.enumValueIndex == (int)MB3_MeshBakerGrouper.ClusterType.agglomerative)
        {
            float dist    = clusterDistance.floatValue;
            float maxDist = 100f;
            float minDist = .000001f;
            MB3_MeshBakerGrouperCluster cl = null;
            if (grouper.grouper is MB3_MeshBakerGrouperCluster)
            {
                cl      = (MB3_MeshBakerGrouperCluster)grouper.grouper;
                maxDist = cl._ObjsExtents;
                minDist = cl._minDistBetweenClusters;
                if (dist < minDist)
                {
                    dist = Mathf.Lerp(minDist, maxDist, .11f);
                }
            }

            dist = EditorGUILayout.Slider(gc_ClusterDistance, dist, minDist, maxDist);
            clusterDistance.floatValue = dist;

            string btnName = "Refresh Clusters";
            if (cl.cluster == null || cl.cluster.clusters == null || cl.cluster.clusters.Length == 0)
            {
                btnName = "Click To Build Clusters";
            }
            if (GUILayout.Button(btnName))
            {
                if (grouper.grouper is MB3_MeshBakerGrouperCluster)
                {
                    MB3_MeshBakerGrouperCluster cg = (MB3_MeshBakerGrouperCluster)grouper.grouper;
                    MB3_TextureBaker            tb = grouper.GetComponent <MB3_TextureBaker>();
                    if (tb != null)
                    {
                        //MB3_EditorMethods em = new MB3_EditorMethods();
                        cg.BuildClusters(tb.GetObjectsToCombine(), updateProgressBar);
                        EditorUtility.ClearProgressBar();
                        Repaint();
                    }
                }
            }
        }
        EditorGUILayout.PropertyField(clusterOnLMIndex, gc_ClusterOnLMIndex);
        EditorGUILayout.PropertyField(clusterByLODLevel, gc_ClusterByLODLevel);
    }