public static JsonProject fromObjects(GameObject[] obj, bool showGui) { var result = new JsonProject(); var scene = JsonScene.fromObjects(obj, result.resourceMapper, showGui); result.scenes.Add(scene); return(result); }
public static JsonScene fromObjects(GameObject[] args, ResourceMapper resMap, bool showGui) { try{ var result = new JsonScene(); var objMap = new GameObjectMapper(); foreach (var curObj in args) { objMap.gatherObjectIds(curObj); } foreach (var curObj in objMap.objectList) { resMap.gatherPrefabData(curObj); } for (int i = 0; i < objMap.objectList.Count; i++) { /*TODO: The constructor CAN add more data, but most of it would've been added prior to this point. * Contempalting whether to enforce it strictly or not.*/ if (showGui) { ExportUtility.showProgressBar("Collecting scene data", string.Format("Adding scene object {0}/{1}", i, objMap.numObjects), i, objMap.objectList.Count); } var newObj = new JsonGameObject(objMap.objectList[i], objMap, resMap); result.objects.Add(newObj); } return(result); } finally{ if (showGui) { ExportUtility.hideProgressBar(); } } }
public JsonScene exportObjects(GameObject[] args) { var result = new JsonScene(); foreach (var cur in args) { if (!cur) { continue; } objects.getId(cur); } for (int i = 0; i < objects.objectList.Count; i++) { result.objects.Add(new JsonGameObject(objects.objectList[i], this)); } foreach (var cur in meshes.objectList) { result.meshes.Add(new JsonMesh(cur, this)); } foreach (var cur in materials.objectList) { result.materials.Add(new JsonMaterial(cur, this)); } foreach (var cur in textures.objectList) { result.textures.Add(new JsonTexture(cur, this)); } result.resources = new List <string>(resources); result.resources.Sort(); return(result); }
bool addSceneAsset(AssetInfo asset, bool showGui, Logger logger) { Logger.makeValid(ref logger); //AssetDatabase.LoadAllAssetsAtPath(asset.path); var mainAsset = AssetDatabase.LoadMainAssetAtPath(asset.path); var sceneAsset = mainAsset as SceneAsset; if (!mainAsset || !sceneAsset) { logger.logErrorFormat("Could not get scene at path {0}({1})", asset.path, asset.guid); return(true); } var scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene( asset.path, UnityEditor.SceneManagement.OpenSceneMode.Single); var jsonScene = JsonScene.fromScene(scene, resourceMapper, false); scenes.Add(jsonScene); //EditorSceneManagement. //var scene = sceneAsset as Scene; logger.logFormat("Loading scene: \"{0}\"", sceneAsset.name); return(true); }