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


C# Character.GetComponentInChildren方法代碼示例

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


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

示例1: CharacterPhysicsController

    public CharacterPhysicsController(Character character)
    {
        _character               = character;
        _rigidBody               = character.GetComponentInChildren<Rigidbody>();
        _capsule                 = character.GetComponentInChildren<CapsuleCollider>();
        _bottomCollisionNotifier = character.transform.Find("Capsule/Collisions/BottomSphere").GetComponent<CollisionNotifier>();
        _frontCollisionNotifier  = character.transform.Find("Capsule/Collisions/FrontSphere").GetComponent<CollisionNotifier>();
        _rigidBody.constraints   = RigidbodyConstraints.FreezeRotation;

        UpdateBendedState();
    }
開發者ID:leorojas86,項目名稱:UnityBaseProject,代碼行數:11,代碼來源:CharacterPhysicsController.cs

示例2: DoCollect

 /// <summary>
 /// Do the collection.
 /// </summary>
 /// <param name="character">Character doing the collection.</param>
 protected override void DoCollect(Character character)
 {
     ItemManager itemManager = character.GetComponentInChildren<ItemManager> ();
     if (itemManager != null) itemManager.CollectItem (this);
     if (CollectHasListener()) OnCollectItem(itemClass, type, amount, character);
     else
     {
         // No responders lets do something so the user can tell the collected the item.
         gameObject.SetActive(false);
     }
 }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:15,代碼來源:StackableItem.cs

示例3: DoCollect

 /// <summary>
 /// Do the collection.
 /// </summary>
 /// <param name="character">Character doing the collection.</param>
 protected override void DoCollect(Character character)
 {
     CharacterHealth health = character.GetComponentInChildren<CharacterHealth>();
     if (health == null)
     {
         Debug.LogWarning("Tried to add health but the character doesn't have a CharacterHealth");
     }
     else
     {
         health.Heal(amount);
     }
     DoEventForCollect (character);
 }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:17,代碼來源:ItemHealth.cs

示例4: Init

        /// <summary>
        /// Initialise the mvoement with the given movement data.
        /// </summary>
        /// <param name="character">Character.</param>
        /// <param name="movementData">Movement data.</param>
        public override Movement Init(Character character, MovementVariable[] movementData)
        {
            this.character = character;

            myAnimator = character.GetComponentInChildren<Animator> ();
            if (myAnimator == null) Debug.LogWarning ("Play Animation special movement could not find an animator.");

            if (movementData != null && movementData.Length >= MovementVariableCount)
            {
                loopUntilInterrupted = movementData [LoopUntilInterruptedIndex].BoolValue;
                shouldApplyGravity = movementData [ShouldApplyGravityIndex].BoolValue;
            }
            else
            {
                Debug.LogError("Invalid movement data.");
            }
            return this;
        }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:23,代碼來源:SpecialMovement_PlayAnimation.cs

示例5: Init

 /// <summary>
 /// Initialise this instance.
 /// </summary>
 public override Movement Init(Character character)
 {
     base.Init (character);
     crouchMovement = character.GetComponentInChildren<GroundMovement_Crouch> ();
     if (crouchMovement == null)
     {
         Debug.LogWarning ("Couldn't find a crouch movement, crouch jump will be disabled.");
         Enabled = false;
     }
     return this;
 }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:14,代碼來源:AirMovement_CrouchJump.cs

示例6: Init

        /// <summary>
        /// Initialise this instance.
        /// </summary>
        public override Movement Init(Character character)
        {
            this.character = character;

            if (shrinkHurtBox)
            {
                CharacterHurtBox chb = character.GetComponentInChildren<CharacterHurtBox>();
                if (chb != null) hurtBoxCollider = chb.GetComponent<Collider2D>();
                if (hurtBoxCollider == null) Debug.LogError ("Crouch will try to shrink hurt box collider, but no hurt box collider could be found.");
            }

            if (shrinkHeadAndSides)
            {
                // Make sure the original head extent array is large enough to store each head collider height.
                // And initialise the new extents so we don't need to create anything later.
                int headCount = 0;
                for (int i = 0; i < character.Colliders.Length; i++)
                {
                    if (character.Colliders[i].RaycastType == RaycastType.HEAD) headCount++;
                }
                originalHeadExtents = new Vector2[headCount];
                newHeadExtents = new Vector2[headCount];
                headCount = 0;
                for (int i = 0; i < character.Colliders.Length; i++)
                {
                    if (character.Colliders[i].RaycastType == RaycastType.HEAD)
                    {
                        originalHeadExtents[headCount] = character.Colliders[i].Extent;
                        newHeadExtents[headCount] = new Vector2(character.Colliders[i].Extent.x, newHeadHeight);
                        headCount++;
                    }
                }
            }
            return this;
        }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:38,代碼來源:GroundMovement_Crouch.cs

示例7: Init

        /// <summary>
        /// Initialise this animation bridge.
        /// </summary>
        protected void Init()
        {
            // Get character reference
            myMob = (IMob) gameObject.GetComponent(typeof(IMob));
            if (myMob == null) myMob = (IMob) gameObject.GetComponentInParent(typeof(IMob));
            if (myMob == null) Debug.LogError ("Mecanim Animation Bridge (2D) unable to find Character or Enemy reference");
            myMob.ChangeAnimationState += AnimationStateChanged;
            myAnimator = GetComponentInChildren<Animator>();
            if (myAnimator == null) Debug.LogError ("Platform Animator unable to find Unity Animator reference");
            defaultController = myAnimator.runtimeAnimatorController;

            if (myMob is Character && (statesWithAimUpModifer.Count > 0 || statesWithAimDownModifer.Count > 0))
            {
                myCharacter = (Character) myMob;
                aimer = myCharacter.GetComponentInChildren<ProjectileAimer>();
            }
            if ((statesWithAimUpModifer.Count > 0 || statesWithAimDownModifer.Count > 0) && aimer == null) Debug.LogWarning ("Can't use UP or DOWN modifiers as no aimer could be found");

            animationStateOverrideLookup = new Dictionary<string, AnimatorOverrideController> ();
            foreach (AnimatorControllerMapping mapping in mappings)
            {
                animationStateOverrideLookup.Add (mapping.overrrideState, mapping.controller);
            }

            queuedStates = new Queue<string> ();
            queuedPriorities = new Queue<int> ();
            state = AnimationState.NONE.AsString();
            priority = -1;

            TimeManager.Instance.GamePaused += HandleGamePaused;
            TimeManager.Instance.GameUnPaused += HandleGameUnPaused;

            #if UNITY_EDITOR
            #if UNITY_5
            // TODO also check for up and down states
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List<string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add (stateMachine.states[i].state.name);
                }
            }

            #else
            // TODO also check for up and down states
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditorInternal.AnimatorController)
            {
                editor_stateNames = new List<string>();
                UnityEditorInternal.StateMachine stateMachine = ((UnityEditorInternal.AnimatorController)defaultController).GetLayer(0).stateMachine;
                for (int i = 0; i < stateMachine.stateCount; i++)
                {
                    editor_stateNames.Add (stateMachine.GetState(i).name);
                }

            }
            #endif
            #endif
        }
開發者ID:Connorlc,項目名稱:UnityProjects,代碼行數:65,代碼來源:MecanimAnimationBridge_2DWithModifiers.cs


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