public static void LoadSkillAssetData()
        {
            string path = EditorUtility.OpenFilePanel("Load SkillArt", Application.dataPath + "/" + "Asset", "asset");

            if (path.Length != 0)
            {
                path = "Assets" + path.Replace(Application.dataPath, "");
                EditorDataContainer.LoadSkillArt(path);
            }
        }
        public static void UseSkillArt(SkillUnit.SkillArt oart)
        {
            SkillArt art = EditorDataContainer.currentskillAssetData.skillArt;

            DataConvert.ConvertSkillArt(art, oart);

            string effectName = EditorDataContainer.GetStringById(oart.unitEffect.effect);

            if (art.unitEffect == null)
            {
                art.unitEffect = new List <SkillEffectUnit>();
            }
            if (art.unitEffect.Count == 0)
            {
                art.unitEffect.Add(new SkillEffectUnit());
            }
            art.unitEffect[0].artEffect.effectObj = AssetUtility.GetSkillEffect(art.modelType, art.modelName, effectName);

            string hitEffectName = EditorDataContainer.GetStringById(oart.hitEffect.effect);

            if (art.hitEffect == null)
            {
                art.hitEffect = new List <SkillEffectUnit>();
            }
            if (art.hitEffect.Count == 0)
            {
                art.hitEffect.Add(new SkillEffectUnit());
            }
            art.hitEffect[0].artEffect.effectObj = AssetUtility.GetSkillEffect(art.modelType, art.modelName, hitEffectName);


            if (art.tipEffect == null)
            {
                art.tipEffect = new List <SkillEffectUnit>();
            }
            if (art.tipEffect.Count == 0)
            {
                art.tipEffect.Add(new SkillEffectUnit());
            }
            art.tipEffect[0].artEffect.effectObj = AssetUtility.GetSkillEffect(art.modelType, art.modelName, hitEffectName);

            for (int i = 0; i < oart.beginEffect.Count; i++)
            {
                string beginEffectName = EditorDataContainer.GetStringById(oart.beginEffect[i].effect);
                art.beginEffect[i].artEffect.effectObj = AssetUtility.GetSkillEffect(art.modelType, art.modelName, beginEffectName);
            }
        }
示例#3
0
 private void OnGUI()
 {
     EditorGUILayout.BeginVertical();
     EditorGUILayout.LabelField("输入技能id数字或id名称搜索");
     id     = EditorGUILayout.IntField("id数字:", id);
     idName = EditorGUILayout.TextField("id名称:", idName);
     if (GUILayout.Button("id数字搜索并应用", GUILayout.Height(40)))
     {
         if (id > 0 && EditorDataContainer.allSkillUnits.units.Count > id)
         {
             idName = EditorDataContainer.GetSkillStringById(id);
             DataConvert.ConvertSkillUnit(EditorDataContainer.currentskillAssetData.skillUnit, EditorDataContainer.allSkillUnits.units[id]);
             int curart = EditorDataContainer.currentskillAssetData.skillUnit.artId;
             SkillUnit.SkillArt oart = EditorDataContainer.allSkillUnits.arts[curart];
             DataConvert.ConvertSkillArt(EditorDataContainer.currentskillAssetData.skillArt, oart);
             EditorDataContainer.UseSkillArt(oart);
         }
     }
     if (GUILayout.Button("id名字搜索并应用", GUILayout.Height(40)))
     {
         id = EditorDataContainer.GetSkillIdByString(idName);
         if (id > 0 && EditorDataContainer.allSkillUnits.units.Count > id)
         {
             DataConvert.ConvertSkillUnit(EditorDataContainer.currentskillAssetData.skillUnit, EditorDataContainer.allSkillUnits.units[id]);
             int curart = EditorDataContainer.currentskillAssetData.skillUnit.artId;
             SkillUnit.SkillArt oart = EditorDataContainer.allSkillUnits.arts[curart];
             DataConvert.ConvertSkillArt(EditorDataContainer.currentskillAssetData.skillArt, oart);
             EditorDataContainer.UseSkillArt(oart);
         }
     }
     if (GUILayout.Button("Close", GUILayout.Height(40)))
     {
         Close();
     }
     EditorGUILayout.EndVertical();
 }
示例#4
0
        private void OnGUI()
        {
            if (m_Editor == null)
            {
                // 第一个参数这里暂时没关系,因为编辑器没有取目标对象
                m_Editor = (PreviewExampleInspector)Editor.CreateEditor(this, typeof(PreviewExampleInspector));
            }
            ModelTargetType modelType = EditorDataContainer.currentskillAssetData.skillArt.modelType;
            GameObject      model     = EditorDataContainer.currentskillAssetData.skillArt.model;

            EditorGUILayout.BeginVertical();

            int newtypeindex = EditorGUILayout.Popup("ModelType:", (int)modelType, Enum.GetNames(typeof(ModelTargetType)));

            if (newtypeindex != (int)modelType)
            {
                EditorDataContainer.currentskillAssetData.skillArt.modelType = (ModelTargetType)newtypeindex;
            }
            List <GameObject> allFbx      = AssetUtility.GetAllFBXWithType((ModelTargetType)newtypeindex);
            List <string>     fbxNamelist = new List <string>();

            for (int i = 0; i < allFbx.Count; i++)
            {
                fbxNamelist.Add(allFbx[i].name);
            }
            int fbxselet = -1;

            if (model != null)
            {
                if (fbxNamelist.Contains(model.name))
                {
                    fbxselet = fbxNamelist.IndexOf(model.name);
                }
            }
            int newselectfbx = EditorGUILayout.Popup(fbxselet, fbxNamelist.ToArray());

            if (newselectfbx != fbxselet)
            {
                EditorDataContainer.currentskillAssetData.skillArt.model = allFbx[newselectfbx];
            }
            GameObject NewFbx = (GameObject)EditorGUILayout.ObjectField("Model:", model, typeof(GameObject), true);

            if (NewFbx != model)
            {
                EditorDataContainer.currentskillAssetData.skillArt.model     = NewFbx;
                EditorDataContainer.currentskillAssetData.skillArt.modelName = EditorDataContainer.currentskillAssetData.skillArt.model.name;
            }
            if (EditorDataContainer.currentskillAssetData.skillArt.model != null)
            {
                EditorDataContainer.currentskillAssetData.skillArt.modelName = EditorDataContainer.currentskillAssetData.skillArt.model.name;

                EditorDataContainer.currentskillAssetData.skillArt.animationController = EditorDataContainer.currentskillAssetData.skillArt.model.name + "_Anim";
                EditorGUILayout.TextField("animationControllerName", EditorDataContainer.currentskillAssetData.skillArt.animationController);
                RuntimeAnimatorController controller = AssetUtility.GetAnimationCtl(EditorDataContainer.currentskillAssetData.skillArt.modelType, EditorDataContainer.currentskillAssetData.skillArt.modelName, EditorDataContainer.currentskillAssetData.skillArt.animationController);

                if (EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj == null && controller != null)
                {
                    EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj = controller;
                }

                RuntimeAnimatorController newcontroller = (RuntimeAnimatorController)EditorGUILayout.ObjectField("AnimatorController:", EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj, typeof(RuntimeAnimatorController), true);
                if (newcontroller != controller)
                {
                    EditorDataContainer.currentskillAssetData.skillArt.animationController    = newcontroller.name;
                    EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj = newcontroller;
                }
            }
            if (GUILayout.Button("Create Empty Skill"))
            {
                EditorDataContainer.CreateEmptySkill("NewSkill", EditorDataContainer.currentskillAssetData.skillArt.model, EditorDataContainer.currentskillAssetData.skillArt.modelType, EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj);
            }
            if (EditorDataContainer.currentskillAssetData.skillArt.model != null)
            {
                //Texture pre = AssetPreview.GetAssetPreview(EditorDataContainer.currentskillAssetData.skillArt.model);
                GUILayout.Label("");
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width     = position.width;
                rect.height    = position.height - rect.y;
                m_Editor.model = EditorDataContainer.currentskillAssetData.skillArt.model;
                //   EditorGUI.DrawPreviewTexture(rect, pre);
                m_Editor.DrawPreview(rect);
            }
            EditorGUILayout.EndVertical();
        }
示例#5
0
 private void OnEnable()
 {
     EditorDataContainer.LoadSystemTables();
 }
示例#6
0
        private void DrawButtons()
        {
            //使用选择的技能参数
            if (GUILayout.Button(new GUIContent("Use Choose Unit\n加载选择的技能数据", "使用选择的技能Unit"), GUILayout.Height(40)))
            {
                DataConvert.ConvertSkillUnit(EditorDataContainer.currentskillAssetData.skillUnit, EditorDataContainer.allSkillUnits.units[SelectSkillUnit]);
                int curart = EditorDataContainer.currentskillAssetData.skillUnit.artId;
                SkillUnit.SkillArt oart = EditorDataContainer.allSkillUnits.arts[curart];
                DataConvert.ConvertSkillArt(EditorDataContainer.currentskillAssetData.skillArt, oart);
                EditorDataContainer.UseSkillArt(oart);
            }
            //使用选择的技能参数
            if (GUILayout.Button(new GUIContent("Use Choose Skill Art\n加载选择的特效数据", "使用选择的技能数据填充当前技能数据"), GUILayout.Height(40)))
            {
                SkillUnit.SkillArt oart = EditorDataContainer.allSkillUnits.arts[SelectSkillArt];
                EditorDataContainer.UseSkillArt(oart);
            }
            if (GUILayout.Button(new GUIContent("Generate Sequence\n生成序列", "生成序列"), GUILayout.Height(40)))
            {
                EditorDataContainer.GenerateSequence(EditorDataContainer.currentskillAssetData);
                Close();
            }
            if (GUILayout.Button(new GUIContent("Generate SkillData\n生成技能数据", "由当前序列生成技能数据对象"), GUILayout.Height(40)))
            {
                if (CurrentSequence != null)
                {
                    EditorDataContainer.currentskillAssetData = EditorDataContainer.MakeSkillAssetData(CurrentSequence);
                    Debug.Log(EditorDataContainer.currentskillAssetData.skillArt.beginEffect.Count);
                    Reset();
                }
            }
            if (GUILayout.Button("Search\n搜索技能", GUILayout.Height(40)))
            {
                var window = GetWindow <SearchWindow>();
                window.Show();
            }
            if (GUILayout.Button("Save Asset\n保存技能为Asset", GUILayout.Height(40)))
            {
                EditorDataContainer.SaveSkillAssetData();
            }
            if (GUILayout.Button("Load Asset\n加载Asset技能文件", GUILayout.Height(40)))
            {
                EditorDataContainer.LoadSkillAssetData();
                Reset();
                Repaint();
            }
            if (GUILayout.Button("Save SystemTables\n保存技能到系统表", GUILayout.Height(40)))
            {
                EditorDataContainer.SaveSystemTables();
                EditorDataContainer.LoadSystemTables();
                Reset();
                Repaint();
            }

            if (GUILayout.Button(showUnitList ? "HideSkillUnitList\n隐藏系统技能表" : "ShowSkillUnitList\n显示系统技能表", GUILayout.Height(40)))
            {
                showUnitList = !showUnitList;
            }
            if (GUILayout.Button(showArtList ? "HideSkillArtList\n隐藏系统特效表" : "ShowSkillArtList\n显示系统特效表", GUILayout.Height(40)))
            {
                showArtList = !showArtList;
            }
            if (GUILayout.Button("Close\n关闭窗口", GUILayout.Height(40)))
            {
                Close();
            }
        }
示例#7
0
        private void DrawSkillArtList(float width)
        {
            GUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("SkillArtEffect List");
            LoadFbx();
            LoadEffect();
            // 设置保存文件名字
            List <SkillUnit.SkillArt> skillart = EditorDataContainer.allSkillUnits.arts;

            artScrollPos = EditorGUILayout.BeginScrollView(artScrollPos);
            //列表
            if (artList == null)
            {
                // 加入数据数组
                artList = new ReorderableList(skillart, typeof(SkillUnit.SkillArt), false, false, true, true);
            }
            // 绘制Item显示列表
            artList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                SkillUnit.SkillArt element = skillart[index];
                Rect drawRect = new Rect(rect.x, rect.y + 20, width - 30, 1200);
                GUILayout.BeginArea(drawRect);
                EditorGUILayout.TextField("Id:" + element.id, EditorDataContainer.GetSkillStringById(element.id));
                EditorGUILayout.FloatField("guideFadeTime:", element.guideFadeTime);
                EditorGUILayout.TextField("guideAction:", element.guideAction);
                EditorGUILayout.TextField("guidingAction:", element.guidingAction);
                EditorGUILayout.TextField("endAction:", element.endAction);

                for (int i = 0; i < element.beginEffect.Count; i++)
                {
                    if (element.beginEffect[i] != null)
                    {
                        EditorGUILayout.LabelField("beginEffect:" + i);
                        EditorDrawUtility.DrawSkillArtEffect(DataConvert.ConvertSkillArtEffect(element.beginEffect[i]), null, null);
                    }
                }
                if (element.unitEffect != null)
                {
                    EditorGUILayout.LabelField("unitEffect:");
                    EditorDrawUtility.DrawSkillArtEffect(DataConvert.ConvertSkillArtEffect(element.unitEffect), null, null);
                }
                if (element.tipEffect != null)
                {
                    EditorGUILayout.LabelField("tipEffect:");
                    EditorDrawUtility.DrawSkillArtEffect(DataConvert.ConvertSkillArtEffect(element.tipEffect), null, null);
                }
                if (element.hitEffect != null)
                {
                    EditorGUILayout.LabelField("hitEffect:");
                    EditorDrawUtility.DrawSkillArtEffect(DataConvert.ConvertSkillArtEffect(element.hitEffect), null, null);
                }
                if (element.beginCameraAction != null)
                {
                    EditorGUILayout.LabelField("beginCameraAction:");
                    EditorDrawUtility.DrawCameraAction(DataConvert.ConvertCameraAction(element.beginCameraAction));
                }
                if (element.moveCameraAction != null)
                {
                    EditorGUILayout.LabelField("moveCameraAction:");
                    EditorDrawUtility.DrawCameraAction(DataConvert.ConvertCameraAction(element.moveCameraAction));
                }
                if (element.hitCameraAction != null)
                {
                    EditorGUILayout.LabelField("hitCameraAction:");
                    EditorDrawUtility.DrawCameraAction(DataConvert.ConvertCameraAction(element.hitCameraAction));
                }
                GUILayout.EndArea();
                EditorGUILayout.Separator();
                artList.elementHeight = 1200;// 190 + element.beginEffect.Count * 80;
            };
            // 绘制表头
            artList.drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, "SkillArtList");
            };
            // 选择回调
            artList.onSelectCallback = (ReorderableList l) =>
            {
                SelectSkillArt = l.index;
            };
            artList.DoLayoutList();
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
        //生成序列
        public static JSequencer GenerateSequence(SkillAssetData skillart)
        {
            //id 名称
            string SkillId = EditorDataContainer.GetSkillStringById(skillart.skillArt.id);
            //模型名称
            string ModelName = skillart.skillArt.modelName;
            //起始动作
            string guideAction = skillart.skillArt.guideAction;
            //持续动作
            string guidingAction = skillart.skillArt.guidingAction;
            //结束动作
            string endAction = skillart.skillArt.endAction;
            //animator名称
            string animatorName = skillart.skillArt.animationController;
            RuntimeAnimatorController animationControllerObj = skillart.skillArt.animationControllerObj;
            //模型类型 主角  NPC
            ModelTargetType modelType = skillart.skillArt.modelType;
            //技能列表
            List <SkillEffectUnit> beginEffect = skillart.skillArt.beginEffect;
            //技能列表
            List <SkillEffectUnit> unitEffect = skillart.skillArt.unitEffect;
            //技能列表
            List <SkillEffectUnit> tipEffect = skillart.skillArt.tipEffect;
            //技能列表
            List <SkillEffectUnit> hitEffect = skillart.skillArt.hitEffect;

            GameObject ShowRoot = new GameObject("ShowRoot_" + SkillId);
            //获取模型 实例化
            GameObject PlayerModel = AssetUtility.GetFBXAsset(modelType, ModelName);
            GameObject Player      = null;

            if (PlayerModel != null)
            {
                Player                  = UnityEngine.Object.Instantiate(PlayerModel) as GameObject;
                Player.name             = ModelName;
                Player.transform.parent = ShowRoot.transform;
            }
            else
            {
                Player = new GameObject(ModelName);
                Player.transform.parent = ShowRoot.transform;
            }
            //获取animator 赋值
            RuntimeAnimatorController controll = animationControllerObj;// AssetUtility.GetAnimationCtl(modelType, ModelName, animatorName);

            if (controll != null)
            {
                if (Player.GetComponent <Animator>() == null)
                {
                    Player.AddComponent <Animator>();
                }
                Player.GetComponent <Animator>().runtimeAnimatorController = controll;
            }

            //新建队列
            GameObject newSequence = new GameObject("Sequence_" + ModelName);
            JSequencer sequence    = newSequence.AddComponent <JSequencer>();

            JTimelineContainer ccontainer = sequence.CreateNewTimelineContainer(Player.transform);

            JTimelineEffect effectline = (JTimelineEffect)ccontainer.AddNewTimeline(TimeLineType.Effect);

            if (guideAction != "-1")
            {
                JEffectTrack track = effectline.AddNewTrack();
                track.name = SkillNames.EffectNames[(int)SkillNames.Effect.GuideAction];
                JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                clip.effectType       = EffectType.Animation;
                clip.TargetObject     = effectline.AffectedObject.gameObject;
                clip.animController   = controll;
                clip.StateName        = guideAction;
                clip.PlaybackDuration = MecanimAnimationUtility.GetStateDurationWithAnimatorController(guideAction, controll);
                clip.StartTime        = 0;
                track.AddClip(clip);
            }
            if (guidingAction != "-1")
            {
                JEffectTrack track = effectline.AddNewTrack();
                track.name = SkillNames.EffectNames[(int)SkillNames.Effect.GuidingAction];
                JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                clip.effectType       = EffectType.Animation;
                clip.TargetObject     = effectline.AffectedObject.gameObject;
                clip.animController   = controll;
                clip.StateName        = guidingAction;
                clip.PlaybackDuration = MecanimAnimationUtility.GetStateDurationWithAnimatorController(guidingAction, controll);
                float t = guidingAction == "-1" ? 0 : MecanimAnimationUtility.GetStateDurationWithAnimatorController(guideAction, controll);
                clip.StartTime = t;
                track.AddClip(clip);
            }
            if (endAction != "-1")
            {
                JEffectTrack track = effectline.AddNewTrack();
                track.name = SkillNames.EffectNames[(int)SkillNames.Effect.EndAction];
                float           t1   = guideAction == "-1" ? 0 : MecanimAnimationUtility.GetStateDurationWithAnimatorController(guideAction, controll);
                float           t    = guidingAction == "-1" ? 0 : MecanimAnimationUtility.GetStateDurationWithAnimatorController(guidingAction, controll);
                JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                clip.effectType       = EffectType.Animation;
                clip.TargetObject     = effectline.AffectedObject.gameObject;
                clip.animController   = controll;
                clip.StateName        = endAction;
                clip.PlaybackDuration = MecanimAnimationUtility.GetStateDurationWithAnimatorController(endAction, controll);
                clip.StartTime        = t1 + t;
                track.AddClip(clip);
            }

            if (beginEffect != null)
            {
                //一个特效 一条轨道
                foreach (SkillEffectUnit effect in beginEffect)
                {
                    //特效名称
                    JEffectTrack track = effectline.AddNewTrack();
                    int          index = beginEffect.IndexOf(effect);
                    if (index > 2)
                    {
                        index = 2;
                    }
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect0 + index];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Particle;
                    clip.effectunit       = effect.Copy();
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.artEffect.phaseTime / 1000.0f;
                    clip.StartTime        = (float)effect.artEffect.beginTime / 1000.0f;
                    track.AddClip(clip);
                }
            }
            if (unitEffect != null)
            {
                //一个特效 一条轨道
                foreach (SkillEffectUnit effect in unitEffect)
                {
                    //特效名称
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.UnitEffect];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Trajectory;
                    clip.effectunit       = effect.Copy();
                    clip.skillunit        = skillart.skillUnit.Copy();
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.artEffect.phaseTime / 1000.0f;
                    clip.StartTime        = (float)effect.artEffect.beginTime / 1000.0f;
                    track.AddClip(clip);
                }
            }
            if (tipEffect != null)
            {
                //一个特效 一条轨道
                foreach (SkillEffectUnit effect in tipEffect)
                {
                    //特效名称
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.TipEffect];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Particle;
                    clip.effectunit       = effect.Copy();
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.artEffect.phaseTime / 1000.0f;
                    clip.StartTime        = (float)effect.artEffect.beginTime / 1000.0f;
                    track.AddClip(clip);
                }
            }
            if (hitEffect != null)
            {
                //一个特效 一条轨道
                foreach (SkillEffectUnit effect in hitEffect)
                {
                    //特效名称
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.HitEffect];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Particle;
                    clip.effectunit       = effect.Copy();
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.artEffect.phaseTime / 1000.0f;
                    clip.StartTime        = (float)effect.artEffect.beginTime / 1000.0f;
                    track.AddClip(clip);
                    //    track.AddClip(effectName, (float)effect.artEffect.beginTime / 1000.0f, (float)effect.artEffect.phaseTime / 1000.0f, effectPrefab, effect.configure);
                }
            }
            if (skillart.skillArt.beginCameraAction != null)
            {
                //一个特效 一条轨道
                foreach (SkillCameraAction effect in skillart.skillArt.beginCameraAction)
                {
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.BeginCameraAction];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Camera;
                    clip.cameraAction     = effect.Copy();
                    clip.TargetCamera     = Camera.main;
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.phaseTime;
                    clip.StartTime        = (float)effect.delay;
                    track.AddClip(clip);
                }
            }
            if (skillart.skillArt.moveCameraAction != null)
            {
                foreach (SkillCameraAction effect in skillart.skillArt.moveCameraAction)
                {
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.MoveCameraAction];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Camera;
                    clip.cameraAction     = effect.Copy();
                    clip.TargetCamera     = Camera.main;
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.phaseTime;
                    clip.StartTime        = (float)effect.delay;
                    track.AddClip(clip);
                }
            }
            if (skillart.skillArt.hitCameraAction != null)
            {
                foreach (SkillCameraAction effect in skillart.skillArt.hitCameraAction)
                {
                    JEffectTrack track = effectline.AddNewTrack();
                    track.name = SkillNames.EffectNames[(int)SkillNames.Effect.HitCameraAction];
                    JEffectClipData clip = ScriptableObject.CreateInstance <JEffectClipData>();
                    clip.effectType       = EffectType.Camera;
                    clip.cameraAction     = effect.Copy();
                    clip.TargetCamera     = Camera.main;
                    clip.TargetObject     = effectline.AffectedObject.gameObject;
                    clip.PlaybackDuration = (float)effect.phaseTime;
                    clip.StartTime        = (float)effect.delay;
                    track.AddClip(clip);
                }
            }
            return(sequence);
        }
        public static SkillAssetData MakeSkillAssetData(JSequencer sequenceer)
        {
            SkillAssetData    skillart       = new SkillAssetData();
            Transform         AffectedObject = sequenceer.TimelineContainers[0].AffectedObject;
            string            ModelName      = AffectedObject.name;
            List <GameObject> plist          = AssetUtility.GetAllFBXWithType(ModelTargetType.Player);
            List <GameObject> nlist          = AssetUtility.GetAllFBXWithType(ModelTargetType.NPC);

            skillart.skillArt.modelType = ModelTargetType.Player;
            bool findtype = false;

            for (int i = 0; i < plist.Count && !findtype; i++)
            {
                if (plist[i].name == ModelName)
                {
                    skillart.skillArt.modelType = ModelTargetType.Player;
                    findtype = true;
                }
            }
            for (int i = 0; i < nlist.Count && !findtype; i++)
            {
                if (nlist[i].name == ModelName)
                {
                    skillart.skillArt.modelType = ModelTargetType.NPC;
                    findtype = true;
                }
            }
            skillart.skillArt.modelName = ModelName;
            skillart.skillArt.model     = AssetUtility.GetFBXWithName(ModelName);
            Animator Animator = AffectedObject.GetComponent <Animator>();

            skillart.skillArt.animationController = Animator.runtimeAnimatorController.name;
            skillart.skillArt.id = EditorDataContainer.GetSkillIdByString(AffectedObject.parent.name.Split('_')[1]);
            if (sequenceer.TimelineContainers.Length > 0)
            {
                JTimelineBase[] lines = sequenceer.TimelineContainers[0].Timelines;
                for (int i = 0; i < lines.Length; i++)
                {
                    JTimelineBase line = lines[i];
                    //动作时间线 guideaction

                    /* if (line.LineType() == TimeLineType.Animation)
                     * {
                     *   JTimelineAnimation aniline = (JTimelineAnimation)line;
                     *   foreach (var track in aniline.AnimationTracks)
                     *   {
                     *       if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.GuideAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.guideAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *       else if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.GuidingAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.guidingAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *       else if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.EndAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.endAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *   }
                     * }*/
                    //特效时间线 begineffect
                    if (line.LineType() == TimeLineType.Effect)
                    {
                        JTimelineEffect aniline = (JTimelineEffect)line;
                        foreach (var track in aniline.EffectTracks)
                        {
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.GuideAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.guideAction = track.TrackClips[0].StateName;
                                }
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.GuidingAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.guidingAction = track.TrackClips[0].StateName;
                                }
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.endAction = track.TrackClips[0].StateName;
                                }
                            }

                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect0] || track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect1])
                            {
                                if (skillart.skillArt.beginEffect == null)
                                {
                                    skillart.skillArt.beginEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.beginEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }


                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndEffect])
                            {
                                if (skillart.skillArt.endEffect == null)
                                {
                                    skillart.skillArt.endEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.endEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.UnitEffect])
                            {
                                if (skillart.skillArt.unitEffect == null)
                                {
                                    skillart.skillArt.unitEffect = new List <SkillEffectUnit>();
                                }
                                if (skillart.skillUnit == null)
                                {
                                    skillart.skillUnit = new JSkillUnit();
                                }
                                skillart.skillArt.unitEffect.Add(track.TrackClips[0].effectunit.Copy());
                                skillart.skillUnit = track.TrackClips[0].skillunit.Copy();
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.HitEffect])
                            {
                                if (skillart.skillArt.hitEffect == null)
                                {
                                    skillart.skillArt.hitEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.hitEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.TipEffect])
                            {
                                if (skillart.skillArt.tipEffect == null)
                                {
                                    skillart.skillArt.tipEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.tipEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginCameraAction])
                            {
                                if (skillart.skillArt.beginCameraAction == null)
                                {
                                    skillart.skillArt.beginCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.beginCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.MoveCameraAction])
                            {
                                if (skillart.skillArt.moveCameraAction == null)
                                {
                                    skillart.skillArt.moveCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.moveCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.HitCameraAction])
                            {
                                if (skillart.skillArt.hitCameraAction == null)
                                {
                                    skillart.skillArt.hitCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.hitCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                        }
                    }
                    if (skillart.skillArt.beginEffect != null)
                    {
                        skillart.skillArt.beginEffect.Sort(delegate(SkillEffectUnit x, SkillEffectUnit y)
                        {
                            return(x.artEffect.beginTime.CompareTo(y.artEffect.beginTime));
                        });
                    }


                    /*
                     *  if (line.LineType() == TimeLineType.Particle)
                     *  {
                     *      JTimelineParticle aniline = (JTimelineParticle)line;
                     *      foreach (var track in aniline.ParticleTracks)
                     *      {
                     *          if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect0]|| track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect1]|| track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndEffect])
                     *          {
                     *              if (track.TrackClips.Count > 0)
                     *              {
                     *                  SkillEffectUnit unit = new SkillEffectUnit();
                     *                  unit.configure = track.TrackClips[0].EffectConfig.Copy();
                     *                  unit.artEffect.beginTime = (int)(track.TrackClips[0].StartTime*1000f);
                     *                  unit.artEffect.phaseTime = (int)(track.TrackClips[0].PlaybackDuration * 1000f);
                     *                  unit.artEffect.effectObj = track.TrackClips[0].Effect;
                     *                  unit.artEffect.effect = EditorDataContainer.GetIdByString(track.TrackClips[0].ParticleName);
                     *                  begineffect.Insert(0, unit);
                     *              }
                     *          }
                     *
                     *      }
                     *  }
                     *  //弹道时间线
                     *  if (skillart.skillArt.unitEffect == null)
                     *      skillart.skillArt.unitEffect = new List<SkillEffectUnit>();
                     *  List<SkillEffectUnit> unitEffect = skillart.skillArt.unitEffect;
                     *  unitEffect.Clear();
                     *  if (line.LineType() == TimeLineType.Trajectory)
                     *  {
                     *      JTimelineTrajectory aniline = (JTimelineTrajectory)line;
                     *
                     *      foreach (var track in aniline.TrajectoryTracks)
                     *      {
                     *          if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.UnitEffect])
                     *          {
                     *              if (track.TrackClips.Count > 0)
                     *              {
                     *                  skillart.skillUnit = track.TrackClips[0].skillunit.Copy();
                     *                  unitEffect.Add(track.TrackClips[0].effectunit.Copy());
                     *              }
                     *          }
                     *      }
                     *  }
                     */
                }
            }
            Debug.Log(skillart.skillArt.beginEffect.Count);

            return(skillart);
        }
 public static int GetIdByString(string id)
 {
     return(EditorDataContainer.GetIdByString(id));
 }
 public static string GetStringById(int id)
 {
     return(EditorDataContainer.GetStringById(id));
 }
示例#12
0
        private void DisplayTopBar()
        {
            float space = 16.0f;

            GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(18.0f));

            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                TopBar = GUILayoutUtility.GetLastRect();
            }

            GUILayout.BeginArea(TopBar);
            {
                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Create New Sequence", EditorStyles.toolbarButton))
                    {
                        GameObject newSequence = new GameObject("Sequence");
                        JSequencer sequence    = newSequence.AddComponent <JSequencer>();
                        //USUtility.CreateAndAttachObserver(sequence);

                        if (CurrentSequence == null)
                        {
                            Selection.activeGameObject = newSequence;
                            Selection.activeTransform  = newSequence.transform;
                            SequenceSwitch(sequence);
                        }

                        Repaint();
                    }

                    string currentSequence = CurrentSequence != null ? CurrentSequence.name : "";
                    string label           = "Select a Sequence";
                    if (CurrentSequence != null)
                    {
                        label = String.Format("Editting : {0}", currentSequence);
                    }
                    if (GUILayout.Button(label, EditorStyles.toolbarButton, GUILayout.Width(150.0f)))
                    {
                        GenericMenu  menu             = new GenericMenu();
                        JSequencer[] sequences        = FindObjectsOfType(typeof(JSequencer)) as JSequencer[];
                        var          orderedSequences = sequences.OrderBy(sequence => sequence.name);
                        foreach (JSequencer sequence in orderedSequences)
                        {
                            menu.AddItem(new GUIContent(sequence.name),
                                         currentSequence == sequence.name ? true : false,
                                         (obj) => Selection.activeGameObject = (GameObject)obj,
                                         sequence.gameObject);
                        }
                        menu.ShowAsContext();
                    }

                    GUILayout.Space(space);
                    GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f));
                    GUILayout.Space(space);

                    if (CurrentSequence != null)
                    {
                        if (GUILayout.Button(new GUIContent(!CurrentSequence.IsPlaying ? USEditorUtility.PlayButton : USEditorUtility.PauseButton, "Toggle Play Mode (P)"), USEditorUtility.ToolbarButtonSmall))
                        {
                            PlayOrPause();
                        }
                        if (GUILayout.Button(USEditorUtility.StopButton, USEditorUtility.ToolbarButtonSmall))
                        {
                            Stop();
                        }

                        GUILayout.Space(space);
                        GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f));
                        GUILayout.Space(space);
                    }
                    if (GUILayout.Button("CreateNewSkill", EditorStyles.toolbarButton))
                    {
                        Debug.Log("创建新技能");
                        var window = GetWindow <SetModelWindow>();
                        window.Show();
                    }
                    if (GUILayout.Button("Configure", EditorStyles.toolbarButton))
                    {
                        Debug.Log("配置面板");
                        var window = GetWindow <ConfigureWindow>();
                        window.CurrentSequence = CurrentSequence;
                        window.Show();
                    }
                    if (GUILayout.Button("Save", EditorStyles.toolbarButton))
                    {
                        EditorDataContainer.SaveSkillAssetData();
                    }
                    if (GUILayout.Button("Load", EditorStyles.toolbarButton))
                    {
                        EditorDataContainer.LoadSkillAssetData();
                    }

                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }