Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JoffreyVR's avatar
JoffreyVR
Honored Guest
11 years ago

TextField for writing

Hi everyone, I explain my issue: I want to create a cube (instanciate a prefab) at a certain position. I want that if the player push "I" by example, a window pop in which he would be able to write numbers. Then I want that number to modify attributes of my class. For the moment, my biggest problem is to allow users to enter numbers. I don't find how to do that with TextField. And second problem how to display it VR ? Because when it's unmodifiable text, I know how to do (an example):
GUI.Label(new Rect(Screen.width / 5 * 1, 370, 200, 20),"");
GUI.Label(new Rect(Screen.width / 5 * 3, 370, 200, 20),"");

If I have to enter numbers in two TextFields, it will be more complicated due to VR.
Hope I made it clear :)
Thank you
- Joffrey

6 Replies

Replies have been turned off for this discussion
  • You should check out the GUI used on the Tuscany demo.

    I bet your can rip out some of that code and use it for your purposes.
  • :( Sorry, but I don't find a way to do what I want in the Tuscany Assets/Scripts/Objects. Maybe I did it wrong. Any other idea ?
  • Ah yes, I've found them, but it wasn't whant I really need. I've found an other to do that. Anyway, thank you for your answers.
  • In case of anybody needs to write something on a TextField and get the text (c#):
    Attribute declaration:
    private string textFieldStringScale="";


    OnGui method: (twice for the VR)
    textFieldStringScale=GUI.TextField(new Rect(Screen.width / 5 * 1, 250, 80, 20),textFieldStringScale,10);
    textFieldStringScale=GUI.TextField(new Rect(Screen.width / 5 * 3, 250, 80, 20),textFieldStringScale,10);


    How to get content:
    script.attribute=Convert.ToSingle(textFieldStringScale); //Convert to float here by example


    Don't forget to add:
    using System;
    if you wan't to use Convert class.

    Hope it helps :)

    - Joffrey