Hello everyone.
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.
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.
Options
How Can I display Hello World Text On my Hologram app?
How Can I display Hello World Text On my Holographic app, this text "Hello World" need to displayed dynamically at runtime, for example this could be a twitter feed.
Tagged:
0
Best Answer
-
OptionsPatrick mod
You can also use a 3D text mesh in Unity, and enable/disable the game object that has the text mesh to conditionally display the mesh.
Here's a cheesy debug script I use sometimes:
public class DebugText : MonoBehaviour { /// <summary> /// Unity textmesh for rendering text. /// </summary> TextMesh textMesh; /// <summary> /// Counter for number of frames. /// </summary> int frames; /// <summary> /// Tracks FPS. /// </summary> float fps = 0; /// <summary> /// Tracks which whole second we are on. /// </summary> int SecondsPassed = 0; void Start() { textMesh = gameObject.GetComponent<TextMesh>(); } void Update() { // This is a super crude method of determining FPS. // Basically, we count how many frames we get each second. frames++; int currentSecond = (int)Time.time; if (currentSecond != SecondsPassed) { fps = frames; frames = 0; SecondsPassed = currentSecond; } // Also show available speech commands. textMesh.text = string.Format("fps: {0}}", fps.ToString());, } }
and then I make an object in the Unity editor and add a TextMesh as a child with the above script. On the parent object I add this script, setting the text mesh as the 'information object' so I can toggle it with my keywords.
/// <summary> /// Creates a handy debug window. /// </summary> public class CommandWindowController : MonoBehaviour { [Tooltip("This object is shown when the command window is expanded")] public GameObject informationObject; [Tooltip("This is the offset from the user's position to draw the object")] public Vector3 headOffset = Vector3.zero; /// <summary> /// We will be using speech for some interactions. /// </summary> private KeywordRecognizer keywordRecognizer; // Use this for initialization void Start () { // Create the keywordRecognizer listening to 'expand' and 'collapse'. List<string> keywords = new List<string>(); keywords.Add("expand"); keywords.Add("collapse"); keywordRecognizer = new KeywordRecognizer(keywords.ToArray()); keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; keywordRecognizer.Start(); } private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args) { // Enable the appropriate objects when expanding/collapsing. switch(args.text.ToLower()) { case "expand": informationObject.SetActive(true); break; case "collapse": informationObject.SetActive(false); break; } } // Update is called once per frame void Update () { // Put the object in a static position in the scene relative to the user. // Generally this wouldn't be a good idea for an application, but this is handy for // debugging. Transform headTransform = Camera.main.transform; this.transform.position = headTransform.position + headTransform.forward * headOffset.z + headTransform.right * headOffset.x + headTransform.up * headOffset.y; this.transform.LookAt(headTransform); this.transform.Rotate(0, 180, 0); } }
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
7
Answers
I would start looking into MVC/MMVM patterns and things like uGUI and Text Mesh Pro.
@ManojTalreja sounds like you are looking for Unity UI.
Look at the create dropdown at the top of the Hierarchy pane.
BUT.. there are a lot of weird issues that you will need to fuss with.
If you add a text element, it will put it inside a canvas as a container.
Set the Text property of the text object to Hello World.
To programmatically set the text property do something like:
where "Text" is the name of the Text object in your Hierarchy.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
Default uGUI text is a good option for "Hello World" apps, but for production apps I would use a vector-based text plugin such as Text Mesh Pro, which is compatible with uGUI.
You can also use a 3D text mesh in Unity, and enable/disable the game object that has the text mesh to conditionally display the mesh.
Here's a cheesy debug script I use sometimes:
and then I make an object in the Unity editor and add a TextMesh as a child with the above script. On the parent object I add this script, setting the text mesh as the 'information object' so I can toggle it with my keywords.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
@HoloSheep Hi there, I have exported the HoloToolikit-Unity package into a new blank Unity project, as well as a Canvas and Panel (in ScreenSpace-Camera mode and HoloLensCamera prefab as RenderCamera) but I cannot change the position of the Canvas. You say "zero out the position of the canvas" but mine is greyed out. What am I missing?