當前位置: 首頁>>代碼示例>>C#>>正文


C# SkeletonData.FindAnimation方法代碼示例

本文整理匯總了C#中Spine.SkeletonData.FindAnimation方法的典型用法代碼示例。如果您正苦於以下問題:C# SkeletonData.FindAnimation方法的具體用法?C# SkeletonData.FindAnimation怎麽用?C# SkeletonData.FindAnimation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spine.SkeletonData的用法示例。


在下文中一共展示了SkeletonData.FindAnimation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExtractAnimation

	static AnimationClip ExtractAnimation (string name, SkeletonData skeletonData, Dictionary<int, List<string>> slotLookup, bool bakeIK, SendMessageOptions eventOptions, AnimationClip clip = null) {
		var animation = skeletonData.FindAnimation(name);

		var timelines = animation.Timelines;

		if (clip == null) {
			clip = new AnimationClip();
		} else {
			clip.ClearCurves();
			AnimationUtility.SetAnimationEvents(clip, new AnimationEvent[0]);
		}

#if UNITY_5

#else
		AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Generic);
#endif

		clip.name = name;

		Skeleton skeleton = new Skeleton(skeletonData);

		List<int> ignoreRotateTimelineIndexes = new List<int>();

		if (bakeIK) {
			foreach (IkConstraint i in skeleton.IkConstraints) {
				foreach (Bone b in i.Bones) {
					int index = skeleton.FindBoneIndex(b.Data.Name);
					ignoreRotateTimelineIndexes.Add(index);
					BakeBone(b, animation, clip);
				}
			}
		}

		foreach (Bone b in skeleton.Bones) {
			if (b.Data.InheritRotation == false) {
				int index = skeleton.FindBoneIndex(b.Data.Name);

				if (ignoreRotateTimelineIndexes.Contains(index) == false) {
					ignoreRotateTimelineIndexes.Add(index);
					BakeBone(b, animation, clip);
				}
			}
		}

		foreach (Timeline t in timelines) {
			skeleton.SetToSetupPose();

			if (t is ScaleTimeline) {
				ParseScaleTimeline(skeleton, (ScaleTimeline)t, clip);
			} else if (t is TranslateTimeline) {
				ParseTranslateTimeline(skeleton, (TranslateTimeline)t, clip);
			} else if (t is RotateTimeline) {
				//bypass any rotation keys if they're going to get baked anyway to prevent localEulerAngles vs Baked collision
				if (ignoreRotateTimelineIndexes.Contains(((RotateTimeline)t).BoneIndex) == false)
					ParseRotateTimeline(skeleton, (RotateTimeline)t, clip);
			} else if (t is AttachmentTimeline) {
				ParseAttachmentTimeline(skeleton, (AttachmentTimeline)t, slotLookup, clip);
			} else if (t is EventTimeline) {
				ParseEventTimeline((EventTimeline)t, clip, eventOptions);
			}

		}

		var settings = AnimationUtility.GetAnimationClipSettings(clip);
		settings.loopTime = true;
		settings.stopTime = Mathf.Max(clip.length, 0.001f);

		SetAnimationSettings(clip, settings);

		clip.EnsureQuaternionContinuity();

		EditorUtility.SetDirty(clip);

		return clip;
	}
開發者ID:wenhaoisbad,項目名稱:kxsm,代碼行數:76,代碼來源:SkeletonBaker.cs


注:本文中的Spine.SkeletonData.FindAnimation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。