Ejemplo n.º 1
0
        public void LoadAll()
        {
            ClearAll();

            _config = ActorConfig.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;
            }

            //--加载行为配置
            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 XmlCfg.Skill.ActorConfig()
                    {
                        ModelName = modelName
                    };
                    string savePath = string.Format("{0}/{1}.xml", ActorConfig.Instance.ActionConfigPath, modelName);
                    var    actor    = new ActorEditor(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 ActorEditor(path);
                AddActor(actor);
            }
            foreach (var item in _modelDict)
            {
                item.Value.InitBaseModelAction();
            }

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

            window.RefreshTree();
            IsInit = true;
            Debug.Log("加载所有动作 完毕!");
        }
Ejemplo n.º 2
0
        private void ModifyModelName()
        {
            var models = new List <string>(CfgManager.Model.Keys);

            models.Remove(ModelName);
            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                _actorCfg.ModelName = name;

                ActorEditorWindow window = ActorEditorWindow.GetWindow <ActorEditorWindow>();
                OdinMenuItem item        = window.MenuTree.Selection.FirstOrDefault();
                item.Name         = name;
                item.SearchString = name;
            });
        }
Ejemplo n.º 3
0
        public void Delete()
        {
            if (EditorUtility.DisplayDialog("删除操作", "确定要删除文件 -> " + ModelName, "确定", "取消"))
            {
                if (File.Exists(_path))
                {
                    File.Delete(_path);
                }

                ActorEditorWindow window = ActorEditorWindow.GetWindow <ActorEditorWindow>();
                OdinMenuItem      item   = window.MenuTree.Selection.FirstOrDefault();
                if (item != null && item.Value != null)
                {
                    ActorEditor model = item.Value as ActorEditor;
                    HomeConfig.Instance.RemoveActor(model);
                    item.Parent.ChildMenuItems.Remove(item);
                    item.MenuTree.Selection.Clear();
                    item.Parent.Select();
                    item.MenuTree.UpdateMenuTree();
                    item.MenuTree.DrawMenuTree();
                }
            }
        }