Search Unity

Is it possible to create a manu as a prefab?

Discussion in 'VR' started by KenniKure, Aug 28, 2019.

  1. KenniKure

    KenniKure

    Joined:
    Aug 7, 2019
    Posts:
    39
    Hi forum

    I have watched a lot of videos on how to create menus and how to instantiate objects, but I cant seem to link them together.

    So here is what I want to do: I have a CAD model in VR I can navigate through via teleport etc. I want to be able to open a menu with a button click, and closing it again. I have an OVRcamerarig/playercontroller for the VR part. Can I create a menu as a prefab and add it to the vr part? I have tried a lot of things to create an instatiateable menu but I dont know the proper steps to see it through.

    I hope someone can help me? :)
     
  2. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    Why would you create and destroy a menu? Put it wherever you want (even as a child of the player if you want to be relative to it) and show/hide it.
     
  3. KenniKure

    KenniKure

    Joined:
    Aug 7, 2019
    Posts:
    39
    I want to be able to open and close it in VR by pressing a button. The menu is only supposted to be shown when I press a button.
     
  4. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    Well, then use SetActive and toggle the menu at button press.
     
    JoeStrout likes this.
  5. KenniKure

    KenniKure

    Joined:
    Aug 7, 2019
    Posts:
    39
    I dont know if this helps? I am a noob in Unity and scripting etc. I tried a few scripts but there keeps being errors, så I have deleted them and started from scratch. Do you have any ideas for two simple scripts for this? one that opens the menu and one that closes it? maybe I should rename the button "back" to close?
     

    Attached Files:

  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    It doesn't require any scripts at all. You can do this entirely with UnityEvents (invoking GameObject.SetActive on your menu).

    You might want to go back and review the UI tutorials. Also, check out my tutorial on UnityEvent.
     
  7. KenniKure

    KenniKure

    Joined:
    Aug 7, 2019
    Posts:
    39
    Thanks. But it didnt really help me any. I am pretty new to Unity, and Im in a 10 week internship working on a project in Unity, and I have 6 weeks left now. I am not gonna work in Unity again after this, and I have seen so many tutorials and other things to make it work but nothing has helped.