Search Unity

Question How to generate the same UI using scripts for different sources

Discussion in 'Scripting' started by yuemco, Feb 24, 2021.

  1. yuemco

    yuemco

    Joined:
    Jul 1, 2018
    Posts:
    36
    Hi all,

    What is the best practice of generating or building the same UI for different sources (It can be Oculus VR UI, can be a tablet UI or can be desktop UI)? The problem is each source uses different dependencies and Is it possible to exclude these dependencies to create the same UI for the different sources. If it doesn't clear I can elaborate on it.

    Thanks.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Different dependencies? Unity has their canvas UI which works for mobile, desktop, and even VR. VR is the only unique one because you have to account for the user turning their head and how you want the UI to work with that in VR.

    Now if you're talking code, you can use platform dependent compiling.
    https://docs.unity3d.com/Manual/PlatformDependentCompilation.html

    But I think the Oculus Quest falls under Android and PC VR possibly falls under standalone Win.

    I'm just not sure what different dependencies you are referencing.
     
  3. yuemco

    yuemco

    Joined:
    Jul 1, 2018
    Posts:
    36
    Hi @Brathnann,

    Thank you for your reply. Actually, I am talking about scripting UI with UXML and USS. Using these I can make sure the UI is standard for VR or desktop app. I don't have any worries about deployment. I am looking for design patterns (or best practices) for UI that would be created by scripts. I hope it is clear now.

    Btw, I also created a thread in the UI toolkit but nobody replies to me. I try my chance in here :)

    Thanks.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Unfortunately, I haven't touched UI Toolkit yet, so I am unable to help you. Hopefully someone else has more knowledge.