public bool PlayAnimation(string path, AnimPlayType type, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.15f, float time = 0.0f, bool async = true) { if (type == AnimPlayType.Priority) { Debug.LogError("高优先级动画请用PlayPriorityAnimation播放!"); return(false); } if (string.IsNullOrEmpty(path)) { return(false); } if (async) { // 未来Lambda改成Request ResourceSystem.LoadAsync <AnimationClip>(path, (o) => { AnimationClip c = o as AnimationClip; if (c == null) { return; } PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time); }); } else { AnimationClip c = ResourceSystem.Load <AnimationClip>(path); if (c == null) { return(false); } PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time); } return(true); }
public ModSubAnimationDfnXml this[AnimPlayType playType] { get { return(SubAnimations.Where(o => o.PlayType == playType).FirstOrDefault()); } }
protected void MixingClip(AnimationState state, AnimPlayType type) { if (type == AnimPlayType.Up) { Transform up = mAnimation.transform.Find(mBoneUpFull); if (up != null) { state.AddMixingTransform(up); } } else if (type == AnimPlayType.Down) { int i = 0; Transform root = mAnimation.transform; do { Transform t = root.Find(mBoneRoot[i]); if (t != null) { state.AddMixingTransform(t, false); } ++i; root = t; }while (root != null && i < mBoneRoot.Length); if (root != null) { for (i = 0; i < root.childCount; ++i) { Transform t = root.GetChild(i); if (t.name.Equals("Bip01 Spine")) { state.AddMixingTransform(t, false); for (int j = 0; j < t.childCount; ++j) { Transform linkspine = t.GetChild(j); if (linkspine.name.Contains("Bip")) { if (!linkspine.name.Contains("Spine1")) { state.AddMixingTransform(linkspine); } } } } else if (t.name.Contains("Bone")) { state.AddMixingTransform(t); } } } } }
public bool PlayAnimation(int id, AnimPlayType type, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.15f, float time = 0.0f, bool async = true) { excel_anim_list animList = excel_anim_list.Find(id); if (animList == null) { Debug.LogError("未找到ID为" + id + "的动画表"); return(false); } string path = mAnimPath + animList.name; return(PlayAnimation(path, type, speed, loop, reverse, fadeLength, time, async)); }
/// <summary> /// 动画组播放类型 /// </summary> private void DrawAnimPlayType() { EditorUI.SetLabelWidth(65); EditorGUILayout.BeginHorizontal(); GUILayout.Label("播放类型:", UIStyles.Label_13_White, GUILayout.Width(60)); AnimPlayType apt = (AnimPlayType)EditorGUILayout.EnumPopup(APT, GUILayout.Width(150)); if (apt != APT) { APT = apt; } EditorGUILayout.EndHorizontal(); EditorUI.SetLabelWidth(80); }
public void SetAnimTime(AnimPlayType type, float time) { string animName = mCurAnimNames[(int)type]; if (string.IsNullOrEmpty(animName)) { return; } AnimationState state = mAnimation[animName]; if (state == null) { return; } state.time = time; }
public void StopClip(AnimPlayType type = AnimPlayType.All) { if (type == AnimPlayType.All) { for (int i = 0; i < mCurAnimNames.Length; ++i) { string sAnimName = mCurAnimNames[i]; StopClip(sAnimName); mCurAnimNames[i] = ""; } return; } string animName = mCurAnimNames[(int)type]; StopClip(animName); mCurAnimNames[(int)type] = ""; }
static void PlayAnimation(Character cha, ChildObject childObject, SkillContext context, excel_skill_event e) { if (cha == null) { return; } int id = e.evnetParam1; int trait = e.evnetParam2; bool loop = ((trait & 0x1) != 0); bool reverse = ((trait & 0x2) != 0); bool onlyup = ((trait & 0x4) != 0); bool highPriority = ((trait & 0x8) != 0); float time = 0.03333f * (float)e.evnetParam3; float speed = 1.0f; if (e.evnetParam4 > 0) { speed = (float)e.evnetParam5 * 0.001f; } AnimPlayType animType = AnimPlayType.General; if (onlyup) { animType = AnimPlayType.Up; cha.PlayAnimation(id, animType, speed, loop, reverse, 0.0f, time); } else { if (highPriority) { cha.PlayPriorityAnimation(id, AnimPriority.Skill, speed, loop, reverse, 0.0f, time); } else { cha.PlayAnimation(id, AnimPlayType.General, speed, loop, reverse, 0.0f, time); } } context.mPlayingAnimations.Add(id); }
public AnimationState PlayClipAnimation(AnimationClip clip, string animName, AnimPlayType type = AnimPlayType.General, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.3f, float time = 0.0f) { if (mAnimation == null) { return(null); } if (!clip.legacy) { clip.legacy = true; } if (mLastPlayTypes.ContainsKey(animName)) { AnimPlayType lastType = mLastPlayTypes[animName]; if (lastType != type) { RemoveClip(animName, false); } } int layer = mAnimTypeLayer[(int)type]; AnimationState state = mAnimation[animName]; if (state != null && state.clip != clip) { RemoveClip(animName, false); state = mAnimation[animName]; } if (state == null) { mAnimation.AddClip(clip, animName); mLastPlayTypes[animName] = type; state = mAnimation[animName]; if (layer == 2) { MixingClip(state, type); } } else if (loop && state.wrapMode == WrapMode.Loop && mCurAnimNames[(int)type] == animName) { if ((reverse && state.speed < 0.0f) || (!reverse && state.speed > 0.0f)) { return(state); } } state.layer = layer; if (type == AnimPlayType.Addition) { state.blendMode = AnimationBlendMode.Additive; state.wrapMode = WrapMode.Once; mCurAnimNames[(int)type] = animName; } else { state.blendMode = AnimationBlendMode.Blend; if (loop) { state.wrapMode = WrapMode.Loop; } else if (type == AnimPlayType.Base) { // 播完停最后一帧; state.wrapMode = WrapMode.ClampForever; } else { state.wrapMode = WrapMode.Once; } if (layer == 1) { StopClip(type); } mCurAnimNames[(int)type] = animName; } if (reverse) { state.time = clip.length - time; state.speed = -speed; } else { state.time = time; state.speed = speed; } if (type == AnimPlayType.Addition) { state.weight = 1.0f; state.enabled = true; } else { if (layer == 2) { mAnimation.Blend(animName, 1, fadeLength); } else { mAnimation.CrossFade(animName, fadeLength); } } return(state); }