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


C# Animation.CrossFade方法代碼示例

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


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

示例1: RollTrack

 private void RollTrack(Animation track, int defaultRollTime)
 {
     if (track != null)
     {
         track.CrossFade("10107_Trap01");
         SetNextRoll(track, defaultRollTime);
     }
 }
開發者ID:lbddk,項目名稱:ahzs-client,代碼行數:8,代碼來源:IronRail.cs

示例2: LoopAnimation

    private void LoopAnimation(string thisAnimation, Animation anim)
    {
        anim.wrapMode = WrapMode.Loop;

        anim.CrossFade(thisAnimation);

        anim[thisAnimation].time = Random.Range(0f, 3f);
    }
開發者ID:VincentHui,項目名稱:fireworks,代碼行數:8,代碼來源:CrowdController.cs

示例3: Start

    // Use this for initialization
    void Start()
    {
        EnemyHealth = 10;
        nextAction = Time.time;
        an = GetComponent<Animation>();

        an.CrossFade ("run");
    }
開發者ID:h27han,項目名稱:Unity-Fight-Game,代碼行數:9,代碼來源:EnemyControl.cs

示例4: Start

 void Start()
 {
     smooth = 5.0f;
     scaler = 25.0f;
     walkingSpeed = 5.0f;
     velocity = Vector3.zero;
     anim = GetComponent<Animation> ();
     anim.CrossFade ("soldierIdleRelaxed");
     previousValidPos = transform.position;
 }
開發者ID:15466Group,項目名稱:Project2_Old,代碼行數:10,代碼來源:GoalControl.cs

示例5: MirrorCharacterAnimations

 void MirrorCharacterAnimations()
 {
     if (mirrorCharacterAnim) {
         animation = transform.Find("Model").GetComponent<Animation>();
         if (animation != null) {
             if (originalController == null) {
                 originalController = original.GetComponent<Character>().controller;
             }
             animation[originalController.animationPlaying].speed = originalController.animationSpeed;
             animation.CrossFade(originalController.animationPlaying);
         }
     }
 }
開發者ID:MedeirosMarcelo,項目名稱:TowerFall,代碼行數:13,代碼來源:ObjectReflection.cs

示例6: Start

 public void Start()
 {
     string audioClipName = GetParameter(0);
     string animationClipName = GetParameter(1);
     finalClipName = GetParameter(2);
     subject = GetSubject(3);
     anim = (subject == null) ? null : subject.GetComponent<Animation>();
     AudioClip audioClip = (!string.IsNullOrEmpty(audioClipName)) ? (DialogueManager.LoadAsset(audioClipName) as AudioClip) : null;
     if ((subject == null) || (anim == null)) {
         if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: No Animation component found on {3}.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, (subject != null) ? subject.name : GetParameter(2) }));
     } else if (audioClip == null) {
         if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: Clip is null.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, subject.name }));
     } else if (string.IsNullOrEmpty(animationClipName)) {
         if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: Animation name is blank.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, subject.name }));
     } else {
         if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4})", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, Tools.GetObjectName(subject) }));
         audioSource = SequencerTools.GetAudioSource(subject);
         if (audioSource == null) {
             if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice() command: can't find or add AudioSource to {1}.", new System.Object[] { DialogueDebug.Prefix, subject.name }));
         } else {
             if (IsAudioMuted()) {
                 if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}): Audio is muted; not playing it.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, Tools.GetObjectName(subject) }));
             } else {
                 //--- Was, prior to implementing pause: audioSource.PlayOneShot(audioClip);
                 audioSource.clip = audioClip;
                 audioSource.Play();
             }
             anim.CrossFade(animationClipName);
             try {
                 stopTime = DialogueTime.time + Mathf.Max(0.1f, anim[animationClipName].length - 0.3f);
                 if (audioClip.length > anim[animationClipName].length) stopTime = DialogueTime.time + audioClip.length;
             } catch (System.Exception) {
                 stopTime = 0;
             }
         }
     }
 }
開發者ID:farreltr,項目名稱:OneLastSunset,代碼行數:37,代碼來源:SequencerCommandVoice.cs

示例7: Starta

    // Use this for initialization
    public void Starta(GameObject plane, GameObject swamps, float nodeSize)
    {
        fixedDeadCollider = false;

        poi = Vector3.zero;
        health = 100.0f;
        seesPlayer = false;
        seesDeadPeople = false;
        hearsSomething = false;
        disturbed = false;

        reachGoal = GetComponent<ReachGoal> ();
        wander = GetComponent<Wander> ();
        standstill = GetComponent<StandStill> ();
        patrol = GetComponent<Patrol> ();
        gc = player.GetComponent<GoalControl> ();

        reachGoal.plane = plane;
        reachGoal.swamps = swamps;
        reachGoal.nodeSize = nodeSize;
        reachGoal.goalPos = poi;
        reachGoal.Starta ();
        wander.Starta ();
        patrol.Starta ();
        standstill.Starta ();
        anim = GetComponent<Animation> ();
        anim.CrossFade (idle);
        walkingSpeed = 10.0f;
        gunShot = this.GetComponents<AudioSource> ()[0];

        lr = this.GetComponentInParent<LineRenderer> ();
        seenTime = 0f;
        //		Debug.Log (transform.name);
    }
開發者ID:15466Group,項目名稱:ProjectDemo,代碼行數:35,代碼來源:MasterBehaviour.cs

示例8: SwitchSkin

    public void SwitchSkin(GameObject skin)
    {
        Vector3 current_pos = player.transform.position;
        Vector3 current_rot = player.transform.eulerAngles;
        Vector3 current_scale = player.transform.localScale;

        player = skin;
        player.transform.position = current_pos;
        player.transform.eulerAngles = current_rot;
        player.transform.localScale = current_scale;

        animations = player.GetComponent<Animation>();
        animations.CrossFade(stateAnimation[animationState]);

        ShouldSwitch = false;
    }
開發者ID:hydna,項目名稱:hydna-unity-chicken-demo,代碼行數:16,代碼來源:ChickenPlayer.cs

示例9: QueueIdle

 private IEnumerator QueueIdle(Animation source)
 {
     while (source.IsPlaying(_ClipName))
         yield return new WaitForFixedUpdate();
     source.CrossFade(AnimationResources.Idle);
 }
開發者ID:DR9885,項目名稱:Possessed,代碼行數:6,代碼來源:DialogueAnimationEvent.cs

示例10: Start

 // Use this for initialization
 public virtual void Start()
 {
     velocity = new Vector3 ();
     acceleration = new Vector3 ();
     accMagDefault = 50.0f;
     speedMaxDefault = 20.0f;
     walkingSpeed = 15.0f;
     epsilon = 2.0f;
     searchRadius = 100.0f;
     rayDistDefault = 20.0f;
     rayDist = rayDistDefault;
     closeRayDistDefault = 7.0f;
     closeRayDist = closeRayDistDefault;
     charWidth = 5.0f;
     smooth = 5.0f;
     obstacleWeight = 3.0f;
     charWeight = 1.0f;
     accMag = accMagDefault;
     speedMax = speedMaxDefault;
     anim = GetComponent<Animation> ();
     anim.CrossFade ("idle");
 }
開發者ID:15466Group,項目名稱:Project1,代碼行數:23,代碼來源:workingMessyBehavior.cs

示例11: Start

 void Start()
 {
     radius = 2.0f;
     smooth = 5.0f;
     scaler = 20.0f;
     walkingSpeed = 5.0f;
     velocity = Vector3.zero;
     anim = GetComponent<Animation> ();
     anim.CrossFade (idle);
     previousValidPos = transform.position;
     soldierLayer = 1 << (LayerMask.NameToLayer("Soldier"));
     obstacleLayer = 1 << (LayerMask.NameToLayer("Obstacles"));
     health = 20;
     healthTex = new Texture2D(1, 1);
     healthTex.SetPixel(0,0,Color.green);
     healthTex.Apply();
 }
開發者ID:15466Group,項目名稱:Project3,代碼行數:17,代碼來源:GoalControl.cs

示例12: Start

    //methods
    // Use this for initialization
    public virtual void Start()
    {
        anim = GetComponent<Animation>();

        velocity = new Vector3 ();
        nextPosition = new Vector3 (); //position where char wants to move to next
        acceleration = new Vector3 ();
        targetAccel = new Vector3 ();
        accMag = 50.0f;
        maxRadsDelta = Mathf.Deg2Rad * 20.0f;
        maxMagDelta = 100.0f;
        maxSpeed = 20.0f;

        behaviorWeight = 1.0f;

        smooth = 5.0f;
        walkingSpeed = 20.0f;

        randomRad = 0.0f;

        charWidth = 5.0f;
        rayDist = 30.0f;
        rayDistMax = rayDist;
        originalMaxSpeed = maxSpeed;
        rayDistClose = 5.0f;

        anim.CrossFade ("idle");
        count = 0;
    }
開發者ID:15466Group,項目名稱:Project1,代碼行數:31,代碼來源:BehaviorClass.cs

示例13: 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;
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:63,代碼來源:clsurgutils.cs

示例14: SpecialAttack

 public void SpecialAttack(Animation _anim, GameObject _target, float _dmg)
 {
     _anim.CrossFade("Special");
     _target.GetComponent<PlayerObject>().ApplyDamage(_dmg * 2);
     useSpecial = false;
     this.hasAttacked = true;
 }
開發者ID:jkevinp,項目名稱:SciHeroes,代碼行數:7,代碼來源:PlayerObject.cs

示例15: Attack

 public void Attack(Animation _anim , GameObject _target , float _dmg)
 {
     _anim.CrossFade("Attack");
     _target.GetComponent<PlayerObject>().ApplyDamage(_dmg);
     this.hasAttacked = true;
 }
開發者ID:jkevinp,項目名稱:SciHeroes,代碼行數:6,代碼來源:PlayerObject.cs


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