public static void FH_CreateColliders(GameObject obj, string vrmlText, bool isBatchMode)
{
if (obj == null)
return;
if (UnityEditor.PrefabUtility.GetPrefabType(obj) == UnityEditor.PrefabType.ModelPrefab)
{
Debug.LogWarningFormat("{0} is a model prefab and can't be edited to have meshes", obj.name);
return;
}
InBatchSaveMode = isBatchMode;
GameObject prefab = UnityEditor.PrefabUtility.FindPrefabRoot(obj) as GameObject;
GameObject createdInstance = null;
if (prefab != null && UnityEditor.PrefabUtility.GetPrefabType(obj) == UnityEditor.PrefabType.Prefab)
{
// Since we can't modify prefabs directly, we'll instantiate it first and modify that instead
createdInstance = UnityEditor.PrefabUtility.InstantiatePrefab(prefab) as GameObject;
Debug.LogFormat("{0} is prefab", obj.name, UnityEditor.PrefabUtility.GetPrefabType(createdInstance));
obj = createdInstance;
}
else
{
Debug.LogFormat("{0} is not prefab: {1}", obj.name, UnityEditor.PrefabUtility.GetPrefabType(obj));
}
shouldCancelBatch = false;
ProgressDelegate progressBar = new ConcaveCollider.ProgressDelegate(CreateProgressBar(FH_Cancel));
if (vrmlText != null)
{
FH_CreateHullsFromVrml(obj, vrmlText, progressBar);
UnityEditor.EditorUtility.ClearProgressBar();
}
else
{
MeshFilter [] foundMeshFilters = obj.GetComponentsInChildren<MeshFilter>();
if (foundMeshFilters == null || foundMeshFilters.Length == 0)
FH_ComputeHulls(obj, progressBar);
else
{
foreach(MeshFilter curMeshFilter in foundMeshFilters)
FH_ComputeHulls(curMeshFilter.gameObject, progressBar);
}
}
shouldCancelBatch = false;
if (createdInstance != null)
{
UnityEditor.PrefabUtility.ReplacePrefab(createdInstance, prefab);
DestroyImmediate(createdInstance);
}
InBatchSaveMode = false;
}