本文整理汇总了C#中UnityEngine.AnimationClip.ClearCurves方法的典型用法代码示例。如果您正苦于以下问题:C# AnimationClip.ClearCurves方法的具体用法?C# AnimationClip.ClearCurves怎么用?C# AnimationClip.ClearCurves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AnimationClip
的用法示例。
在下文中一共展示了AnimationClip.ClearCurves方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MovePlayer
IEnumerator MovePlayer()
{
Spell rootSpell = gameObject.GetComponent<Spell>();
Transform player = rootSpell.m_myCaster.transform;
// Change animation curves relative to the player's current position
for (int i = 0; i < x.keys.Length; ++i) {
x.keys[i].value += player.position.x;
}
for (int i = 0; i < y.keys.Length; ++i) {
y.keys[i].value += player.position.y;
}
for (int i = 0; i < z.keys.Length; ++i) {
z.keys[i].value += player.position.z;
}
// Create the clip
AnimationClip clip = new AnimationClip();
clip.ClearCurves();
clip.SetCurve("", typeof(Transform), "localPosition.x", x);
clip.SetCurve("", typeof(Transform), "localPosition.y", y);
clip.SetCurve("", typeof(Transform), "localPosition.z", z);
PlayerController controller = player.GetComponent<PlayerController>();
player.networkView.RPC("LockPlayer", player.networkView.owner);
float startTime = Time.time;
while(Time.time < startTime + duration) {
}
return null;
}
示例2: addAnimation
public static void addAnimation(GameObject rootGO,
string rootDirectory,
SpineData spineData,
Dictionary<string, GameObject> boneGOByName,
Dictionary<string, Slot> slotByName,
AttachmentGOByNameBySlot attachmentGOByNameBySlot,
List<Skin> skinList,
int pixelsPerUnit,
float zStep,
bool useLegacyAnimation,
bool updateResources)
{
float ratio = 1.0f / (float)pixelsPerUnit;
foreach(KeyValuePair<string,SpineAnimation> kvp in spineData.animations){
string animationName = kvp.Key;
string animationFolder = rootDirectory+"/"+ANIMATION_FOLDER;
string assetPath = animationFolder + "/" + animationName+".anim";
SpineAnimation spineAnimation = kvp.Value;
AnimationClip animationClip = new AnimationClip();
bool updateCurve = false;
if (File.Exists(assetPath)){
AnimationClip oldClip = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AnimationClip)) as AnimationClip;
if (oldClip != null){
animationClip = oldClip;
animationClip.ClearCurves();
updateCurve = true;
}
}
animationClip.legacy = useLegacyAnimation;
if (spineAnimation.bones!=null)
addBoneAnimationToClip(animationClip,spineAnimation.bones, spineData, boneGOByName, ratio);
if (spineAnimation.slots!=null)
addSlotAnimationToClip(animationClip, spineAnimation.slots, spineData, skinList, attachmentGOByNameBySlot);
if ( spineAnimation.events != null )
AddEvents( animationClip, spineAnimation.events, animationName );
if (spineAnimation.draworder!=null)
addDrawOrderAnimation( animationClip, spineAnimation.draworder, spineData, zStep, animationName, slotByName );
if (updateCurve){
EditorUtility.SetDirty(animationClip);
AssetDatabase.SaveAssets();
} else {
animationClip.frameRate = 30;
createFolderIfNoExists(rootDirectory, ANIMATION_FOLDER);
AssetDatabase.CreateAsset(animationClip, assetPath);
AssetDatabase.SaveAssets();
if (useLegacyAnimation){
AddClipToLegacyAnimationComponent(rootGO, animationClip);
} else {
AddClipToAnimatorComponent(rootGO,animationClip);
}
}
}
}
示例3: GetAnimationClip
private static AnimationClip GetAnimationClip(Animator animator, GameObject rootObject, MoCapData data,
bool processBodyTransforms, bool processFaceTransforms, bool processFaceBlendShapes)
{
var animationClip = new AnimationClip();
animationClip.name = Path.GetFileNameWithoutExtension(DataFile);
animationClip.legacy = true;
animationClip.wrapMode = WrapMode.Once;
animationClip.frameRate = 25;
animationClip.ClearCurves();
if (data.BodyFrames != null && data.BodyFrames.Length > 0)
{
if (processBodyTransforms)
{
var transforms = new TransformTime[(int) MoCapKinectBone.Count][];
for (var i = 0; i < (int) MoCapKinectBone.Count; i++)
{
transforms[i] = new TransformTime[data.BodyFrames.Length];
for (var j = 0; j < data.BodyFrames.Length; j++)
{
transforms[i][j].Time = data.BodyFrames[j].SkeletonTransforms[i].Time;
transforms[i][j].Position = Vector3.Zero;
transforms[i][j].Rotation = MoCapBoneMapper.LocalRotation(ref data.BodyFrames[j],
(MoCapKinectBone) i);
transforms[i][j].Scale = Vector3.One;
}
}
foreach (MoCapKinectBone kinectBone in Enum.GetValues(typeof (MoCapKinectBone)))
if (MoCapBoneMapper.IsValidKinectBone(kinectBone))
{
var mecanimBone = MoCapBoneMapper.Kinect2Mecanim(kinectBone);
if (MoCapBoneMapper.IsValidMecanimBone(mecanimBone))
SetAnimationCurvesForBody(animator, rootObject, transforms[(int) kinectBone], animationClip,
mecanimBone, false, true, false);
}
}
}
if (data.FaceFrames != null && data.FaceFrames.Length > 0)
{
if (processFaceTransforms)
{
var transforms = new TransformTime[data.FaceFrames.Length];
for (var i = 0; i < data.FaceFrames.Length; i++)
{
transforms[i].Time = data.FaceFrames[i].FaceTransform.Time;
transforms[i].Position = Vector3.Zero;
transforms[i].Rotation = new Quaternion(-data.FaceFrames[i].FaceTransform.Rotation.X,
data.FaceFrames[i].FaceTransform.Rotation.Y, data.FaceFrames[i].FaceTransform.Rotation.Z,
data.FaceFrames[i].FaceTransform.Rotation.W);
transforms[i].Scale = Vector3.One;
}
SetAnimationCurvesForBody(animator, rootObject, transforms, animationClip, MoCapMecanimBone.Head, false,
true, false);
}
if (processFaceBlendShapes)
{
var weights =
new List<KeyValuePair<float, float>>[(int) MoCapMixamoFacialExpression.LastBlendShape];
foreach (
MoCapKinectFacialExpression kinectFacialExpression in
Enum.GetValues(typeof (MoCapKinectFacialExpression)))
if (MoCapFacialExpressionMapper.IsValidKinectFacialExpression(kinectFacialExpression))
{
for (var j = 0; j < data.FaceFrames.Length; j++)
{
MoCapMixamoFacialExpression mixamoFacialExpression;
float mixamoWeight;
MoCapFacialExpressionMapper.Kinect2Mixamo(kinectFacialExpression,
data.FaceFrames[j].ExpressionWeights[(int) kinectFacialExpression],
out mixamoFacialExpression, out mixamoWeight);
if (MoCapFacialExpressionMapper.IsValidMixamoFacialExpression(mixamoFacialExpression))
{
if (weights[(int) mixamoFacialExpression] == null)
weights[(int) mixamoFacialExpression] =
new List<KeyValuePair<float, float>>(data.FaceFrames.Length);
weights[(int) mixamoFacialExpression].Add(
new KeyValuePair<float, float>(data.FaceFrames[j].FaceTransform.Time, mixamoWeight));
}
}
}
foreach (
MoCapMixamoFacialExpression mixamoFacialExpression in
Enum.GetValues(typeof (MoCapMixamoFacialExpression)))
if (MoCapFacialExpressionMapper.IsValidMixamoFacialExpression(mixamoFacialExpression))
if (weights[(int) mixamoFacialExpression] != null &&
weights[(int) mixamoFacialExpression].Count > 0)
SetAnimationCurvesForFace(animator, rootObject,
//.........这里部分代码省略.........
示例4: SaveToClip
public void SaveToClip(AnimationClip newClip)
{
newClip.ClearCurves ();
foreach(var data in AnimationUtility.GetAllCurves(Clip)) {
AnimationUtility.SetEditorCurve (newClip,
data.path,
data.type,
data.propertyName,
data.curve);
}
}
示例5: OnGUI
public void OnGUI()
{
EditorGUILayout.LabelField("");
var animationClips = Resources.FindObjectsOfTypeAll<AnimationClip>().ToList();
EditorGUILayout.BeginHorizontal();
int selectedAnimationClipIndex = EditorGUILayout.Popup("Animation Clips", animationClips.IndexOf(selectedAnimationClip), animationClips.Select(x => x.name).ToArray());
if (selectedAnimationClipIndex < 0)
{
selectedAnimationClipIndex = 0;
}
if (selectedAnimationClip != animationClips[selectedAnimationClipIndex] || curveInformation == null)
{
curveInformation = new CurveInformation(animationClips[selectedAnimationClipIndex].name);
}
selectedAnimationClip = animationClips[selectedAnimationClipIndex];
if (GUILayout.Button("Copy", EditorStyles.miniButton))
{
animationCurveClipboard = curveInformation.GetSelectedAnimationCurves();
}
if (GUILayout.Button("Copy All", EditorStyles.miniButton))
{
animationCurveClipboard = AnimationUtility.GetAllCurves(selectedAnimationClip, true).ToList();
}
if (GUILayout.Button("Paste", EditorStyles.miniButton))
{
Paste();
}
if (GUILayout.Button("Remove", EditorStyles.miniButton))
{
var curvesToDelete = curveInformation.GetSelectedAnimationCurves();
var allCurves = curveInformation.GetSelectedAnimationCurves(new List<AnimationClipCurveData>(), true);
selectedAnimationClip.ClearCurves();
foreach (var curveInfo in allCurves)
{
if (curveInfo == null)
{
continue;
}
if (!curvesToDelete.Contains(curveInfo))
{
InsertCurve(curveInfo);
}
}
Refresh();
}
if (GUILayout.Button("Refresh", EditorStyles.miniButton))
{
Refresh();
}
EditorGUILayout.EndHorizontal();
foreach (AnimationClipCurveData curveData in AnimationUtility.GetAllCurves(selectedAnimationClip, true))
{
UpdateCurveInformation(selectedAnimationClip.name, curveInformation, curveData);
}
scrollViewVector = EditorGUILayout.BeginScrollView(scrollViewVector);
curveInformation.DisplayCurveInformation();
EditorGUILayout.EndScrollView();
}
示例6: addAnimation
public static void addAnimation(GameObject rootGO,
string rootDirectory,
SpineData spineData,
Dictionary<string, GameObject> boneGOByName,
AttachmentGOByNameBySlot attachmentGOByNameBySlot,
int pixelsPerUnit,
ModelImporterAnimationType modelImporterAnimationType,
bool updateResources)
{
float ratio = 1.0f / (float)pixelsPerUnit;
foreach(KeyValuePair<string,SpineAnimation> kvp in spineData.animations){
string animationName = kvp.Key;
string animationFolder = rootDirectory+"/"+ANIMATION_FOLDER;
string assetPath = animationFolder + "/" + animationName+".anim";
SpineAnimation spineAnimation = kvp.Value;
AnimationClip animationClip = new AnimationClip();
bool updateCurve = false;
if (File.Exists(assetPath)){
AnimationClip oldClip = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AnimationClip)) as AnimationClip;
if (oldClip != null){
animationClip = oldClip;
animationClip.ClearCurves();
updateCurve = true;
}
}
AnimationUtility.SetAnimationType(animationClip, modelImporterAnimationType);
if (spineAnimation.bones!=null)
addBoneAnimationToClip(animationClip,spineAnimation.bones, spineData, boneGOByName, ratio);
if (spineAnimation.slots!=null)
addSlotAnimationToClip(animationClip, spineAnimation.slots, spineData, attachmentGOByNameBySlot);
if (spineAnimation.draworder!=null)
Debug.LogWarning("draworder animation implemented yet");
if (updateCurve){
EditorUtility.SetDirty(animationClip);
AssetDatabase.SaveAssets();
} else {
animationClip.frameRate = 30;
createFolderIfNoExists(rootDirectory, ANIMATION_FOLDER);
AssetDatabase.CreateAsset(animationClip, assetPath);
AssetDatabase.SaveAssets();
if (modelImporterAnimationType == ModelImporterAnimationType.Generic)
AddClipToAnimatorComponent(rootGO,animationClip);
else
AddClipToLegacyAnimationComponent(rootGO, animationClip);
}
}
}