本文整理汇总了C#中UnityEngine.Animation.RemoveClip方法的典型用法代码示例。如果您正苦于以下问题:C# Animation.RemoveClip方法的具体用法?C# Animation.RemoveClip怎么用?C# Animation.RemoveClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animation
的用法示例。
在下文中一共展示了Animation.RemoveClip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAnimation
public static AnimationClip SetAnimation(Animation tarAnimation, int tarIndex, AnimationClip srcClip)
{
int nCount = 0;
AnimationClip[] backClip = new AnimationClip[tarAnimation.GetClipCount() - tarIndex + 1];
foreach (AnimationState clip in tarAnimation)
{
if (tarIndex == nCount)
tarAnimation.RemoveClip(clip.clip);
if (tarIndex < nCount)
{
backClip[nCount - tarIndex - 1] = clip.clip;
tarAnimation.RemoveClip(clip.clip);
}
}
tarAnimation.AddClip(srcClip, srcClip.name);
for (int n = 0; n < backClip.Length; n++)
tarAnimation.AddClip(backClip[n], backClip[n].name);
return srcClip;
}
示例2: CleanUnusedClips
/**
* <summary>Cleans the supplied Animation component of any clips not being played.</summary>
* <param name = "_animation">The Animation component to clean</param>
*/
public static void CleanUnusedClips(Animation _animation)
{
// Remove any non-playing animations
List <string> removeClips = new List <string>();
foreach (AnimationState state in _animation)
{
if (!_animation [state.name].enabled)
{
// Queued animations get " - Queued Clone" appended to it, so remove
int queueIndex = state.name.IndexOf (" - Queued Clone");
if (queueIndex > 0)
{
removeClips.Add (state.name.Substring (0, queueIndex));
}
else
{
removeClips.Add (state.name);
}
}
}
foreach (string _clip in removeClips)
{
_animation.RemoveClip (_clip);
}
}
示例3: Initialize
protected void Initialize(Animation animation, Transform transform, string newName = null)
{
if (clip == null)
{
Debug.LogError ("clip is null. Cannot initialize animation " + (name == null ? "NULL" : name));
return;
}
animation.RemoveClip (Name);
if (newName != null)
name = newName;
animation.AddClip (clip, Name);
animation [Name].layer = Layer;
foreach(var mt in MixingTransforms)
{
if (AnimationNames.ContainsKey(mt) && transform.Find (AnimationNames [mt]) != null && transform != null)
animation [Name].AddMixingTransform (transform.Find (AnimationNames [mt]));
else
Debug.LogError ("[assembly: " + Assembly.GetExecutingAssembly ().GetName().Name + "]: animation mixing transform " + mt + " from animation " + Name + " does not exist, or could not be found.");
}
}
示例4: metcrossfadetransitionanimation
public static int metcrossfadetransitionanimation(Transform varpcharacter, string varpdestinationanimname, float varptransitiontime, Transform varpcontroller = null, string varpstateanimationname = "", bool varpgokinematic = true, string varpnewanimname = "transition", Animation varpanimationsystem = null, SkinnedMeshRenderer varprenderer = null, clsurganimationstatesmanager varpstatesmanager = null)
{
if (varpcharacter == null)
{
return -1;
}
if (varptransitiontime == 0f)
{
return -2;
}
if (varpanimationsystem == null)
{
varpanimationsystem = varpcharacter.root.GetComponentInChildren<Animation>();
if (varpanimationsystem == null)
{
return -3;
}
varpanimationsystem.Stop();
}
if (varprenderer == null)
{
varprenderer = varpcharacter.root.GetComponentInChildren<SkinnedMeshRenderer>();
if (varprenderer == null)
{
return -4;
}
}
if (varpgokinematic)
{
clsurgutils.metgodriven(varpcharacter, true);
}
Vector3 localPosition = default(Vector3);
if (varpcontroller != null)
{
Vector3 position = varpcharacter.position;
varpcontroller.position = position;
varpcharacter.localPosition = localPosition;
}
AnimationClip animationClip = clsurgutils.metcreatetransitionanimation(varpcharacter, varpdestinationanimname, varptransitiontime, varpnewanimname, ref localPosition, varpstatesmanager, false);
if (animationClip != null)
{
varpanimationsystem.Stop();
AnimationState animationState = varpanimationsystem[varpdestinationanimname];
if (animationState != null && animationState.name != varpdestinationanimname)
{
varpanimationsystem.RemoveClip(varpnewanimname);
}
varpanimationsystem.AddClip(animationClip, varpnewanimname);
if (varpstateanimationname != string.Empty)
{
varpanimationsystem[varpnewanimname].wrapMode = WrapMode.Once;
varpanimationsystem.CrossFade(varpnewanimname);
varpanimationsystem.CrossFadeQueued(varpstateanimationname);
}
else
{
varpanimationsystem.CrossFade(varpnewanimname);
}
return 1;
}
Debug.LogError("Could not create transition");
return -5;
}