Search Unity

Bug XRGeneralSettingsPerBuildTarget - XRGeneralSettings stuck as Standalone while developing for Android

Discussion in 'VR' started by KingKRoecks, Apr 20, 2023.

  1. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    upload_2023-4-20_14-17-58.png

    I am currently developing for Quest, which is an Android platform.

    Here is the
    XRGeneralSettingsPerBuildTarget:OnEnable method
    upload_2023-4-20_14-21-16.png

    This could probably figure out the current build target by my current platform right?
    Rather than just hardcoding Standalone?
     

    Attached Files:

  2. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    The reason this is an issue is that it calls the OnEnable when you enter PlayMode.
    If you had set it through interacting with the UI, or even if you had a value set somehow previously, it's lost as soon as you hit play.

    In order to fix this, I'm going to have to manually set the instance, the same way you're doing, and specify the platform.
    I shouldn't have to do that. That's the bug.
     
  3. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
  4. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    It's in the editor namespace, so I can't modify it at runtime through script without an editor class in my own project.
    It'll be so much easier to just remove that line and go about my business lol
     
  5. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    upload_2023-4-20_14-42-5.png

    It looks like Application.platform isn't useful.

    What class do I need to access to the platform targeted for builds etc?

    upload_2023-4-20_14-43-56.png
     

    Attached Files:

  6. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    ANYWAY
    this was ALMOST super easy

    upload_2023-4-20_14-54-36.png

    but I'm not sure how to access the platform so I'm just going to have hardcode it

    (probably what the dev said too and why it's standalone)
     
  7. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    Anyway, the lesson here, is whoever made there be no accessor to the current platform is evil.
     
  8. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    You could always use a platform conditional to set your instance properly.

    Code (CSharp):
    1. #if UNITY_STANDALONE
    2. //do whatever you need
    3. #elif UNITY_ANDROID
    4. //blah
    5. #endif