當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。