Skip to main content
Up and Coming
April 30, 2014

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
    This topic has been closed for replies.

    6 replies

    Inspiring
    April 30, 2014
    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.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    JoffreyVRAuthor
    Up and Coming
    May 2, 2014
    Ok thank you, I'll check that.
    ~ Don't forget: What you want, will be.
    JoffreyVRAuthor
    Up and Coming
    May 2, 2014
    :( 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 ?
    ~ Don't forget: What you want, will be.
    Inspiring
    May 2, 2014
    The files are in OVR/Scripts (like OVRGUI and OVRMainMenu).
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    JoffreyVRAuthor
    Up and Coming
    May 5, 2014
    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.
    ~ Don't forget: What you want, will be.
    JoffreyVRAuthor
    Up and Coming
    May 9, 2014
    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
    ~ Don't forget: What you want, will be.