本文整理匯總了C#中UnityEngine.Animation.GetClip方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.GetClip方法的具體用法?C# Animation.GetClip怎麽用?C# Animation.GetClip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UnityEngine.Animation
的用法示例。
在下文中一共展示了Animation.GetClip方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: loadBeetle1Anim
private static void loadBeetle1Anim(Animation animation)
{
//攻擊
AnimationEvent eStrike = new AnimationEvent();
eStrike.functionName = "OnStrike";
AnimationEvent eStrikeEnd = new AnimationEvent();
eStrikeEnd.time = 1.63f;
eStrikeEnd.functionName = "OnStrikeEnd";
AnimationClip strikeClip = animation.GetClip("beetle1_strike");
strikeClip.events = new AnimationEvent[] { eStrike, eStrikeEnd };
//受擊
AnimationEvent eStriked = new AnimationEvent();
eStriked.time = 0.66f;
eStriked.functionName = "OnStrikedEnd";
AnimationClip strikedClip = animation.GetClip("beetle1_striked");
strikedClip.events = new AnimationEvent[] { eStriked };
//死亡
AnimationEvent eDyingEnd = new AnimationEvent();
eDyingEnd.time = 1.3f;
eDyingEnd.functionName = "OnDyingEnd";
AnimationClip dieClip = animation.GetClip("beetle1_die");
dieClip.events = new AnimationEvent[] { eDyingEnd };
}
示例2: loadFlower1Anim
private static void loadFlower1Anim(Animation animation)
{
//攻擊
AnimationEvent eStrikeEnd = new AnimationEvent();
eStrikeEnd.time = 1.8f;
eStrikeEnd.functionName = "OnStrikeEnd";
AnimationClip strikeClip = animation.GetClip("flower1_strike");
strikeClip.events = new AnimationEvent[] { eStrikeEnd };
//死亡
AnimationEvent eDyingEnd = new AnimationEvent();
eDyingEnd.time = 1.7f;
eDyingEnd.functionName = "OnDyingEnd";
AnimationClip dieClip = animation.GetClip("flower1_die");
dieClip.events = new AnimationEvent[] { eDyingEnd };
}
示例3: Start
// Use this for initialization
public virtual void Start()
{
loopedAnimations.Add ("idle");
loopedAnimations.Add ("walk");
loopedAnimations.Add ("sprint");
loopedAnimations.Add ("run");
loopedAnimations.Add ("idle_settle");
loopedAnimations.Add ("idle_lookaround");
GameObject gobj = gameObject;
ParentObjectName = gobj.name;
try
{
while( gobj.transform.parent.gameObject != null )
{
ParentObjectName = gobj.name;
gobj = gobj.transform.parent.gameObject;
}
}
catch{}
// always start NOT engaged in combat.
EngagedInCombat = false;
// Ensure nav targets list object is instantiated
// and available for all subclassed from it.
// always default the list to "Finish"
//defaultNavTargets = new List<eNavTargets>();
//defaultNavTargets.Add(eNavTargets.Finish);
// load NavAgent for each
navAgent = (NavMeshAgent)GetComponent("NavMeshAgent");
// pre-load animation component that is used on most elements
animComponent = (Animation)GetComponent("Animation");
// First time in for any animated element, don't allow the to have
// the same exact speed. 100 humans can all have slightly different
// speeds within their base range. Don't change every time they are
// moving between objects. Why sometimes slow, then fast. The speed
// is the speed for the duration of the human's life (same with running)
origBaseSpeed = baseSpeed;
origRunSpeed = runSpeed;
//AdjustSpeeds();
// animation modes are independent per specific clip.
// walk is ALWAYS a looping
foreach (string loopAnim in loopedAnimations)
{
AnimationClip ac = animComponent.GetClip(loopAnim);
if (ac != null)
ac.wrapMode = WrapMode.Loop;
}
//AnimationClip ac = animComponent.GetClip ("walk");
//ac.wrapMode = WrapMode.Loop;
animComponent.Play ();
// Initiate first target and set destination to it
moveToNewTarget();
}
示例4: SetAni
public static void SetAni( Animation _animation, AnimationClip aniIn, int layerIn, WrapMode wrapModeIn)
{
if( aniIn != null ) {
try {
if( _animation.GetClip( aniIn.name ) != null ) {
_animation[ aniIn.name ].wrapMode = wrapModeIn;
_animation[ aniIn.name ].layer = layerIn;
}
} catch( System.Exception ex ) {
Debug.LogWarning( ex.Message + aniIn.name + " From: " + _animation.gameObject.name );
}
}
}
示例5: SetAnis
public static void SetAnis( Animation _animation, AnimationClip[] anisIn, int layerIn, WrapMode wrapModeIn, bool bSyncLayer = false )
{
for( int i = 0; i < anisIn.Length; i++ ) {
if( anisIn[ i ] != null ) {
try {
if( _animation.GetClip( anisIn[ i ].name ) != null ) {
_animation[ anisIn[ i ].name ].wrapMode = wrapModeIn;
_animation[ anisIn[ i ].name ].layer = layerIn;
}
} catch( System.Exception ex ) {
Debug.LogWarning( ex.Message + anisIn[ i ].name + " From: " + _animation.gameObject.name );
}
}
}
if( bSyncLayer ) {
_animation.SyncLayer( layerIn );
}
}
示例6: Start
// Use this for initialization
void Start()
{
animation = this.gameObject.GetComponent<Animation>();
attackLength = animation.GetClip("Attack").length;
playerHealthManager = player.GetComponent<HealthManager>();
}
示例7: edit
private void edit()
{
anim = GetComponentInChildren<Animation>();
Debug.Log(anim,anim);
runAnim = anim.GetClip("run");
attackAnim.Clear();
for (int i = 1; i < 6; i++)
if (anim["attack" + i] != null)
attackAnim.Add(anim.GetClip("attack" + i));
dances.Clear();
for (int i = 1; i < 10; i++)
if (anim["dance" + i] != null)
dances.Add(anim.GetClip("dance" + i));
idleAnim = Anim("idle");
hitAnim = Anim("hit");
hitCAnim = Anim("hitCritical");
wakeup = Anim("wakeup");
standUp = Anim("standUp");
castUp = Anim("castup");
walkAnim = Anim("walk", true);
crawlAnim = Anim("crawl");
throwAnim = Anim("throw");
SetDirty();
}
示例8: loadTanglanAnim
private static void loadTanglanAnim(Animation animation)
{
//攻擊
AnimationEvent eStrike = new AnimationEvent();
eStrike.functionName = "OnStrike";
AnimationEvent eStrikeEnd = new AnimationEvent();
eStrikeEnd.time = 0.96f;
eStrikeEnd.functionName = "OnStrikeEnd";
AnimationClip strikeClip = animation.GetClip("tanglan_strike");
strikeClip.events = new AnimationEvent[] { eStrike, eStrikeEnd };
//受擊
AnimationEvent eStriked = new AnimationEvent();
eStriked.time = 0.46f;
eStriked.functionName = "OnStrikedEnd";
AnimationClip strikedClip = animation.GetClip("tanglan_striked");
strikedClip.events = new AnimationEvent[] { eStriked };
//死亡
AnimationEvent eDyingEnd = new AnimationEvent();
eDyingEnd.time = 1.13f;
eDyingEnd.functionName = "OnDyingEnd";
AnimationClip dieClip = animation.GetClip("tanglan_die");
dieClip.events = new AnimationEvent[] { eDyingEnd };
}
示例9: Setup
public void Setup()
{
animator = GetComponentInChildren<Animation>();
if (CanAnimate = (animator .IsNotNull ()))
{
//States
idlingClip = animator.GetClip (idling);
movingClip = animator.GetClip (moving);
engagingClip = animator.GetClip (engaging);
dyingClip = animator.GetClip (dying);
//Impulses
fireClip = animator.GetClip (fire);
}
}
示例10: Start
void Start()
{
_animation = this.GetComponent<Animation>();
_animation.Play("Idle");
AnimationEvent _event = new AnimationEvent();
_event.time = _animation.GetClip("Attack").length;
_event.functionName = "AudioPlay";
if (this.GetComponent<Animation>().GetClip("Back") != null)
{
this.GetComponent<Animation>()["Back"].speed = -0.5f;
}
if (this.GetComponent<Animation>().GetClip("Charge") != null)
{
this.GetComponent<Animation>()["Charge"].speed = 4;
_event = new AnimationEvent();
_event.time = 0;
_event.functionName = "PlayChargeAudio";
_animation.GetClip("Charge").AddEvent(_event);
print("addedd Hit");
}
if (this.GetComponent<Animation>().GetClip("Hit") != null)
{
this.GetComponent<Animation>()["Hit"].speed = 0.5f;
_event = new AnimationEvent();
_event.time = 0;
_event.functionName = "PlayHitAudio";
_animation.GetClip("Hit").AddEvent(_event);
print("addedd Hit");
}
if (this.GetComponent<Animation>().GetClip("Block") != null)
{
this.GetComponent<Animation>()["Block"].speed = 1f;
_event = new AnimationEvent();
_event.time = 0;
_event.functionName = "PlayHitAudio";
_animation.GetClip("Block").AddEvent(_event);
print("addedd Hit");
}
if (this.GetComponent<Animation>().GetClip("Dead") != null)
{
this.GetComponent<Animation>()["Dead"].speed = 1f;
_event = new AnimationEvent();
_event.time = 0;
_event.functionName = "PlayDeadAudio";
_animation.GetClip("Dead").AddEvent(_event);
print("addedd Hit");
}
if (this.GetComponent<Animation>().GetClip("Run") != null)
{
_event = new AnimationEvent();
_event.time = _animation.GetClip("Run").length /2;
_event.functionName = "PlayRunAudio";
_animation.GetClip("Run").AddEvent(_event);
print("Added Run Animation");
}
if (this.GetComponent<Animation>().GetClip("Attack") != null){
this.GetComponent<Animation>()["Attack"].speed = 1.5f;
}
if(this.GetComponent<AudioSource>() == null){
this.gameObject.AddComponent<AudioSource>();
}
}
示例11: BakeSkinnedMesh
private void BakeSkinnedMesh(Animation animation, SkinnedMeshRenderer skinnedMeshRenderer)
{
int clipIndex = 0;
foreach (AnimationState clipState in animation)
{
//Prep animation clip for sampling
var curClip = this.AnimationClipsToBake[clipIndex] = animation.GetClip(clipState.name);
animation.Play(clipState.name, PlayMode.StopAll);
clipState.time = 0;
clipState.wrapMode = WrapMode.Clamp;
//Calculate number of meshes to bake in this clip sequence based on the clip's sampling framerate
uint numberOfFrames = (uint)Mathf.RoundToInt(curClip.frameRate * curClip.length);
var curBakedMeshSequence = this.BakedClips[clipIndex] = new MeshSequence(numberOfFrames);
for (uint frameIndex = 0; frameIndex < numberOfFrames; frameIndex++)
{
//Bake sequence of meshes
var curMeshFrame = curBakedMeshSequence[frameIndex] = new Mesh();
curMeshFrame.name = string.Format(@"{0}_Baked_{1}_{2}", this.name, clipIndex, frameIndex);
animation.Sample();
skinnedMeshRenderer.BakeMesh(curMeshFrame);
clipState.time += (1.0f / curClip.frameRate);
}
animation.Stop();
clipIndex++;
}
}