public override void Deserialize(BinaryReader reader) { path = reader.ReadString(); Scene scene = default(Scene); bool loaded = false; for (int i = EditorSceneManager.sceneCount - 1; i >= 0; i--) { var iscene = EditorSceneManager.GetSceneAt(i); if (iscene.IsValid() && Equals(iscene.path, path)) { scene = iscene; loaded = true; break; } } if (!loaded) { scene = EditorSceneManager.OpenScene(path, SceneManagement.OpenSceneMode.Additive); } var gos = scene.GetRootGameObjects(); var length = reader.ReadInt32(); for (int i = 0; i < length; i++) { goLog.go = gos[i]; goLog.Deserialize(reader); } EditorSceneManager.SaveScene(scene); if (!loaded) { EditorSceneManager.CloseScene(scene, true); } }
public override void Serialize(BinaryWriter writer) { writer.Write(path); Scene scene = default(Scene); bool loaded = false; for (int i = EditorSceneManager.sceneCount - 1; i >= 0; i--) { var iscene = EditorSceneManager.GetSceneAt(i); if (iscene.IsValid() && Equals(iscene.path, path)) { scene = iscene; loaded = true; break; } } if (!loaded) { scene = EditorSceneManager.OpenScene(path, SceneManagement.OpenSceneMode.Additive); } var gos = scene.GetRootGameObjects(); writer.Write(gos.Length); for (int i = 0; i < gos.Length; i++) { goLog.go = gos[i]; goLog.Serialize(writer); } EditorSceneManager.SaveScene(scene); if (!loaded) { EditorSceneManager.CloseScene(scene, true); } }
public override void Translate() { Scene scene = default(Scene); bool loaded = false; for (int i = EditorSceneManager.sceneCount - 1; i >= 0; i--) { var iscene = EditorSceneManager.GetSceneAt(i); if (iscene.IsValid() && Equals(iscene.path, path)) { scene = iscene; loaded = true; break; } } if (!loaded) { scene = EditorSceneManager.OpenScene(path, SceneManagement.OpenSceneMode.Additive); } var gos = scene.GetRootGameObjects(); var collectors = new List <ICollector>(); for (int i = 0; i < gos.Length; i++) { var collector = new GameObjectCollector(); collector.go = gos[i]; collector.Collect(); collectors.Add(collector); } Util.RebindThenTranslate(collectors, sprites); EditorSceneManager.SaveScene(scene); if (!loaded) { EditorSceneManager.CloseScene(scene, true); } }
public override void Collect() { var list = new List <UnityEngine.UI.Sprite>(); Scene scene = default(Scene); bool loaded = false; for (int i = EditorSceneManager.sceneCount - 1; i >= 0; i--) { var iscene = EditorSceneManager.GetSceneAt(i); if (iscene.IsValid() && Equals(iscene.path, path)) { scene = iscene; loaded = true; break; } } if (!loaded) { scene = EditorSceneManager.OpenScene(path, SceneManagement.OpenSceneMode.Additive); } var gos = scene.GetRootGameObjects(); for (int i = 0; i < gos.Length; i++) { var goCollector = new GameObjectCollector(); goCollector.go = gos[i]; goCollector.Collect(); list.AddRange(goCollector.sprites); } EditorSceneManager.SaveScene(scene); if (!loaded) { EditorSceneManager.CloseScene(scene, true); } sprites = list.ToArray(); }