From 411470e66bcfd9631c7b6f82b0a00e5e1e1b0004 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Tue, 27 Jun 2023 18:43:09 +0800 Subject: + stage serialize --- .../Assets/Tools/LevelEditor/LevelEditor.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 WorldlineKeepers/Assets/Tools/LevelEditor/LevelEditor.cs (limited to 'WorldlineKeepers/Assets/Tools/LevelEditor/LevelEditor.cs') diff --git a/WorldlineKeepers/Assets/Tools/LevelEditor/LevelEditor.cs b/WorldlineKeepers/Assets/Tools/LevelEditor/LevelEditor.cs new file mode 100644 index 0000000..b9609a5 --- /dev/null +++ b/WorldlineKeepers/Assets/Tools/LevelEditor/LevelEditor.cs @@ -0,0 +1,54 @@ +using LitJson; +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using WK; +using WK.Data; + +public class LevelEditor : EditorWindow +{ + + private static LevelEditor s_LevelEditorWindow; + + private string m_StageOutFile = "Assets/Bundle/stages/"; + + [MenuItem("Tools/¹Ø¿¨±à¼­Æ÷/Open")] + public static void OpenLevelEditor() + { + s_LevelEditorWindow = GetWindow(); + } + + private void OnGUI() + { + m_StageOutFile = GUILayout.TextField(m_StageOutFile); + + if(GUILayout.Button("ÐòÁл¯")) + { + StageMetadata stageMetadata = new StageMetadata(); + + StageEntityBase[] entites = GameObject.FindObjectsOfType(); + if(entites != null && entites.Length > 0) + { + for(int i = 0; i < entites.Length; ++i) + { + StageEntityBase entity = entites[i]; + if (entity == null) + continue; + GameObject go = entity.gameObject; + if (go.name.StartsWith("~")) + continue; + var meta = entity.OnSerialize(); + if(meta != null) + { + stageMetadata.Write(meta); + } + } + } + + string json = JsonMapper.ToJson(stageMetadata); + CommonFunction.WriteFile(json, m_StageOutFile); + } + } + +} -- cgit v1.1-26-g67d0