Ejemplo n.º 1
0
        public static ClipData CreateClipData(AssetType type)
        {
            ClipData clip = null;

            switch (type)
            {
            case AssetType.Animation:
                clip = new AnimClipData();
                break;

            case AssetType.BoneFx:
                clip = new BoneFxClipData();
                break;

            case AssetType.PostProcess:
                clip = new PostprocessData();
                break;

            case AssetType.SceneFx:
                clip = new SceneFxClipData();
                break;

            case AssetType.LogicValue:
                clip = new LogicClipData();
                break;

            default:
                Debug.Log("unknown clip " + type);
                break;
            }
            return(clip);
        }
Ejemplo n.º 2
0
 public void Initial(ClipData data, int port)
 {
     this.port = port;
     anData    = data as AnimClipData;
     aclip     = XResources.LoadSharedAsset <AnimationClip>(anData.anim);
     playable  = AnimationClipPlayable.Create(XTimeline.graph, aclip);
 }
        private static Dictionary <int, AnimClipData> GetStates(Animator animator, List <AnimClipData> clips)
        {
            UnityEditor.Animations.AnimatorController controller = animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
            Dictionary <int, int> states = GetStatesFromStatemachine(controller.layers[0].stateMachine);

            Dictionary <int, AnimClipData> stateClip = new Dictionary <int, AnimClipData>();

            foreach (var state in states)
            {
                AnimClipData data = clips.Find(delegate(AnimClipData clip)
                {
                    if (Animator.StringToHash(clip.clip.name) == state.Value)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
                stateClip.Add(state.Key, data);
            }

            return(stateClip);
        }
Ejemplo n.º 4
0
        private static void AddNewAnimClipData(string modelName)
        {
            AnimClipData data = new AnimClipData();

            data.modelName = modelName;
            m_listAnimClip.Add(data);
            m_curModelIndex = m_listAnimClip.Count - 1;
        }
Ejemplo n.º 5
0
        private void AddClip(AnimationClip u_clip, float t)
        {
            AnimClipData data = new AnimClipData();

            data.start      = t;
            data.duration   = u_clip.averageDuration;
            data.anim       = AssetDatabase.GetAssetPath(u_clip);
            data.trim_start = 0;
            data.loop       = u_clip.isLooping;
            XAnimationTrack atr  = (XAnimationTrack)track;
            XAnimationClip  clip = track.BuildClip(data) as XAnimationClip;

            clip.aclip = u_clip;
            clip.OnBind();
            track.AddClip(clip, data);
        }
Ejemplo n.º 6
0
        public override void OnDestroy()
        {
            if (playable.IsValid())
            {
                playable.Destroy();
                if (track.mixPlayable.IsValid())
                {
                    track.mixPlayable.SetInputCount(0);
                }
            }
            AnimClipData anData = data as AnimClipData;

            XResources.DestroySharedAsset(anData.anim);
            SharedPool <XAnimationClip> .Return(this);

            base.OnDestroy();
        }
Ejemplo n.º 7
0
        // Only skill mode worked
        public void BlendTo(string path)
        {
            var          track = SkillHostTrack as XAnimationTrack;
            AnimClipData data  = null;

            if (track)
            {
                blendPlayableOutput = track.playableOutput;
                blendMixPlayable    = track.mixPlayable;
                mixJob = track.mixJob;
                var clip = track.GetPlayingPlayable(out var tick) as XAnimationClip;
                if (clip != null)
                {
                    var p = clip.playable;
                    data            = (AnimClipData)clip.data;
                    data.trim_start = tick;
                    data.duration   = Mathf.Min(tick + 0.1f, data.duration);
                    data.start      = 0.01f;
                }
            }
            blending = true;
            Dispose(true);
            ReadConf(path);
            if (config != null)
            {
                if (config.skillHostTrack <= 0)
                {
                    Debug.LogError("not config skill host " + path);
                    return;
                }
                if (data != null)
                {
                    var clips = config.tracks[config.skillHostTrack].clips;
                    var nc    = new ClipData[clips.Length + 1];
                    nc[0] = data;
                    for (int i = 1; i < clips.Length + 1; i++)
                    {
                        nc[i] = clips[i - 1];
                    }
                    config.tracks[config.skillHostTrack].clips = nc;
                }
                Initial(config, PlayMode.Skill);
            }
            SetPlaying(true);
        }
        private static List <AnimClipData> GetClipsFromStatemachine(UnityEditor.Animations.AnimatorStateMachine stateMachine)
        {
            List <AnimClipData> list = new List <AnimClipData>();

            for (int i = 0; i != stateMachine.states.Length; ++i)
            {
                UnityEditor.Animations.ChildAnimatorState state = stateMachine.states[i];
                if (state.state.motion is UnityEditor.Animations.BlendTree)
                {
                    UnityEditor.Animations.BlendTree blendTree = state.state.motion as UnityEditor.Animations.BlendTree;
                    ChildMotion[] childMotion = blendTree.children;
                    for (int j = 0; j != childMotion.Length; ++j)
                    {
                        AnimClipData clipData = new AnimClipData();
                        clipData.clip  = childMotion[j].motion as AnimationClip;
                        clipData.speed = 1;
                        list.Add(clipData);
                    }
                }
                else if (state.state.motion != null)
                {
                    AnimClipData clipData = new AnimClipData();
                    clipData.clip  = state.state.motion as AnimationClip;
                    clipData.speed = state.state.speed;
                    list.Add(clipData);
                }
            }
            for (int i = 0; i != stateMachine.stateMachines.Length; ++i)
            {
                list.AddRange(GetClipsFromStatemachine(stateMachine.stateMachines[i].stateMachine));
            }

            list = list.Select(q => (AnimClipData)q).Distinct().ToList();

            return(list);
        }