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.
Scaling an object
I am trying to make a hologram in unity like mircrosoft's holograms with clickable corners that will be used to scale the hologram. Anyone have an suggestions on how to do this. I've hit a wall. What I've done so far is add cubes to each corner to act as collision boxes for when the gaze and corner is selected, but I can't figure out a script to scale the model that is a sibling of my corners. Thanks in advance for the help.
Best Answer
-
HoloSheep mod
@Alec_H the scaling logic is pretty simple and can look something like:
this.gameObject.transform.localScale = new Vector3(this.gameObject.transform.localScale.x * 2, this.gameObject.transform.localScale.y * 2, this.gameObject.transform.localScale.z * 2);
which in the above case would double the size of the current object.
If instead you want your script to scale a different object (sibling, parent, or whatever) you would do something similar to a reference to that object.So one way to reference a different object is to create a public variable in your script like so:
public GameObject TheObjectToScale;
which would then expose a property in the Unity Inspector that you could drag the sibling onto. That would then allow you to modify the earlier logic to be something like:
TheObjectToScale.transform.localScale = new Vector3 TheObjectToScale.transform.localScale.x * 2, TheObjectToScale.transform.localScale.y * 2, TheObjectToScale.transform.localScale.z * 2);
HTH.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings5
Answers
@Alec_H,
I would recommend using the manipulation gesture to scale your object. Depending on the experience you desire, you may or may not want to add some gesture scaling rather than keeping it at a 1:1 ratio of hand movement to object scaling.
Have you taken a look at the Holograms 211: Gestures course? The GestureAction script (Chapter 4) shows an example of how to use the manipulation gesture to move an object in the scene.
Thanks!
David
@Alec_H the scaling logic is pretty simple and can look something like:
which in the above case would double the size of the current object.
If instead you want your script to scale a different object (sibling, parent, or whatever) you would do something similar to a reference to that object.
So one way to reference a different object is to create a public variable in your script like so:
public GameObject TheObjectToScale;
which would then expose a property in the Unity Inspector that you could drag the sibling onto. That would then allow you to modify the earlier logic to be something like:
HTH.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
@DavidKlineMS Yes, I looked at this tutorial and am able to move my object no problem, but I am wanting to be able to scale the object like you can with the MS holograms. I think it's going to take the code @HoloSheep and some of the 211 tutorial to achieve my final goal. Thank you both of you!
Any progress about this question? have you figure out how to scale-up/down with clickable corner?
@mARkus No I haven't been able to do it yet. I have gotten it to scale with voice commands, but that's not what I want my final product to do. I will update once I figure it out.
I've tried a few things with the GestureAction code given in one of the tutorials. Ideally I would like it to be a 1:1 fixed scale but right now this code just makes my object vanish and I'm not sure why. @HoloSheep @DavidKlineMS any suggestions on what's going wrong?
`using UnityEngine;
///
public class Cubscript : MonoBehaviour
{
[Tooltip("Rotation max speed controls amount of rotation.")]
}`
Hi,
I search exactly the same? Are you got any results?
Pad