当前位置: 首页>>代码示例>>C#>>正文


C# Collider.GetComponentInParent方法代码示例

本文整理汇总了C#中UnityEngine.Collider.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetComponentInParent方法的具体用法?C# Collider.GetComponentInParent怎么用?C# Collider.GetComponentInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Collider的用法示例。


在下文中一共展示了Collider.GetComponentInParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerEnter

        private void OnTriggerEnter(Collider collider)
        {
            var handle = collider.GetComponentInParent<BowHandle>();

            if (handle != null && obj != null && handle.aim.IsHeld() && obj.IsGrabbed())
            {
                handle.nockSide = collider.transform;
                arrow.transform.parent = handle.arrowNockingPoint;

                CopyNotchToArrow();

                collider.GetComponentInParent<BowAim>().SetArrow(arrow);
                Destroy(gameObject);
            }
        }
开发者ID:MechroCat22,项目名称:VR-Object-Hunt,代码行数:15,代码来源:ArrowNotch.cs

示例2: OnTriggerEnter

        protected virtual void OnTriggerEnter(Collider collider)
        {
            Asteroid asteroid = collider.GetComponentInParent<Asteroid>();

            if (!Paused)
                TryCatchAsteroid(asteroid);
        }
开发者ID:ai-ry,项目名称:orbit,代码行数:7,代码来源:AsteroidField.cs

示例3: ToggleRigidbody

 private void ToggleRigidbody(Collider collider, bool state)
 {
     var touch = collider.GetComponentInParent<VRTK_InteractTouch>();
     if (touch)
     {
         touch.ToggleControllerRigidBody(state, state);
     }
 }
开发者ID:MechroCat22,项目名称:VR-Object-Hunt,代码行数:8,代码来源:VRTK_ControllerRigidbodyActivator.cs

示例4: tryNotify

 private void tryNotify(Collider other) {
   IInteractionBehaviour ib = other.GetComponentInParent<IInteractionBehaviour>();
   if (ib) {
     manager.EnsureActive(ib);
     _dislocatedCounter = 0;
     ib.NotifyBrushDislocated();
   }
 }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:8,代码来源:InteractionBrushBone.cs

示例5: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Interactor")
     {
         switch (other.transform.parent.tag)
         {
             case "Customer":
                 Customer customer = other.GetComponentInParent<Customer>();
                 customer.OnInteract(this);
                 break;
             case "Staff":
                 Staff staff = other.GetComponentInParent<Staff>();
                 staff.OnInteract(this);
                 break;
         }
     }
 }
开发者ID:Clarksj4,项目名称:Theme-Supermarket-Tycoon-World,代码行数:17,代码来源:InteractionZone.cs

示例6: Change

        private void Change(Collider target, bool targetValue)
        {
            if (target == null || !SmashGame.IsPlayer(target))
                return;

            var character = target.GetComponentInParent<Character>();

            character.IsGrounded = targetValue;
        }
开发者ID:HouraiTeahouse,项目名称:SmashBrew,代码行数:9,代码来源:Ground.cs

示例7: OnTriggerStay

 private void OnTriggerStay(Collider collider)
 {
     var controller = (collider.GetComponent<VRTK_ControllerEvents>() ? collider.GetComponent<VRTK_ControllerEvents>() : collider.GetComponentInParent<VRTK_ControllerEvents>());
     if (controller)
     {
         if (lastUsePressedState == true && !controller.usePressed)
         {
             var distance = Vector3.Distance(transform.position, destination.position);
             var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);
             OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
         }
         lastUsePressedState = controller.usePressed;
     }
 }
开发者ID:MechroCat22,项目名称:VR-Object-Hunt,代码行数:14,代码来源:ModelVillage_TeleportLocation.cs

示例8: Pickup

 public void Pickup(Collider target)
 {
     // Check if target can be held
     IPickupable held = (IPickupable)target.GetComponentInParent(typeof(IPickupable));
     if (held != null)
     {
         hand.Pickup(held);
     }
     else
     {
         print("Not pickupable");
         print(target.tag);
     }
 }
开发者ID:Clarksj4,项目名称:Theme-Supermarket-Tycoon-World,代码行数:14,代码来源:Selection.cs

示例9: OnTriggerStay

        public void OnTriggerStay(Collider a_other)
        {
            Rigidbody rigid = a_other.GetComponent<Rigidbody>();

            if (rigid == null)
            {
                rigid = a_other.GetComponentInParent<Rigidbody>();
            }

            // Ensure that player has a rigidbody
            if (rigid != null)
            {
                //This seems to be the best value for the time being- adjust this as necessary.
                //rigid.velocity *= 0.985f;
                rigid.velocity *= (delayFactor/2);
                rigid.angularVelocity *= delayFactor; //-- Too much?
            }
        }
开发者ID:patferguson,项目名称:Storms-Project,代码行数:18,代码来源:DelayChaff.cs

示例10: OnTriggerEnter

        void OnTriggerEnter(Collider other)
        {
            if (other.CompareTag("Player1_") || other.CompareTag("Player2_") || other.CompareTag("Player3_") || other.CompareTag("Player4_"))
            {
                ShipPartDestroy partScript = other.GetComponentInParent<ShipPartDestroy>();
                if (partScript != null)
                {
                    // Found in parent, repair
                    partScript.RepairAllParts();
                }
                else
                {
                    // Look to children for the part object
                    partScript = other.GetComponentInChildren<ShipPartDestroy>();
                    if (partScript != null)
                    {
                        partScript.RepairAllParts();
                    }
                }

            }
        }
开发者ID:patferguson,项目名称:Storms-Project,代码行数:22,代码来源:HealPointBehaviour.cs

示例11: OnTriggerEnter

 void OnTriggerEnter(Collider col)
 {
     if (col.GetComponentInParent<BasePlayer>())
     {
         inTrigger.Add(col.GetComponentInParent<BasePlayer>());
         OnEnterZone(this, col.GetComponentInParent<BasePlayer>());
     }
 }
开发者ID:bloodyblaze,项目名称:rep-Mods,代码行数:8,代码来源:ZoneManager.cs

示例12: Select

        /// <summary>
        /// Selects the given gameObject. A selected gameObject is followed and highlighted by a visual effect, and has its
        /// statistics displayed on the UI. 
        /// </summary>
        /// <param name="target">The gameObject to highlight</param>
        void Select(Collider target)
        {
            // Check if the clicked thing is selectable
            selected = (ISelectable)target.GetComponentInParent(typeof(ISelectable));
            if (selected != null)
            {
                // Setting parent causes this object (and its children) to follow the parent
                transform.parent = target.transform;
                // This object floats just off the base of the selected object
                transform.localPosition = new Vector3(0, 1.5f, 0);
                // Turn on visual effects
                visualEffect.SetActive(true);

                selected.OnSelect();
            }
        }
开发者ID:Clarksj4,项目名称:Theme-Supermarket-Tycoon-World,代码行数:21,代码来源:Selection.cs

示例13: OnTriggerExit

 private void OnTriggerExit(Collider col)
 {
     //Interface.Oxide.LogInfo("Exit {0}: {1}", Info.ID, col.name);
     var player = col.GetComponentInParent<BasePlayer>();
     if (player != null)
     {
         if (!players.Remove(player)) return;
         ZoneManagerPlugin.OnPlayerExitZone(this, player);
     }
     else if(!col.transform.CompareTag("MeshColliderBatch"))
         CheckCollisionLeave(col);
     else
     {
         var colliderBatch = col.GetComponent<MeshColliderBatch>();
         if (colliderBatch != null)
         {
             var colliders = (ListDictionary<Component, ColliderCombineInstance>) InstancesField.GetValue(colliderBatch);
             foreach (var instance in colliders.Values)
                 CheckCollisionLeave(instance.collider);
         }
     }
 }
开发者ID:Arkoudaphobia,项目名称:ArkoudaphobiaConfig,代码行数:22,代码来源:ZoneManager.cs

示例14: OnTriggerStay

        public void OnTriggerStay(Collider other)
        {
            if (!IsAnimalAi(other))
            {
                return;
            }

            if (IsSelf(other))
            {
                return;
            }

            var direction = other.transform.position - gameObject.transform.position;
            var angle = Vector3.Angle(direction, transform.forward);
            if (angle < 0.5 * FieldOfViewAngle)
            {
                RaycastHit ray;
                if (Physics.Raycast(transform.position, direction, out ray))
                {
                    var otherAnimal = other.GetComponentInParent<AiRig>();
                    var collidedAnimal = ray.collider.GetComponentInParent<AiRig>();
                    if (collidedAnimal == otherAnimal)
                    {
                        ReportDetection(other);
                        return;
                    }
                }
            }
            if (Detected.Contains(other))
            {
                ReportUndetection(other);
            }
        }
开发者ID:Miista,项目名称:TerrainGeneration,代码行数:33,代码来源:Sensors.cs

示例15: IsSelf

 protected bool IsSelf(Collider other)
 {
     var components = GetComponentInParent(AiBase);
     var otherAnimal = other.GetComponentInParent(AiBase);
     return components == otherAnimal;
 }
开发者ID:Miista,项目名称:TerrainGeneration,代码行数:6,代码来源:Sensors.cs


注:本文中的UnityEngine.Collider.GetComponentInParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。