Exemplo n.º 1
0
 public CharacterScanner(CharacterJsonWriter writer)
 {
     if (writer == null)
     {
         this.writer = new CharacterJsonWriter();
     }
     else
     {
         this.writer = writer;
     }
 }
Exemplo n.º 2
0
    public static void ScanAllCharacters()
    {
        var configName     = "skill_anims.json";
        var configFilename = FI.ConfigPath + configName;

        var jsonWriter = new CharacterJsonWriter();

        jsonWriter.WriteObjectStart();

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(
            UnityEditor.SceneManagement.NewSceneSetup.EmptyScene, UnityEditor.SceneManagement.NewSceneMode.Single);

        var all = Directory.GetFiles("Assets/Prefab/characters", "*.prefab", SearchOption.AllDirectories).ToList();

        for (int i = 0; i < all.Count; ++i)
        {
            var filename = all[i];
            EditorUtility.DisplayProgressBar("Scan all characters", "scanning " + filename, (float)i / all.Count);

            var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(filename);
            var name   = System.IO.Path.GetFileNameWithoutExtension(filename);

            if (name.EndsWith("_model"))
            {
                name = name.Substring(0, name.Length - "_model".Length);
            }

            var scanner = new CharacterScanner(jsonWriter);
            scanner.ScanPrefab(name, prefab);

            LogUtil.Debug("Prefab " + filename + " scan success");
        }
        ;

        jsonWriter.WriteObjectEnd();
        jsonWriter.OutputToFile(configFilename);

        LogUtil.Debug("Config " + configFilename + " successfully scanned and generated in game-config folder");
        EditorUtility.ClearProgressBar();
    }