MRTK BoundsControl Meta Quest 2

35 views Asked by At

I am Currently working with MRTK (Microsoft Mixed Reality Toolkit). I have a doubt in MRTK can I access the built in script of MRTK in my custom script?

  1. I have one MRTK script name "BoundsControl". Which contents Targeted gameObject.
  2. I have created my custom script which is attached to the pointer (Cursor) in MRTK Cursor.
  3. When both collides (cursor & targetObject as gameObject) I want to enable the BoundsControl Script. So I can scale, rotate that particular TargetObject.
  4. I tried to getComponent but showing me an error.

This is in my custom script // Enable the BoundsControl script on the target GameObject GameObject targetObject = targetObject; BoundsControl boundsControl = targetObject.GetComponent();

Could anyone of can tell me where I am going wrong.

I want to access the "BoundsControl" Script of MRTk (If accessable- I dont know whether its accessable or not please clear my doubts?

1

There are 1 answers

0
Ying Li - MSFT On

Yes, you can access the BoundsControl script from your custom script.

You’re attempting to get the BoundsControl component from the targetObject, but you haven’t specified the type of component you’re trying to get. Here’s how you can correct it:

BoundsControl boundsControl = targetObject.GetComponent<BoundsControl>();

For more information on how to use BoundsControl in your code, you can refer to Bounds control - MRTK 2 | Microsoft Learn.