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


C# Animation.AddClip方法代碼示例

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


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

示例1: InitAnimations

 private void InitAnimations()
 {
     animation = GetComponentInChildren<Animation> ();
     animation.AddClip (walk, "Walk");
     animation.AddClip (aim, "Aim");
     animation.AddClip (kick, "Kick");
     animation ["Walk"].layer = 0;
     animation ["Aim"].layer = 1;
     animation ["Aim"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_arm_L"));
     animation ["Aim"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_arm_R"));
     animation ["Kick"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_leg_R"));
     animation.wrapMode = WrapMode.Loop;
 }
開發者ID:WaDelma,項目名稱:PseudoRandom,代碼行數:13,代碼來源:PlayerController.cs

示例2: Start

    private float idleSwitchDelay; // A random time to play RandomIdle animation

    void Start () {
        monster = GetComponent<Monster>();
        
        animation = monster.monsterGameObject.GetComponent<Animation>();

        // Initialize monster animator
        if(animationClips.idle != null)
            animation.AddClip(animationClips.idle, "Idle");

        if(animationClips.randomIdle != null) {
            animation.AddClip(animationClips.randomIdle, "RandomIdle");

            idleSwitchDelay = (Length("Idle") * UnityEngine.Random.Range(4, 8)) + Time.time;
        }

        if(animationClips.moveForward != null)
            animation.AddClip(animationClips.moveForward, "MoveForward");
        if(animationClips.moveBackward != null)
            animation.AddClip(animationClips.moveBackward, "MoveBackward");
        if(animationClips.physicalAttack != null)
            animation.AddClip(animationClips.physicalAttack, "PhysicalAttack");
        if(animationClips.specialAttack != null)
            animation.AddClip(animationClips.specialAttack, "SpecialAttack");
        if(animationClips.takeDamage != null)
            animation.AddClip(animationClips.takeDamage, "TakeDamage");
        if(animationClips.dead != null)
            animation.AddClip(animationClips.dead, "Dead");

        Play("Idle");
    }
開發者ID:Jian881219,項目名稱:TurnBasedBattleKit,代碼行數:32,代碼來源:MonsterAnimator.cs

示例3: CreateEffect

 public override void CreateEffect()
 {
     base.CreateEffect();
     m_animation = GetComponent<Animation>();
     if( m_animation == null)
     {
         m_animation = this.gameObject.AddComponent<Animation>();
         if(ShowAnim != null)
             m_animation.AddClip(ShowAnim, "ShowAnim");
         if(HideAnim != null)
             m_animation.AddClip(HideAnim, "HideAnim");
         if(IdleAnim != null)
             m_animation.AddClip(IdleAnim, "IdelAnim");
     }
 }
開發者ID:zhenghehe2014,項目名稱:u3dframework,代碼行數:15,代碼來源:ShowAnimUIEffect.cs

示例4: Start

 // Use this for initialization
 void Start()
 {
     animation = GetComponent<Animation>();
     animation.AddClip(animationClip, "animationClip");
     animation["animationClip"].speed = speed;
     animation.wrapMode = WrapMode.Loop;
 }
開發者ID:WaDelma,項目名稱:PseudoRandom,代碼行數:8,代碼來源:SimpleAnimation.cs

示例5: TransferAnimation

    public void TransferAnimation(Animation target, Transform avatar)
    {
        Debug.LogWarning("here");
        target.AddClip(clip, clip.name);
        target[clip.name].layer = animationLayer;
        //StartCoroutine(MixingTransforms( addMixingTransforms, removeMixingTransforms, clip));
        //yield return null;

        if(addMixingTransforms.Count>0)
        {
            for (int i = 0; i < addMixingTransforms.Count; i++) {
                target[clip.name].AddMixingTransform(GetBone(addMixingTransforms[i], avatar), false);
                //yield return null;
            }
        }

        if(removeMixingTransforms.Count>0)
        {
            for (int i = 0; i < removeMixingTransforms.Count; i++)
            {
                target[clip.name].RemoveMixingTransform(GetBone(removeMixingTransforms[i], avatar));
                //yield return null;
            }
        }
    }
開發者ID:reaganq,項目名稱:mixabots,代碼行數:25,代碼來源:ArmorAnimation.cs

示例6: 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;
	}
開發者ID:Kinderril,項目名稱:p3,代碼行數:21,代碼來源:NgAnimation.cs

示例7: Create

    public void Create(Creature ac)
    {
        m_ac = ac;
        m_ac.OnDead += OnDead;
        m_ac.OnTakeDamage += OnTakeDamage;

        m_anim_ctl = ResMgr.Instance.CreateGameObject(string.Format("Creature/{0}/{1}", ac.Proto.Key, ac.Proto.Key), gameObject).GetComponent<Animation>();
        m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/FIdle", ac.Proto.Key)) as AnimationClip, "FIdle");
        m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Fight", ac.Proto.Key)) as AnimationClip, "Fight");
        m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Die", ac.Proto.Key)) as AnimationClip, "Die");
        m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Walk", ac.Proto.Key)) as AnimationClip, "Walk");
        m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/BeHit", ac.Proto.Key)) as AnimationClip, "BeHit");

        m_anim_ctl["BeHit"].layer = 2;

        m_prog_hp = ResMgr.Instance.CreateGameObject("UI/PlaneProgHP", Launcher.Instance.CanvasUI.gameObject);
        m_img_prog_hp = Util.FindGameObjectByName(m_prog_hp, "Fill").GetComponent<Image>();
        m_img_prog_hp.fillAmount = 1;

        Idle();
    }
開發者ID:drawpixel,項目名稱:DHunter,代碼行數:21,代碼來源:CreatureView.cs

示例8: TransferAnimation

    public IEnumerator TransferAnimation(Animation target, ArmorAnimation anim, Avatar avatar)
    {
        target.AddClip(anim.clip, anim.clip.name);
        target[anim.clip.name].layer = anim.animationLayer;
		target[anim.clip.name].speed = anim.speed;
        //StartCoroutine(MixingTransforms( anim.addMixingTransforms, anim.removeMixingTransforms, anim.clip));
        yield return new WaitForEndOfFrame();

		if(!anim.useWholeBody)
		{
			if(anim.useArmLBones)
			{
				target[anim.clip.name].AddMixingTransform(avatar.clavicleL, false);
				target[anim.clip.name].AddMixingTransform(avatar.shoulderL, false);
				target[anim.clip.name].AddMixingTransform(avatar.shoulderGuardL, false);
				target[anim.clip.name].AddMixingTransform(avatar.elbowL, false);
				target[anim.clip.name].AddMixingTransform(avatar.forearmL, false);
				target[anim.clip.name].AddMixingTransform(avatar.handL, false);
			}
			
			if(anim.useArmRBones)
			{
				target[anim.clip.name].AddMixingTransform(avatar.clavicleR, false);
				target[anim.clip.name].AddMixingTransform(avatar.shoulderR, false);
				target[anim.clip.name].AddMixingTransform(avatar.shoulderGuardR, false);
				target[anim.clip.name].AddMixingTransform(avatar.elbowR, false);
				target[anim.clip.name].AddMixingTransform(avatar.forearmR, false);
				target[anim.clip.name].AddMixingTransform(avatar.handR, false);
			}
			
			if(anim.useVerticalBones)
			{
				target[anim.clip.name].AddMixingTransform(avatar.spine2, false);
				target[anim.clip.name].AddMixingTransform(avatar.neckHorizontal, false);
			}
		}
        /*if(anim.addMixingTransforms.Count>0)
        {
            for (int i = 0; i < anim.addMixingTransforms.Count; i++) {
                target[anim.clip.name].AddMixingTransform(GetBone(anim.addMixingTransforms[i], avatar), false);
            }
        }
        
        if(anim.removeMixingTransforms.Count>0)
        {
            for (int i = 0; i < anim.removeMixingTransforms.Count; i++) 
            {
                target[anim.clip.name].RemoveMixingTransform(GetBone(anim.removeMixingTransforms[i], avatar));
            }
        }*/
    }
開發者ID:reaganq,項目名稱:MagnetBots_unity,代碼行數:51,代碼來源:PassiveArmorAnimationController.cs

示例9: TransferAnimation

    public IEnumerator TransferAnimation(Animation target, ArmorAnimation anim, Transform avatar)
    {
        target.AddClip(anim.clip, anim.clip.name);
        target[anim.clip.name].layer = anim.animationLayer;
        //StartCoroutine(MixingTransforms( anim.addMixingTransforms, anim.removeMixingTransforms, anim.clip));
        yield return null;

        if(anim.addMixingTransforms.Count>0)
        {
            for (int i = 0; i < anim.addMixingTransforms.Count; i++) {
                target[anim.clip.name].AddMixingTransform(GetBone(anim.addMixingTransforms[i], avatar), false);
            }
        }

        if(anim.removeMixingTransforms.Count>0)
        {
            for (int i = 0; i < anim.removeMixingTransforms.Count; i++)
            {
                target[anim.clip.name].RemoveMixingTransform(GetBone(anim.removeMixingTransforms[i], avatar));
            }
        }
    }
開發者ID:reaganq,項目名稱:mixabots,代碼行數:22,代碼來源:PassiveArmorAnimationController.cs

示例10: 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.");
     }
 }
開發者ID:Kerbas-ad-astra,項目名稱:KerbalAnimationSuite,代碼行數:20,代碼來源:KerbalAnimationClip.cs

示例11: AddClipToAnimationComponent

 public static bool AddClipToAnimationComponent(Animation animation, AnimationClip newClip)
 {
     SetClipAsLegacy(newClip);
     animation.AddClip(newClip, newClip.name);
     return true;
 }
開發者ID:demelev,項目名稱:projectHL,代碼行數:6,代碼來源:AnimationWindowUtility.cs

示例12: Start

 // Use this for initialization
 void Start()
 {
     anim = (Animation)GetComponent("Animation");
     anim.AddClip(clip,"main");
 }
開發者ID:cxdcxd,項目名稱:simserver,代碼行數:6,代碼來源:car_controller.cs

示例13: CopyAnimation

    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    static bool CopyAnimation ( Animation _src, Animation _dest ) {
        foreach ( AnimationState state in _src ) {
            _dest.AddClip(_src[state.name].clip, state.name);
        }
        _dest.clip=_src.clip;
        _dest.playAutomatically = _src.playAutomatically;
        _dest.animatePhysics = _src.animatePhysics;
        _dest.animateOnlyIfVisible = _src.animateOnlyIfVisible;
        return true;
    }
開發者ID:exdev,項目名稱:urban-survivors,代碼行數:14,代碼來源:CompHelper.cs

示例14: StarEffectAnim

    void StarEffectAnim(Animation anim, GameObject tmp)
    {
        //Debug.Break();
        anim.enabled = true;
        AnimationClip animclip = new AnimationClip();
        #if UNITY_5
                animclip.legacy = true;
        #endif
        AnimationCurve curveScalex = AnimationCurve.Linear(0, tmp.transform.localScale.x, 1, 3);
        //AnimationCurve curveScaley = AnimationCurve.Linear(0, tmp.transform.localScale.y, 1, 3);
        AnimationCurve curvex = AnimationCurve.Linear(0, tmp.transform.position.x, 1, 0);
        AnimationCurve curvey = AnimationCurve.Linear(0, tmp.transform.position.y, 1, 0);
        AnimationCurve curvez = AnimationCurve.Linear(0, tmp.transform.position.z, 1, tmp.transform.position.z);
        AnimationCurve curveColora = AnimationCurve.Linear(0, 1, 1, 0);

        animclip.SetCurve("", typeof(Transform), "m_LocalScale.x", curveScalex);
        animclip.SetCurve("", typeof(Transform), "m_LocalScale.y", curveScalex);
        animclip.SetCurve("", typeof(Transform), "localPosition.x", curvex);
        animclip.SetCurve("", typeof(Transform), "localPosition.y", curvey);
        animclip.SetCurve("", typeof(Transform), "localPosition.z", curvez);
        animclip.SetCurve(tmp.transform.GetChild(0).name, typeof(SpriteRenderer), "m_Color.a", curveColora);
        // animclip.SetCurve("", typeof(Animation), "m_Enabled", curvenable);
        anim.wrapMode = WrapMode.Once;
        anim.AddClip(animclip, "Startwin");
        anim.Play("Startwin");
    }
開發者ID:darknessomi,項目名稱:Unity-Match3,代碼行數:26,代碼來源:EffectSpawner.cs

示例15: TransferAnimations

    public void TransferAnimations(Animation target, CharacterMotor newcontroller)
    {
        rootAnimationTarget = target;
        controller = newcontroller;

        if(PreAttackClip != null)
        {
            rootAnimationTarget.AddClip(PreAttackClip, PreAttackClip.name);
            rootAnimationTarget[PreAttackClip.name].layer = attackAnimationLayer;
            StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, PreAttackClip ));
        }

        if(AttackClip != null)
        {
            rootAnimationTarget.AddClip(AttackClip, AttackClip.name);
            rootAnimationTarget[AttackClip.name].layer = attackAnimationLayer;
            StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, AttackClip ));
        }

        if(PostAttackClip != null)
        {
            rootAnimationTarget.AddClip(PostAttackClip, PostAttackClip.name);
            rootAnimationTarget[PostAttackClip.name].layer = attackAnimationLayer;
            StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, PostAttackClip ));
        }

        if(RecoilClip != null)
        {
            rootAnimationTarget.AddClip(RecoilClip, RecoilClip.name);
            rootAnimationTarget[RecoilClip.name].layer = attackAnimationLayer;
            StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, RecoilClip ));
        }

        if(hasIdleAnimationOverride)
        {
        rootAnimationTarget.AddClip(IdleOverrideAnimationClip, IdleOverrideAnimationClip.name);
        rootAnimationTarget[IdleOverrideAnimationClip.name].layer = idleAnimationLayer;

        StartCoroutine(MixingTransforms( IdleAnimationMixingTransformNames, IdleAnimationRemoveTransformNames, IdleOverrideAnimationClip ));
        }

        if(hasRunningOverride)
        {
        rootAnimationTarget.AddClip(RunningOverrideAnimationClip, RunningOverrideAnimationClip.name);
        rootAnimationTarget[RunningOverrideAnimationClip.name].layer = idleAnimationLayer;

        StartCoroutine(MixingTransforms( RunningAnimationMixingTransforms, RunningAnimationRemoveTransforms, RunningOverrideAnimationClip ));
        }
    }
開發者ID:reaganq,項目名稱:mixabots,代碼行數:49,代碼來源:ArmorController.cs


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