GetClip() public method

public GetClip ( string name ) : AnimationClip
name string
return AnimationClip
コード例 #1
0
ファイル: LoadAnimation.cs プロジェクト: qingsen/notes
    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
0
 static public int GetClip(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         System.String         a1;
         checkType(l, 2, out a1);
         var ret = self.GetClip(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #3
0
ファイル: LoadAnimation.cs プロジェクト: qingsen/notes
    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 };
    }
コード例 #4
0
ファイル: AnimationQueue.cs プロジェクト: MrBek/Poker
        public void Update()
        {
            var currentTime = Time.time;

            foreach (var entry in entries.ToArray())
            {
                if (entry.StartTime <= currentTime)
                {
                    entries.Remove(entry);

                    if (entry.OnlyIfNotPlaying)
                    {
                        if (animation.IsPlaying(entry.Name))
                        {
                            continue;
                        }
                    }

                    if (entry.BlendWeight > 0.0f)
                    {
                        animation.Blend(entry.Name, entry.BlendWeight);
                    }
                    else
                    {
                        animation.Play(entry.Name, entry.PlayMode);
                    }

                    animationStartedCallback(entry.Name, animation.GetClip(entry.Name).length);
                }
            }
        }
コード例 #5
0
        public static void AddClips(this UnityEngine.Animation anim, UnityEngine.Animation originAnim, params string[] animNames)
        {
            AnimationClip clip;

            foreach (string clipName in animNames)
            {
                clip = originAnim.GetClip(clipName);
                if (clip != null)
                {
                    anim.AddClip(clip, clipName);
                }
            }
        }
コード例 #6
0
 static public int GetClip(IntPtr l)
 {
     try {
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         System.String         a1;
         checkType(l, 2, out a1);
         var ret = self.GetClip(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #7
0
 static int QPYX_GetClip_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation));
         string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2);
         UnityEngine.AnimationClip QPYX_o_YXQP = QPYX_obj_YXQP.GetClip(QPYX_arg0_YXQP);
         ToLua.PushSealed(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #8
0
 static public int GetClip(IntPtr l)
 {
     try{
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         System.String         a1;
         checkType(l, 2, out a1);
         UnityEngine.AnimationClip ret = self.GetClip(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #9
0
 static int GetClip(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
         string arg0 = ToLua.CheckString(L, 2);
         UnityEngine.AnimationClip o = obj.GetClip(arg0);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #10
0
 public static int GetClip_wrap(long L)
 {
     try
     {
         long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Animation obj = get_obj(nThisPtr);
         string arg0 = FCLibHelper.fc_get_string_a(L, 0);
         UnityEngine.AnimationClip ret = obj.GetClip(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #11
0
    static int GetClip(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Animation.GetClip");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
            string arg0 = ToLua.CheckString(L, 2);
            UnityEngine.AnimationClip o = obj.GetClip(arg0);
            ToLua.PushSealed(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #12
0
        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++;
            }
        }
コード例 #13
0
ファイル: commonAI.cs プロジェクト: tng2903/game1
    // 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();
    }
コード例 #14
0
ファイル: ChpAnimation.cs プロジェクト: fengqk/Art
	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 );
			}
		}
	}
コード例 #15
0
ファイル: ChpAnimation.cs プロジェクト: fengqk/Art
	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 );
		}
	}
コード例 #16
0
ファイル: ChpAnimation.cs プロジェクト: fengqk/Art
	public static void SetAnis(Animation _animation, string[] aniNames, int layerIn, WrapMode wrapModeIn, bool bSyncLayer = false)
	{
		for (int i = 0; i < aniNames.Length; i++)
		{
			if (aniNames[i] != null && !string.IsNullOrEmpty( aniNames[i]))
			{
				try
				{
					if (_animation.GetClip(aniNames[i]) != null)
					{
						_animation[aniNames[i]].wrapMode = wrapModeIn;
						_animation[aniNames[i]].layer = layerIn;
					}

				}
				catch (System.Exception ex)
				{
					Debug.LogWarning(ex.Message + aniNames[i] + " From: " + _animation.gameObject.name);
				}
			}
		}
		if (bSyncLayer)
		{
			_animation.SyncLayer(layerIn);
		}

	}
コード例 #17
0
        public static AnimationState GetAnimState(this UnityEngine.Animation anim, string clipName = null)
        {
            AnimationClip clip = string.IsNullOrEmpty(clipName) ? anim.clip : anim.GetClip(clipName);

            return(clip != null ? anim [clip.name] : null);
        }
コード例 #18
0
 // Use this for initialization
 void Start()
 {
     animation = this.gameObject.GetComponent<Animation>();
     attackLength = animation.GetClip("Attack").length;
     playerHealthManager = player.GetComponent<HealthManager>();
 }
コード例 #19
0
ファイル: PlayerAnimation.cs プロジェクト: jkevinp/SciHeroes
    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>();
        }
    }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
    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();
    }
コード例 #22
0
ファイル: LoadAnimation.cs プロジェクト: qingsen/notes
    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 };
    }