瀏覽代碼

Check if object is a prefab instance

Store instances and their prefabs in the prefab dictionary so we can
process them later
punkoffice 9 年之前
父節點
當前提交
ba60fe8e47
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16 0
      Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.cs

+ 16 - 0
Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.cs

@@ -139,6 +139,22 @@ namespace Unity3D2Babylon
                     continue;
                 }
 
+                // Check if this is a prefab instance
+                GameObject gobjPrefab = (GameObject)PrefabUtility.GetPrefabParent(gameObject);
+                if (gobjPrefab != null)
+                {
+                    //Add prefab to dictionary if it doesn't already exist
+                    if (!dicPrefabs.ContainsKey(gobjPrefab))
+                    {
+                        dicPrefabs[gobjPrefab] = new List<BabylonAbstractMesh>();
+                    }
+
+                    List<BabylonAbstractMesh> lstInstances = dicPrefabs[gobjPrefab];
+                    BabylonAbstractMesh instance = ConvertUnityMeshToInstance(gameObject);
+                    lstInstances.Add(instance);
+                    continue;
+                }
+
                 // Static meshes
                 var meshFilter = gameObject.GetComponent<MeshFilter>();
                 if (meshFilter != null)