The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
How to change the size of cursor?
I want to change the size of cursor with c# script.
The cursor will bigger when user see closer object if I use default prefab , but I want to keep the cursor's size regardless of distance.
Please tell me how can I solve this problem.
Best Answers
-
Optionsjames_ashley ✭✭✭✭
You can grab a reference to the cursor gameobject and set the transform.scale to alter it's size larger or smaller. To get the same relative perceived size, I think you would want to set the scale to some constant times the distance (x * distance), with distance being the length between the cursor and the camera.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com5 -
Optionsdbarrett ✭✭✭
You should definitely take a look at some basic Unity tutorials to get a better understanding of game objects and transforms. Unity Tutorials
You can grab a reference to your Cursor game object easily.public GameObject myCusror;
then whenever you attach the script to something you just drag the Cursor game object onto the myCursor field in the Inspector Panel.To get the cursor's transform all you have to do is
myCursor.transform
A transform contains a lot of information but, the big three are position, rotation, and scale.As for distance, that is a method used to determine the distance between two Vectors.
float distance = Vector3.Distance(myCursor.transform.position, Camera.main.transform.position);
AR Developer
6
Answers
@pusher,
You can grab a reference to the cursor gameobject and set the transform.scale to alter it's size larger or smaller. To get the same relative perceived size, I think you would want to set the scale to some constant times the distance (x * distance), with distance being the length between the cursor and the camera.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com
Thank you so much for replying!
This might be basic question, but I don't know how to grab a reference to the cursor gameobject.
I installed "MixedRealityToolkit-Unity for Unity 2017.1.0f3" and am using its cursor object.
But I can't understand where the size of cursor or distances are written.
Could you tell me the name of script or some details?
You should definitely take a look at some basic Unity tutorials to get a better understanding of game objects and transforms. Unity Tutorials
You can grab a reference to your Cursor game object easily.
public GameObject myCusror;
then whenever you attach the script to something you just drag the Cursor game object onto the myCursor field in the Inspector Panel.To get the cursor's transform all you have to do is
myCursor.transform
A transform contains a lot of information but, the big three are position, rotation, and scale.
As for distance, that is a method used to determine the distance between two Vectors.
float distance = Vector3.Distance(myCursor.transform.position, Camera.main.transform.position);
AR Developer
thank you very much!