public static gameObjectSimulator gameObjectToSimulator(GameObject go) { saveMe savME = go.GetComponent <saveMe>(); if (savME != null) { gameObjectSimulator goS = new gameObjectSimulator(); goS.position = go.transform.position; goS.rotation = go.transform.rotation; goS.scale = go.transform.localScale; goS.objectName = go.name; goS.objectType = go.GetType().ToString(); // get scipts attached to the object... lolnope :*( /*foreach (var component in go.GetComponents<Component>()) { * if (savME.scriptAllowed(component.ToString())) { * goS.subScripts.Add(component); * } * }*/ return(goS); } return(null); }
public static GameObject simulatorToGameObject(gameObjectSimulator goS) { loadAllPrefabs(); foreach (GameObject prefab in allPrefabs) { //if (prefab.name == goS.objectName) { //(Clone) // contains MIGHT be dangerous... AGAIN!? if (goS.objectName.Contains(prefab.name)) { //Instantiate(global::UnityEngine.Object) - C:\Users\Gamer\Dropbox\Source\c#\objectSerializer\serializerTest\Library\UnityAssemblies\UnityEngine.dll return((GameObject)UnityEngine.Object.Instantiate(prefab, goS.position, goS.rotation)); } } return(null); }
public void doSave() { serializedObjects.Clear(); object[] objects = GameObject.FindObjectsOfType(typeof(GameObject)); foreach (object obj in objects) { GameObject go = (GameObject)obj; //Debug.Log(g.name); serializer.gameObjectSimulator gSim = serializer.clsHelper.gameObjectToSimulator(go); if (gSim != null) { string xml = serializer.clsSerializer.SerializeToString <serializer.gameObjectSimulator>(gSim); serializedObjects.Add(xml); Debug.Log(xml); } } }