public void LoadWorld() { WorldProfile w_profile = WorldProfile.Load(); if (w_profile == null) { w_profile = new WorldProfile(); } Dictionary <string, Transform> trans_index = FindDirectChildren(); Debug.Log("w_profile is" + w_profile); for (int i = 0; i < w_profile.saved_object_list.Count; i++) { WorldSaveObjectData wsod = w_profile.saved_object_list[i]; if (wsod != null) { Transform parent = trans_index[wsod.parent_trans]; GameObject restore_object = wsod.ToGameObject(parent); WorldSaveObject mono_wso = restore_object.GetComponent <WorldSaveObject>(); mono_wso.GUID = wsod.GUID; mono_wso.Load(wsod); } } }
public override void OnInspectorGUI() { if (owner == null) { owner = target as WorldManager; } if (owner != null) { EditorGUILayout.LabelField("Profile: " + WorldProfile.GetProfilePath(true)); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("SaveWorld")) { owner.SaveWorld(); } if (GUILayout.Button("ClearWorld")) { if (EditorUtility.DisplayDialog("Warning!", "This will remove all WorldSaveObjects. Are you sure?", "Im sure", "Nooooops!")) { owner.ClearWorld(); } } if (GUILayout.Button("LoadWorld")) { owner.LoadWorld(); } EditorGUILayout.EndHorizontal(); } }
public void SaveWorld() { WorldSaveObject[] wsos = GetComponentsInChildren <WorldSaveObject>(); WorldProfile w_profile = new WorldProfile(); w_profile.BeginSave(); for (int i = 0; i < wsos.Length; i++) { if (wsos[i] != null) { w_profile.Append(wsos[i].Save()); } } w_profile.EndSave(); }