SpawnAnimateObjectDeathEvent() public static méthode

Spawn a animate object with the death event, so after the animate was played serval loop times the object will be destroyed.
public static SpawnAnimateObjectDeathEvent ( RuntimeAnimatorController anim, int orderLayer = 15, int loopTimes = 1 ) : GameObject
anim RuntimeAnimatorController animation u want to play
orderLayer int sorting order
loopTimes int loop times
Résultat GameObject
        /// <summary>
        /// Spawn a support animation.
        /// </summary>
        private void SpawnSupAnim()
        {
            for (int index = 0;
                 index < mAnimDesity;
                 ++index)
            {
                // get a random animate from pool
                RuntimeAnimatorController anim = mAnimPoolSupAnim.GetRandomAnim();

                GameObject obj = JCS_Util.SpawnAnimateObjectDeathEvent(anim, mOrderLayer);

#if (UNITY_EDITOR)
                obj.name = "JCS_2DFullScreenAtkAction";
#endif

                if (mSamePosition)
                {
                    obj.transform.position = this.transform.position;
                }
                if (mSameRotation)
                {
                    obj.transform.rotation = this.transform.rotation;
                }
                if (mSameScale)
                {
                    obj.transform.localScale = this.transform.localScale;
                }

                AddHitSound(ref obj);
                SetToRandomPos(ref obj);
            }
        }
Exemple #2
0
        /// <summary>
        /// Spawn a animation for jumping effect.
        /// </summary>
        /// <param name="index"></param>
        private void DoJumpAnimEffect(int index)
        {
            if (mJumpAnim.Length < index)
            {
                return;
            }

            if (mJumpAnim.Length != mJumpAnimOffset.Length)
            {
                return;
            }

            if (mJumpAnim.Length == 0)
            {
                return;
            }

            if (mJumpAnim[index] == null)
            {
                return;
            }

            GameObject gameObject =
                JCS_Util.SpawnAnimateObjectDeathEvent(
                    mJumpAnim[index],
                    mOrderLayerObject.sortingOrder - 1);

            Vector3 newPos     = Vector3.zero;
            Vector3 tempOffset = mJumpAnimOffset[index];

            // change the position depends on the scale.
            if (this.transform.localScale.x < 0)
            {
                tempOffset.x = -tempOffset.x;
            }

            // assign new position for the effect.
            newPos = this.transform.localPosition + tempOffset;

            // assign to effect's transform.
            gameObject.transform.localPosition = newPos;
            gameObject.transform.localScale    = this.transform.localScale;
        }