コード例 #1
0
        private void AddNewEffectClip(JEffectTrack track, EffectType type, float time)
        {
            var             clipData = ScriptableObject.CreateInstance <JEffectClipData>();
            JTimelineEffect line     = (JTimelineEffect)track.TimeLine;

            clipData.TargetObject     = line.AffectedObject.gameObject;
            clipData.StartTime        = time;
            clipData.StateName        = "";
            clipData.PlaybackDuration = 1;
            clipData.Track            = track;
            clipData.effectType       = type;
            track.AddClip(clipData);
            if (timelineClipRenderDataMap.ContainsKey(track))
            {
                var cachedData = ScriptableObject.CreateInstance <JClipRenderData>();
                cachedData.ClipData = clipData;
                timelineClipRenderDataMap[track].Add(cachedData);
            }
            else
            {
                var cachedData = ScriptableObject.CreateInstance <JClipRenderData>();
                cachedData.ClipData = clipData;
                List <JClipRenderData> list = new List <JClipRenderData>();
                list.Add(cachedData);
                timelineClipRenderDataMap.Add(track, list);
            }
        }
コード例 #2
0
        //侧边栏
        private void SideBarAndLineForEffect(JTimelineBase timeline)
        {
            if (timeline is JTimelineEffect)
            {
                GUILayout.BeginVertical();
                JTimelineEffect transformline = (JTimelineEffect)timeline;
                for (int j = 0; j < transformline.EffectTracks.Count; j++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Box(new GUIContent("" + transformline.AffectedObject.name, ""), USEditorUtility.USeqSkin.GetStyle("TimelinePaneBackground"), GUILayout.Height(lineHeight), GUILayout.MaxWidth(FloatingWidth));
                    Rect FloatingRect = GUILayoutUtility.GetLastRect();
                    GUILayout.Box(new GUIContent("", "EffectTimeline for" + transformline.AffectedObject.name + "Track " + j), USEditorUtility.USeqSkin.GetStyle("TimelinePaneBackground"), GUILayout.Height(lineHeight), GUILayout.ExpandWidth(true));
                    Rect ContentRect = GUILayoutUtility.GetLastRect();
                    GUILayout.EndHorizontal();

                    Rect addRect   = FloatingRect;
                    Rect labelRect = addRect;
                    labelRect.x     += 40;
                    labelRect.width -= (lineHeight + 41);
                    GUI.Label(labelRect, "Track " + j);

                    //轨道名字
                    Rect nameRect = addRect;
                    nameRect.x     += 40 + lineHeight + 40;
                    nameRect.width -= (lineHeight + 120);
                    //transformline.EffectTracks[j].name = GUI.TextField(nameRect, transformline.EffectTracks[j].name);

                    int select = SkillNames.EffectNames.Contains(transformline.EffectTracks[j].name) ? SkillNames.EffectNames.IndexOf(transformline.EffectTracks[j].name) : 0;
                    select = EditorGUI.Popup(nameRect, select, SkillNames.EffectNames.ToArray());
                    transformline.EffectTracks[j].name = SkillNames.EffectNames[select];

                    Rect enableRect = addRect;
                    enableRect.x     = addRect.x + addRect.width - 2 * lineHeight - 2.0f;;
                    enableRect.width = lineHeight;
                    //enable开关
                    transformline.EffectTracks[j].Enable = GUI.Toggle(enableRect, transformline.EffectTracks[j].Enable, new GUIContent("", USEditorUtility.EditButton, "Enable The Timeline"));

                    addRect.x     = addRect.x + addRect.width - lineHeight - 1.0f;
                    addRect.width = lineHeight;
                    GenericMenu contextMenu = new GenericMenu();

                    if (GUI.Button(addRect, new GUIContent("", USEditorUtility.EditButton, "Options for this Timeline"), USEditorUtility.ToolbarButtonSmall))
                    {
                        contextMenu = MenuForEffectTimeLine(transformline, transformline.EffectTracks[j]);
                        contextMenu.ShowAsContext();
                    }

                    if (timelineClipRenderDataMap.ContainsKey(transformline.EffectTracks[j]))
                    {
                        ///时间线背景 区域 只接受右键
                        DisplayArea = ContentRect;// GUILayoutUtility.GetLastRect();
                        GUI.BeginGroup(DisplayArea);
                        List <JClipRenderData> renderDataList = timelineClipRenderDataMap[transformline.EffectTracks[j]];
                        EffectGUI(transformline, transformline.EffectTracks[j], renderDataList.ToArray());
                        GUI.EndGroup();
                    }
                }
                GUILayout.EndVertical();
            }
        }
コード例 #3
0
        private void AddRenderDataForEffect(JTimelineBase timeline)
        {
            if (timeline is JTimelineEffect)
            {
                JTimelineEffect tline = (JTimelineEffect)timeline;
                for (int k = 0; k < tline.EffectTracks.Count; k++)
                {
                    List <JClipRenderData> list  = new List <JClipRenderData>();
                    JEffectTrack           track = tline.EffectTracks[k];
                    for (int l = 0; l < track.TrackClips.Count; l++)
                    {
                        JEffectClipData key        = track.TrackClips[l];
                        var             cachedData = ScriptableObject.CreateInstance <JClipRenderData>();
                        cachedData.ClipData = key;
                        list.Add(cachedData);
                    }

                    if (!timelineClipRenderDataMap.ContainsKey(track))
                    {
                        timelineClipRenderDataMap.Add(track, list);
                    }
                    else
                    {
                        timelineClipRenderDataMap[track] = list;
                    }
                }
            }
        }
コード例 #4
0
 private void AddNewEffectTrack(JTimelineBase line)
 {
     if (line is JTimelineEffect)
     {
         JTimelineEffect tline = (JTimelineEffect)line;
         var             track = ScriptableObject.CreateInstance <JEffectTrack>();
         tline.AddTrack(track);
         AddRenderDataForEffect(tline);
     }
 }
コード例 #5
0
        public static void CreateEmptySkill(string SkillId, GameObject PlayerModel, ModelTargetType modelType, RuntimeAnimatorController controll)
        {
            string ModelName = PlayerModel.name;

            GameObject ShowRoot = new GameObject("ShowRoot_" + SkillId);
            //获取模型 实例化
            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 赋值
            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);
            JTimelineAnimation aniline     = (JTimelineAnimation)ccontainer.AddNewTimeline(TimeLineType.Animation);

            /*   foreach (SkillNames.GuideAction gui in Enum.GetValues(typeof(SkillNames.GuideAction)))
             * {
             *     JAnimationTrack track = aniline.AddNewTrack();
             *     track.name = SkillNames.ActionNames[(int)gui];
             * }*/
            JTimelineEffect effectline = (JTimelineEffect)ccontainer.AddNewTimeline(TimeLineType.Effect);

            foreach (SkillNames.Effect gui in Enum.GetValues(typeof(SkillNames.Effect)))
            {
                JEffectTrack track = effectline.AddNewTrack();
                track.name = SkillNames.EffectNames[(int)gui];
            }

            /* JTimelineSound soundline = (JTimelineSound)ccontainer.AddNewTimeline(TimeLineType.Sound);
             * foreach (SkillNames.Sound gui in Enum.GetValues(typeof(SkillNames.Sound)))
             * {
             *   JSoundTrack track = soundline.AddNewTrack();
             *   track.name = SkillNames.SoundNames[(int)gui];
             * }*/
        }
コード例 #6
0
        private void RemoveEffectLine(JEffectTrack track)
        {
            if (timelineClipRenderDataMap.ContainsKey(track))
            {
                timelineClipRenderDataMap.Remove(track);
            }
            JTimelineEffect line = (JTimelineEffect)track.TimeLine;

            line.RemoveTrack(track);
            JTimelineContainer contain = line.TimelineContainer;

            if (line.EffectTracks.Count == 0)
            {
                DestroyImmediate(line.gameObject);
            }
            //删除的是最后一个 删除掉container
            if (contain.Timelines.Length == 0)
            {
                DestroyImmediate(contain.gameObject);
            }
        }
コード例 #7
0
        //生成序列
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        private void EffectGUI(JTimelineBase timeline, JEffectTrack track, JClipRenderData[] renderDataList)
        {
            if (timeline is JTimelineEffect)
            {
                JTimelineEffect Effectline = (JTimelineEffect)timeline;

                GenericMenu contextMenu = new GenericMenu();
                ///event 右键点击
                bool isContext       = UnityEngine.Event.current.type == EventType.MouseDown && UnityEngine.Event.current.button == 1;
                bool isChoose        = UnityEngine.Event.current.type == EventType.MouseDown && UnityEngine.Event.current.button == 0 && UnityEngine.Event.current.clickCount == 1;
                bool hasBox          = false;
                Rect DisplayAreaTemp = DisplayArea;
                DisplayAreaTemp.x = 0;
                DisplayAreaTemp.y = 0;
                for (int j = 0; j < renderDataList.Length; j++)
                {
                    JClipRenderData renderdata     = renderDataList[j];
                    JEffectClipData EffectClipData = (JEffectClipData)renderdata.ClipData;
                    JEffectTrack    linetrack      = EffectClipData.Track;
                    if (linetrack != track)
                    {
                        continue;
                    }
                    var startX      = ConvertTimeToXPos(EffectClipData.StartTime);
                    var endX        = ConvertTimeToXPos(EffectClipData.StartTime + EffectClipData.PlaybackDuration);
                    var transitionX = ConvertTimeToXPos(EffectClipData.StartTime + EffectClipData.PlaybackDuration);
                    var handleWidth = 2.0f;

                    Rect renderRect     = new Rect(startX, DisplayArea.y, endX - startX, DisplayArea.height);
                    Rect transitionRect = new Rect(startX, DisplayArea.y, transitionX - startX, DisplayArea.height);
                    Rect leftHandle     = new Rect(startX, DisplayArea.y, handleWidth * 2.0f, DisplayArea.height);
                    Rect rightHandle    = new Rect(endX - (handleWidth * 2.0f), DisplayArea.y, handleWidth * 2.0f, DisplayArea.height);
                    Rect labelRect      = new Rect();

                    Rect renderRecttemp = renderRect;
                    renderRecttemp.x -= DisplayArea.x;
                    renderRecttemp.y  = 0;
                    Rect transitionRecttemp = transitionRect;
                    transitionRecttemp.y  = 0;
                    transitionRecttemp.x -= DisplayArea.x;
                    Rect leftHandletemp = leftHandle;
                    leftHandletemp.y  = 0;
                    leftHandletemp.x -= DisplayArea.x;
                    Rect rightHandletemp = rightHandle;
                    rightHandletemp.x -= DisplayArea.x;
                    rightHandletemp.y  = 0;

                    // GUI.color = new Color(156 / 255.0f, 11 / 255.0f, 11 / 255.0f, 1);

                    // GUI.color = ColorTools.GetGrandientColor((float)Effectline.EffectTracks.IndexOf(track)/ (float)Effectline.EffectTracks.Count);
                    GUI.color = ColorTools.GetGrandientColor((float)renderdata.index / (float)CountClip);

                    if (SelectedObjects.Contains(renderdata))
                    {
                        GUI.color = ColorTools.SelectColor;
                    }

                    GUI.Box(renderRecttemp, "", USEditorUtility.NormalWhiteOutLineBG);
                    GUI.Box(leftHandletemp, "");
                    GUI.Box(rightHandletemp, "");

                    labelRect       = renderRecttemp;
                    labelRect.width = DisplayArea.width;

                    renderdata.renderRect     = renderRect;
                    renderdata.labelRect      = renderRect;
                    renderdata.renderPosition = new Vector2(startX, DisplayArea.y);
                    renderdata.transitionRect = transitionRect;
                    renderdata.leftHandle     = leftHandle;
                    renderdata.rightHandle    = rightHandle;
                    renderdata.ClipData       = EffectClipData;


                    labelRect.x += 4.0f; // Nudge this along a bit so it isn't flush with the side.

                    GUI.color = Color.black;
                    GUI.Label(labelRect, EffectClipData.FriendlyName);

                    GUI.color = Color.white;

                    if (isContext && renderRecttemp.Contains(UnityEngine.Event.current.mousePosition))
                    {
                        hasBox = true;
                        contextMenu.AddItem(new GUIContent("DeleteClip"),
                                            false, (obj) => RemoveEffectClip(((JClipRenderData)((object[])obj)[0])),
                                            new object[] { renderdata });
                    }
                    if (isContext && renderRecttemp.Contains(UnityEngine.Event.current.mousePosition))
                    {
                        UnityEngine.Event.current.Use();
                        contextMenu.ShowAsContext();
                    }
                }

                if (!hasBox && isChoose && DisplayAreaTemp.Contains(UnityEngine.Event.current.mousePosition) && (UnityEngine.Event.current.control || UnityEngine.Event.current.command))
                {
                    //代码选中hierarchy中的对象 显示inspector 按住Ctrl or command
                    //GameObject go = GameObject.Find(Animationline.gameObject.name);
                    Selection.activeGameObject = Effectline.gameObject;
                    EditorGUIUtility.PingObject(Effectline.gameObject);
                }
                if (!hasBox && isContext && DisplayAreaTemp.Contains(UnityEngine.Event.current.mousePosition))
                {
                    contextMenu = MenuForEffectTimeLine(Effectline, track);
                }
                if (!hasBox && isContext && DisplayAreaTemp.Contains(UnityEngine.Event.current.mousePosition))
                {
                    UnityEngine.Event.current.Use();
                    contextMenu.ShowAsContext();
                }
            }
        }