private void Disassemble() { GameObjectAssembler _assembler = new GameObjectAssembler(); TurretAssemblyAssembler _assemblyAssembler = new TurretAssemblyAssembler(); string path = Paths.StreamingAssets; string name = string.Empty; string data = ""; switch (Type) { case TargetType.Assembly: data = ObjectPipeline.SerializeObject(_assemblyAssembler.Disassemble((Object as GameObject).GetComponent <TurretAssembly>())).ToString(); name = Object.name; break; case TargetType.GameObject: data = ObjectPipeline.SerializeObject(_assembler.Disassemble(Object as GameObject)).ToString(); name = Object.name; break; case TargetType.Object: data = ObjectPipeline.UnbuildObject(Object == null ? Activator.CreateInstance(ReflectionUtils.GetType(_objectTypeName)) : Object, Implicit).ToString(); name = Object == null?_objectTypeName.Replace(".", "") : Object.name; break; } path = path + Path + name + ".json"; File.WriteAllText(path, data); }
public ContentCachedPrefab(RootModel model) { GameObjectAssembler assembler = new GameObjectAssembler(); GameObject instance = assembler.Assemble(model); _cache = new SceneCachedGameObject(instance); }
private ObjectModel[] DisassembleMapObjects() { List <ObjectModel> models = new List <ObjectModel>(); GameObjectAssembler assembler = new GameObjectAssembler(); foreach (Transform child in _mapController.Dependancy.MapObjectParent) { models.Add(assembler.Disassemble(child.gameObject).Root as ObjectModel); } return(models.ToArray()); }
private void Assemble() { GameObjectAssembler _assembler = new GameObjectAssembler(); string path = Paths.StreamingAssets; path += Path; JToken data = JToken.Parse(File.ReadAllText(path)); switch (Type) { case TargetType.GameObject: _assembler.Assemble(ObjectPipeline.DeserializeObject(data)).SetActive(true); break; } Debug.Log(path); }
public static void CompileAsset(string guid, string targetPath, CompilationType type, bool implicitType) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); string directory = Directory.GetParent(targetPath).FullName; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (type == CompilationType.Copy) { File.Copy(assetPath, targetPath, true); return; } object asset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(Object)); JToken json; switch (type) { case CompilationType.SerializeGameObject: GameObjectAssembler assembler = new GameObjectAssembler(); RootModel model = assembler.Disassemble(asset as GameObject); json = ObjectPipeline.SerializeObject(model); break; case CompilationType.SerializeAssembly: TurretAssemblyAssembler tAssembler = new TurretAssemblyAssembler(); RootModel tModel = tAssembler.Disassemble((asset as GameObject).GetComponent <TurretAssembly>()); json = ObjectPipeline.SerializeObject(tModel); break; case CompilationType.SerializeObject: default: json = ObjectPipeline.UnbuildObject(asset, implicitType); break; } File.WriteAllText(Path.ChangeExtension(targetPath, ".json"), json.ToString()); }
private void InstantiateMapObjects() { // Clear for previous map. foreach (GameObject obj in _mapObjects) { Destroy(obj); } _mapObjects.Clear(); // Assembly, duh. GameObjectAssembler assembler = new GameObjectAssembler(); foreach (var obj in MapData.Objects) { _mapObjects.Add(assembler.Assemble(new RootModel(obj))); } // Assign to correct parent. foreach (var obj in _mapObjects) { obj.transform.SetParent(MapObjectParent, true); obj.BroadcastMessage("OnMapObjectAssembled", SendMessageOptions.DontRequireReceiver); } }