public static void MigrateMultiMeshBakerToVersion3Component(GameObject go)
    {
        MB2_MultiMeshBaker tb2 = go.GetComponent <MB2_MultiMeshBaker>();

        if (tb2 == null)
        {
            return;
        }
        Debug.Log("Migrating Mesh Baker");
        MB3_MultiMeshBaker tb3 = go.AddComponent <MB3_MultiMeshBaker>();

        tb3.textureBakeResults          = tb2.textureBakeResults;
        tb3.bakeAssetsInPlaceFolderPath = tb2.bakeAssetsInPlaceFolderPath;
        tb3.objsToMesh   = tb2.objsToMesh;
        tb3.resultPrefab = tb2.resultPrefab;
        tb3.useObjsToMeshFromTexBaker      = tb2.useObjsToMeshFromTexBaker;
        tb3.meshCombiner.doCol             = tb2.doCol;
        tb3.meshCombiner.doNorm            = tb2.doNorm;
        tb3.meshCombiner.doTan             = tb2.doTan;
        tb3.meshCombiner.doUV              = tb2.doUV;
        tb3.meshCombiner.doUV1             = tb2.doUV1;
        tb3.meshCombiner.lightmapOption    = tb2.lightmapOption;
        tb3.meshCombiner.outputOption      = tb2.outputOption;
        tb3.meshCombiner.resultSceneObject = tb2.resultSceneObject;
        tb3.meshCombiner.renderType        = tb2.renderType;

        DestroyImmediate(tb2);
    }
Ejemplo n.º 2
0
 public static void RebuildPrefab(MB2_MeshBakerCommon mom)
 {
     if (MB2_MeshCombiner.EVAL_VERSION)
     {
         return;
     }
     if (mom is MB2_MeshBaker)
     {
         MB2_MeshBaker mb         = (MB2_MeshBaker)mom;
         GameObject    prefabRoot = mom.resultPrefab;
         GameObject    rootGO     = (GameObject)PrefabUtility.InstantiatePrefab(prefabRoot);
         mb.meshCombiner.buildSceneMeshObject(rootGO, mb.meshCombiner.GetMesh(), true);
         string prefabPth = AssetDatabase.GetAssetPath(prefabRoot);
         PrefabUtility.ReplacePrefab(rootGO, AssetDatabase.LoadAssetAtPath(prefabPth, typeof(GameObject)), ReplacePrefabOptions.ConnectToPrefab);
         Editor.DestroyImmediate(rootGO);
     }
     else if (mom is MB2_MultiMeshBaker)
     {
         MB2_MultiMeshBaker mmb        = (MB2_MultiMeshBaker)mom;
         GameObject         prefabRoot = mom.resultPrefab;
         GameObject         rootGO     = (GameObject)PrefabUtility.InstantiatePrefab(prefabRoot);
         for (int i = 0; i < mmb.meshCombiner.meshCombiners.Count; i++)
         {
             mmb.meshCombiner.meshCombiners[i].combinedMesh.buildSceneMeshObject(rootGO, mmb.meshCombiner.meshCombiners[i].combinedMesh.GetMesh(), true);
         }
         string prefabPth = AssetDatabase.GetAssetPath(prefabRoot);
         PrefabUtility.ReplacePrefab(rootGO, AssetDatabase.LoadAssetAtPath(prefabPth, typeof(GameObject)), ReplacePrefabOptions.ConnectToPrefab);
         Editor.DestroyImmediate(rootGO);
     }
     else
     {
         Debug.LogError("Argument was not a MB2_MeshBaker or an MB2_MultiMeshBaker.");
     }
 }
    public override void OnInspectorGUI()
    {
        MB2_MultiMeshBaker tb = (MB2_MultiMeshBaker)target;

        if (GUILayout.Button(" MIGRATE COMPONENTS TO VERSION 3 "))
        {
            GameObject go = tb.gameObject;
            MigrateMultiMeshBakerToVersion3Component(go);
            MB2_TextureBakerEditor.MigrateTestureBakerToVersion3Component(go);
            MB2_MeshBakerEditor.MigrateMeshBakerToVersion3Component(go);
        }

        mbe.OnInspectorGUI((MB2_MeshBakerCommon)target, typeof(MB_MeshBakerEditorWindow));
    }
Ejemplo n.º 4
0
 public static void SaveMeshsToAssetDatabase(MB2_MeshBakerCommon mom, string folderPath, string newFileNameBase)
 {
     if (MB2_MeshCombiner.EVAL_VERSION)
     {
         return;
     }
     if (mom is MB2_MeshBaker)
     {
         MB2_MeshBaker mb          = (MB2_MeshBaker)mom;
         string        newFilename = newFileNameBase + ".asset";
         string        ap          = AssetDatabase.GetAssetPath(mb.meshCombiner.GetMesh());
         if (ap == null || ap.Equals(""))
         {
             Debug.Log("Saving mesh asset to " + newFilename);
             AssetDatabase.CreateAsset(mb.meshCombiner.GetMesh(), newFilename);
         }
         else
         {
             Debug.Log("Mesh is an asset at " + ap);
         }
     }
     else if (mom is MB2_MultiMeshBaker)
     {
         MB2_MultiMeshBaker mmb = (MB2_MultiMeshBaker)mom;
         for (int i = 0; i < mmb.meshCombiner.meshCombiners.Count; i++)
         {
             string newFilename = newFileNameBase + i + ".asset";
             Mesh   mesh        = mmb.meshCombiner.meshCombiners[i].combinedMesh.GetMesh();
             string ap          = AssetDatabase.GetAssetPath(mesh);
             if (ap == null || ap.Equals(""))
             {
                 Debug.Log("Saving mesh asset to " + newFilename);
                 AssetDatabase.CreateAsset(mesh, newFilename);
             }
             else
             {
                 Debug.Log("Mesh is an asset at " + ap);
             }
         }
     }
     else
     {
         Debug.LogError("Argument was not a MB2_MeshBaker or an MB2_MultiMeshBaker.");
     }
 }