技能编辑器是用于我们在创建角色后对角色进行编辑的编辑器,属于一种常见的编辑器类型,掌握技能编辑器有利于我们更好的对角色进行改造以及优化。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Newtonsoft.Json;
using System;
using System.IO;public class SkillEditorWindow : EditorWindow
{class PlayerEditor{public int characterIndex = 0;public int folderIndex = 0;public string characterName = string.Empty;public string folderName = string.Empty;public string characterFilter = string.Empty;public List<string> charactList = new List<string>();public Player playerEntity = null;}PlayerEditor player = new PlayerEditor();private List<string> folderList = new List<string>();public List<string> characterList = new List<string>();Dictionary<string, List<string>> folderprefabs = new Dictionary<string, List<string>>();string newSkillName = string.Empty;public string PlayerName = "";public string EnemyName = "";public int SelectIndex = 0;public int SelectEnemyIndex = 0;public int SelectEnemyPrefabIndex = 0;public List<string> SilleEnemys = new List<string>();public List<string> EnemyPrefabs = new List<string>();public string SkillName = null;public string Names = "";SkillWindow skillWindow;[MenuItem("Tools/Skill _%Q")]public static void Init() {if (Application.isPlaying) {var s = GetWindow<SkillEditorWindow>("SkillEditor");if (s != null){s.Show();}} }public void OnEnable(){SerachFolder();GetFileFlder();}private void GetFileFlder(){folderList.Clear();folderList.Add("All");string[] folders = Directory.GetDirectories(GetPath());foreach (var item in folders){folderList.Add(Path.GetFileName(item));}}private void SerachFolder(){string[] FolderbNameas = Directory.GetFiles(GetPath(), "*.prefab", SearchOption.AllDirectories);characterList.Clear();foreach (var item in FolderbNameas){characterList.Add(Path.GetFileNameWithoutExtension(item));}characterList.Sort();characterList.Insert(0, "null");player.charactList.AddRange(characterList);}string GetPath(){return Application.dataPath + "/GameDate/Model";}private void OnGUI(){GUILayout.Button("ChangeCameraParam");GUILayout.Label("Player");GUILayout.BeginHorizontal();PlayerName = GUILayout.TextField(PlayerName, GUILayout.Width(100), GUILayout.Height(20));int folderIndex = EditorGUILayout.Popup(player.folderIndex, folderList.ToArray());if (folderIndex != player.folderIndex){player.folderIndex = folderIndex;player.characterIndex = -1;string folderName = folderList[player.folderIndex];List<string> lists;if (folderName.Equals("all")){lists = characterList;}else{if (!folderprefabs.TryGetValue(folderName, out lists)){lists = new List<string>();string[] files = Directory.GetFiles(GetPath() + "/" + folderName, "*.prefab", SearchOption.AllDirectories);foreach (var item in files){lists.Add(Path.GetFileNameWithoutExtension(item));}folderprefabs[folderName] = lists;}}player.charactList.Clear();player.charactList.AddRange(lists);}SelectIndex = EditorGUILayout.Popup(player.characterIndex,player.charactList.ToArray(), GUILayout.Width(120), GUILayout.Height(20));if (SelectIndex!=player.characterIndex) {player.characterIndex = SelectIndex;if (player.characterName!=player.charactList[player.characterIndex]){player.characterName = player.charactList[player.characterIndex];if (!string.IsNullOrEmpty(player.characterName)) {if (player.playerEntity!=null) {player.playerEntity.Destroy();}player.playerEntity = Player.Init(player.characterName);}}}GUILayout.EndHorizontal();GUILayout.Space(5);GUILayout.Label("Enemy");SilleEnemys.Add("all");SilleEnemys.Add("Enemy");EnemyPrefabs.Add("null");EnemyPrefabs.Add("Teddy");GUILayout.BeginHorizontal();EnemyName = GUILayout.TextField(EnemyName, GUILayout.Width(100), GUILayout.Height(20));SelectEnemyIndex = EditorGUILayout.Popup(SelectEnemyIndex, SilleEnemys.ToArray(), GUILayout.Width(120), GUILayout.Height(20));SelectEnemyPrefabIndex = EditorGUILayout.Popup(SelectEnemyPrefabIndex, EnemyPrefabs.ToArray(), GUILayout.Width(120), GUILayout.Height(20));GUILayout.EndHorizontal();GUILayout.Space(3);GUILayout.Label("New");GUILayout.BeginHorizontal();SkillName= GUILayout.TextField(SkillName, GUILayout.Width(200), GUILayout.Height(20));if (GUILayout.Button("New")) {if (!string.IsNullOrEmpty(SkillName) &&player.playerEntity!=null) {List<SkillBase> skills = player.playerEntity.AddNewSkills(SkillName);SkillName = "";}}GUILayout.EndHorizontal();GUILayout.Space(3);GUILayout.BeginHorizontal();if (GUILayout.Button("Sa ve", GUILayout.Width(110), GUILayout.Height(20))){player.playerEntity.SaveSkill();}if (GUILayout.Button("Save As", GUILayout.Width(110), GUILayout.Height(20))){}if (GUILayout.Button("Delete", GUILayout.Width(110), GUILayout.Height(20))){}GUILayout.EndHorizontal();GUILayout.BeginHorizontal();GUILayout.Label("ActFilter");Names= GUILayout.TextField(Names, GUILayout.Width(100), GUILayout.Height(20));GUILayout.EndHorizontal();if (player.playerEntity!=null) {Pos = GUILayout.BeginScrollView(Pos, false, true);foreach (var item in player.playerEntity.skillList){GUILayout.BeginHorizontal();if (GUILayout.Button(item.Key)){Names = item.Key;List<SkillBase> skillComponet = player.playerEntity.GetSkill(item.Key);foreach (var ite in skillComponet){ite.Init();}OpenSkillWindow(item.Key, skillComponet);}GUILayoutOption[] options = new GUILayoutOption[]{GUILayout.Width(60),GUILayout.Height(20)};if (GUILayout.Button("删除技能",options)){player.playerEntity.RemoveSkill(item.Key);break;}GUILayout.EndHorizontal();}GUILayout.EndScrollView();}}Vector2 Pos = new Vector2(0, 0);private void OpenSkillWindow(string skillName, List<SkillBase> skillCompoent){if (skillCompoent != null){if (skillWindow == null){skillWindow = GetWindow<SkillWindow>("");}skillWindow.titleContent = new GUIContent(skillName);skillWindow.SetiniySkill(skillCompoent, player.playerEntity);skillWindow.Show();skillWindow.Repaint();}}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;public class SkillWindow : EditorWindow
{string[] skills =new string[] { "低", "中", "高" };string[] comos = new string[] { "null","动画", "特效","音效" };List<SkillBase> skillComPonents=new List<SkillBase>();public List<string> FolderList = new List<string>();public int SelectIndex = 0;public int Folderindex = 0;public float speed = 1;public float speed1 = 0;public bool isok = true;public bool isOpen = true;public string str = "AnimationQueue";Player _player;public AnimationClip anim;public Skill_Anim Anim;public void SetiniySkill(List<SkillBase> skillCompoent,Player player){_player = player;speed = 1;skillComPonents = skillCompoent;_player.currSkillComponts = skillComPonents;}private void OnGUI(){FolderList.Add(null);GUILayout.BeginHorizontal();if (GUILayout.Button("播放", GUILayout.Width(130), GUILayout.Height(20))){foreach (var item in skillComPonents){item.Play();}}if (GUILayout.Button("停止", GUILayout.Width(130), GUILayout.Height(20))){foreach (var item in skillComPonents){item.Stop();}}GUILayout.EndHorizontal();GUILayout.BeginHorizontal();_player.times = GUILayout.TextField(_player.times);GUILayout.EndHorizontal();GUILayout.BeginHorizontal();_player.quanzhong = GUILayout.TextField(_player.quanzhong);GUILayout.EndHorizontal();GUILayout.BeginHorizontal();GUILayout.Label("特效等级");SelectIndex = EditorGUILayout.Popup(SelectIndex, skills, GUILayout.Width(120), GUILayout.Height(20));GUILayout.EndHorizontal();    GUILayout.BeginHorizontal();GUILayout.Label("播放速度");float Speed=EditorGUILayout.Slider(speed, 0, 3);if (Speed!= speed){speed = Speed;Time.timeScale = speed;}GUILayout.EndHorizontal();GUILayout.BeginHorizontal();GUILayout.Label("动画时间轴");GUILayout.Label(speed1.ToString(), GUILayout.Width(50));float value = GUILayout.HorizontalSlider((float)Math.Round(speed1, 2), 0, 3);if (Mathf.Abs(value - speed1) > 0.001){speed1 = value;}//speed1 = EditorGUILayout.Slider(speed1, 0, 5);//if (Mathf.Abs()) //{//}GUILayout.EndHorizontal();GUILayout.Space(3);GUILayout.BeginHorizontal();Folderindex = EditorGUILayout.Popup(Folderindex, comos, GUILayout.Width(120), GUILayout.Height(20));if (GUILayout.Button("添加", GUILayout.Width(100), GUILayout.Height(20))){switch (Folderindex){case 1:skillComPonents.Add(new Skill_Anim(_player));break;case 2:skillComPonents.Add(new Skill_Effects(_player));break;case 3:skillComPonents.Add(new Skill_Audio(_player));break;default:break;}}GUILayout.EndHorizontal();isok = EditorGUILayout.Toggle("全部展开", isok);if (isok) {isOpen=EditorGUILayout.Foldout(isOpen, str);Pos = GUILayout.BeginScrollView(Pos, false, true);foreach (var item in skillComPonents){GUILayout.BeginHorizontal();GUILayout.Label(item.name);if (GUILayout.Button("删除")) {skillComPonents.Remove(item);break;}GUILayout.EndHorizontal();if (item is Skill_Anim) {ShowSkill_Anim(item as Skill_Anim);}if (item is Skill_Effects){ShowSkill_Effect(item as Skill_Effects);}if (item is Skill_Audio){ShowSkill_Audio(item as Skill_Audio);}}GUILayout.EndScrollView();}}Vector2 Pos = new Vector2(0, 0);void ShowSkill_Anim(Skill_Anim _Anim) {_Anim.trigger = EditorGUILayout.TextField(_Anim.trigger);AnimationClip clip = EditorGUILayout.ObjectField(_Anim.clip, typeof(AnimationClip), false) as AnimationClip;if (_Anim.clip!=clip) {_Anim.SetAnimClip(clip);}}void ShowSkill_Effect(Skill_Effects _Effect){_Effect.trigger = EditorGUILayout.TextField(_Effect.trigger);GameObject game = EditorGUILayout.ObjectField(_Effect.game, typeof(GameObject), false) as GameObject;if (_Effect.game != game){_Effect.SetGameClip(game);}}void ShowSkill_Audio(Skill_Audio _Audio){_Audio.trigger = EditorGUILayout.TextField(_Audio.trigger);AudioClip clip = EditorGUILayout.ObjectField(_Audio.clip, typeof(AudioClip), false) as AudioClip;if (_Audio.clip != clip){_Audio.SetAudioClip(clip);}}
}

上面这段代码是用于对技能进行更精确的编辑时所使用的。

下面展示一下具体的效果:

技能编辑器大致效果就是在创建角色时进行编辑操作。

下面附上完整项目,

Skill_Editor.zip-Unity3D文档类资源-CSDN下载

Unity技能编辑器(特效,音效)相关推荐

  1. 基于Unity编辑器开发技能编辑器(一)

    编辑器拓展介绍 常见的Unity编辑器拓展使用主要是创建自定义的窗体进行使用,包括剧情编辑器,动画编辑器,技能编辑器等等.最常使用的就是 EditorGUI,EditorGUILayout,GUI. ...

  2. ACT技能编辑器的制作经验

    这是侑虎科技第407篇文章,感谢作者Gordon供稿.欢迎转发分享,未经作者授权请勿转载.如果您有任何独到的见解或者发现也欢迎联系我们,一起探讨.(QQ群465082844) 作者知乎:https:/ ...

  3. win32_bios 的对象编辑器无法保存对象_技能编辑器设计文档

    设计目的 l 提高技能编辑的可视性,减少技能编辑时间. l 提高技能效果的精度. l 积累技能效果库. 适用范围 l 可用于回合游戏的技能编辑 l 可用于动作游戏的技能编辑 l 可用户moba类游戏的 ...

  4. 如何通过Timeline的形式实现技能编辑器

    1)如何通过Timeline的形式实现技能编辑器 ​2)Addressable如何通过Group Name获得Group下的Key 3)Unity如何获取Sprite在Sprite Packer中的U ...

  5. 在虚幻引擎5中构建你的首款游戏 - 10[完] - 特效音效镜头震动打包

    在虚幻引擎5中构建你的首款游戏 - 10[完] - 特效&音效&镜头震动&打包 前言介绍: 原版地址: << [功能亮点]在虚幻引擎5中构建你的首款游戏(官方字幕) ...

  6. Unity技能系统框架(三)分析一个具体被动技能

    这一篇分析一个具体的被动技能:蚁人的影矛 首先看下技能描述:"每个蚁人都是天生的掷手,投掷出长矛刺穿目标的身躯.普通攻击有几率对攻击范围内其他{0}名目标进行相同攻击.",只要是个 ...

  7. Unity技能工厂——怎样实现丝滑的角色连击动画

    RPG类型的动作游戏因为其敏捷的工作动作,技能连招之间丝滑的衔接,视觉冲击感爆棚的技能释放特效,所谓"拳拳刀肉,刀刀进身"的攻击效果,吸引了一大批忠实角色类扮演游戏的忠实粉丝. 那 ...

  8. Unity 3D 环境特效||Unity 3D 游戏场景设计实例

    Unity 3D 环境特效 一般情况下,要在游戏场景中添加雾特效和水特效较为困难,因为需要开发人员懂得着色器语言且能够熟练地使用它进行编程. Unity 3D 游戏开发引擎为了能够简单地还原真实世界中 ...

  9. unity技能框架_如何使用指导框架学习新技能

    unity技能框架 Last October I created a Mentoring Framework at work. The goal was to create a project fro ...

最新文章

  1. 图的单源最短路径:Dijkstra算法实现
  2. python与编码方式
  3. excel里面如果有filter就不能直接sum,要复制转换一下
  4. Normalization
  5. wxWidgets:键盘 wxWidgets 示例
  6. java例程练习(一维数组)
  7. 数据库中的数据类型和c#的数据类型的映射表(转)
  8. 厉害插件_2个相见恨晚的浏览器插件,让你的工作效率提升100%
  9. 基于SpringBoot的答题系统
  10. tomcat、redis session共存配置
  11. DHCP工作原理和报文格式
  12. win10任务栏开始菜单等系统图标点击无反应的解决方法
  13. 语音合成芯片——SYN6658
  14. 帮助文档.chm能打开但是显示不出来详细内容
  15. Android开源项目大合集(转载的基础上添加了项目地址)
  16. RTMP、RTSP、m3u8、flv 区别及含义
  17. NLP入门开源实践总结
  18. 最近很火的在线文件预览txt、doc、ppt、pdf、excel、jpg、png、zip、tar.gz等各种文件及压缩文件在线解压和预览,包括前后端设计和源码,编写搜索引擎多关键词检索名称和内容(四)
  19. 2019江西省赛F - String
  20. js平滑滚动元素进入视图

热门文章

  1. 联想居然把IBM的个人电脑和笔记本事业群合并了
  2. 蓝桥杯2022年B组初赛题解C++(待完善)
  3. DENSO GT-10Q-SU条码扫描器如何恢复出厂设置?
  4. SQL,SP与ORM
  5. NEXYS4_DDR迪芝伦XC7A100TCSG324-1型,ADT7420测温
  6. dajngo_itsdjangerous_itsdangerous.exc.BadSignature: Signature bXXXXX' does not match
  7. 欧盟商标和马德里商标有什么区别?
  8. 贝叶斯优化python包_《用贝叶斯优化进行超参数调优》
  9. 2021年职称计算机考试模块,2021高级职称计算机考试需要考哪些模块?
  10. javaOA办公系统设计与实现计算机毕业设计MyBatis+系统+LW文档+源码+调试部署