Esempio n. 1
0
        private static void Open()
        {
            var window = GetWindow <ActorCfgWindow>("模型配置窗口");

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500);
            window.minSize  = new Vector2(400, 500);
            ActionHomeConfig.LoadInstanceIfAssetExists();
            HomeConfig.Instance.LoadAll();
        }
Esempio n. 2
0
        public void LoadAll()
        {
            ClearAll();

            _config = ActionHomeConfig.Instance;
            CfgManager.ConfigDir = ConfigDir;
            CfgManager.LoadAll();

            //--初始化资源路径
            EUtil.GetAssetsInSubFolderRecursively(_config.CharacterRelativeDir, "*.prefab", ref AllCharacters);
            EUtil.GetAssetsInSubFolderRecursively(_config.AvatarRelativeDir, "*.prefab", ref AllAvatars);
            EUtil.GetAssetsInSubFolderRecursively(_config.EffectRelativeDir, "*.prefab", ref AllEffects);
            foreach (var item in AllCharacters)
            {
                string searchDir = item.Value.Substring(0, item.Value.LastIndexOf(@"/prefab")) + "/clips";
                var    selfClips = new Dictionary <string, string>();
                EUtil.GetAssetsInSubFolderRecursively(searchDir, "*.anim", ref selfClips);
                AllCharacterClips[item.Key] = selfClips;
            }

            //--初始化资源
            SequenceRoot     = ActorHelper.CreateGameObject("---行为序列---");
            RuntimeAssetRoot = ActorHelper.CreateGameObject("---运行时资源---");

            CharacterDir = ActorHelper.CreateGameObject("Characters", "/---运行时资源---/");
            EffectDir    = ActorHelper.CreateGameObject("Effects", "/---运行时资源---/");
            OtherDir     = ActorHelper.CreateGameObject("Others", "/---运行时资源---/");

            //--加载行为配置
            foreach (var model in CfgManager.Model)
            {
                var    modelName = model.Key;
                string path      = string.Format("{0}/{1}.xml", ActionConfigPath, modelName);
                if (!File.Exists(path))
                {
                    var config = new ActorConfig()
                    {
                        ModelName = modelName
                    };
                    string savePath = string.Format("{0}/{1}.xml", ActionHomeConfig.Instance.ActionConfigPath, modelName);
                    var    actor    = new ActorConfigEditor(savePath, config);
                    actor.Save(true);
                    Debug.LogFormat("<color=orange>新建Actor - {0}</color>", modelName);
                }
            }

            string[] files = Directory.GetFiles(ActionConfigPath, "*.xml", SearchOption.TopDirectoryOnly);
            foreach (var path in files)
            {
                var actor = new ActorConfigEditor(path);
                AddActor(actor);
            }
            foreach (var item in _modelDict)
            {
                item.Value.InitBaseModelAction();
            }

            var window = ActorCfgWindow.GetWindow <ActorCfgWindow>();

            window.RefreshTree();
            IsInit = true;
            Debug.Log("加载所有动作 完毕!");
        }