当前位置: 首页>>代码示例>>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;未经允许,请勿转载。