public void ExportMethod() { var path = AssetDatabase.GetAssetPath(skill); var dirInfo = new DirectoryInfo(Path.GetDirectoryName(path)); var allNpc = dirInfo.GetFiles("*.prefab", SearchOption.AllDirectories); var jDict = new JSONClass(); foreach (var n in allNpc) { var p = Util.FullPathToUnityPath(n.FullName); Debug.LogError(n.FullName + ":" + p); var sk = AssetDatabase.LoadAssetAtPath <GameObject>(p); var jobj = EntityConfigExport.ExportGo(sk); jDict.Add(sk.name, jobj); } var etyPath = Path.Combine(Application.dataPath, "../../tankServer/SocketServer/ConfigData/AllSkill.json"); //var file = Path.Combine(etyPath, skill.name + ".json"); if (File.Exists(etyPath)) { File.Delete(etyPath); } var s = jDict.ToString(); File.WriteAllText(etyPath, s); Debug.LogError("导出配置: " + etyPath); }
public void ExportMethod() { var path = AssetDatabase.GetAssetPath(allNpcConfig); var dirInfo = new DirectoryInfo(Path.GetDirectoryName(path)); var allNpc = dirInfo.GetFiles("*.prefab", SearchOption.AllDirectories); //var allStr = new JSONArray(); var go = new GameObject("AllSoldier"); //var lists = go.AddComponent<ListConfig>(); //lists.lists = new List<GameObject>(); foreach (var n in allNpc) { var p = Util.FullPathToUnityPath(n.FullName); Debug.LogError(n.FullName + ":" + p); var npc = AssetDatabase.LoadAssetAtPath <GameObject>(p); //lists.lists.Add(npc); var nn = GameObject.Instantiate <GameObject>(npc); nn.transform.parent = go.transform; Util.InitGameObject(nn); //Debug.LogError(jobj.ToString()); //allStr.Add(jobj); } var jobj = EntityConfigExport.ExportGo(go); var etyPath = Path.Combine(Application.dataPath, "../../tankServer/SocketServer/ConfigData/"); var file = Path.Combine(etyPath, go.name + ".json"); if (File.Exists(file)) { File.Delete(file); } var s = jobj.ToString(); File.WriteAllText(file, s); Debug.LogError("导出配置: " + file); GameObject.DestroyImmediate(go); }