Exemple #1
0
 public void Initiate()
 {
     SkillEditTempData.copyItem         = null;
     SkillEditTempData.editingItem      = null;
     SkillEditTempData.editingItemCache = null;
     SkillEditTempData.editingSkill     = null;
     Type[] typelist = SkillEditorUtility.GetAllClasses();
     SkillEditorUtility.timeLineTypes.Clear();
     SkillEditorUtility.actionTypes.Clear();
     foreach (Type t in typelist)
     {
         if (typeof(BaseAction).IsAssignableFrom(t))
         {
             SkillEditorUtility.actionTypes.Add(t);
         }
         else if (typeof(TimeLine).IsAssignableFrom(t))
         {
             SkillEditorUtility.timeLineTypes.Add(t);
         }
         else if (typeof(Skill).IsAssignableFrom(t))
         {
             SkillEditorUtility.skillTypes.Add(t);
         }
         else if (typeof(Buff).IsAssignableFrom(t))
         {
             SkillEditorUtility.buffTypes.Add(t);
         }
         else if (typeof(Logic.Skill.Event).IsAssignableFrom(t))
         {
             SkillEditorUtility.eventTypes.Add(t);
         }
     }
     fileInfos.Clear();
     _runtimeOperatePanel = new ERuntimeOperatePanel();
     _actionDetailPanel   = new EShowActionDetailPanel();
     GetFiles(SkillUtility.GetRequiredConfigsPath(), fileInfos, null);
     SkillEditTempData.settingTex = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/Image/setting.png");
 }
    void OnGUI()
    {
        var popups = new List <string>();

        for (int i = 0; i < SkillEditorUtility.skillTypes.Count; i++)
        {
            var type = SkillEditorUtility.skillTypes[i];
            popups.Add(type.FullName);
        }
        for (int i = 0; i < SkillEditorUtility.buffTypes.Count; i++)
        {
            var type = SkillEditorUtility.buffTypes[i];
            popups.Add(type.FullName);
        }
        for (int i = 0; i < SkillEditorUtility.eventTypes.Count; i++)
        {
            var type = SkillEditorUtility.eventTypes[i];
            popups.Add(type.FullName);
        }
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        GUILayout.Label("名字");
        skillname = GUILayout.TextField(skillname, GUILayout.MinWidth(100));
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("ID");
        id = GUILayout.TextField(id, GUILayout.MinWidth(100));
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("路径");
        skillpath = GUILayout.TextField(skillpath, GUILayout.MinWidth(100));
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("创建类型");
        selectedIndex = EditorGUILayout.Popup(selectedIndex, popups.ToArray());
        //  tgType = (TimelingGroupType)EditorGUILayout.EnumPopup(tgType, GUILayout.MinWidth(100));
        GUILayout.EndHorizontal();
        int id_int = 0;

        if (!string.IsNullOrEmpty(id) && int.TryParse(id, out id_int) && !string.IsNullOrEmpty(skillname) && !string.IsNullOrEmpty(skillpath) && (GUILayout.Button("创建")))
        {
            string                 path     = "";
            TimeLineGroup          tg       = null;
            JsonSerializerSettings settings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };
            Type t = null;
            if (selectedIndex < SkillEditorUtility.skillTypes.Count)
            {
                tgType = TimelingGroupType.SKILL;
                t      = SkillEditorUtility.skillTypes[selectedIndex];
            }
            else if (selectedIndex < (SkillEditorUtility.skillTypes.Count + SkillEditorUtility.buffTypes.Count))
            {
                tgType = TimelingGroupType.BUFF;
                t      = SkillEditorUtility.buffTypes[selectedIndex - SkillEditorUtility.skillTypes.Count];
            }
            else
            {
                tgType = TimelingGroupType.EVENT;
                t      = SkillEditorUtility.eventTypes[selectedIndex - SkillEditorUtility.skillTypes.Count - SkillEditorUtility.buffTypes.Count];
            }
            tg = Create(t);
            if (tgType == TimelingGroupType.SKILL)
            {
                path += "Skills/";
                path += "skill_" + skillpath + ".bytes";
            }
            else if (tgType == TimelingGroupType.BUFF)
            {
                path += "Buffs/";
                path += "buff_" + skillpath + ".bytes";
            }
            else if (tgType == TimelingGroupType.EVENT)
            {
                path += "Events/";
                path += "event_" + skillpath + ".bytes";
            }
            string finalPath = SkillUtility.GetRequiredConfigsPath() + path;
            SkillUtility.SaveTimelineGroup(tg, finalPath);
            SkillUtility.SaveToSkillIndexFile(tg, path);
            skillWindow.OnCreate();
            Close();
        }
        GUILayout.EndVertical();
    }