Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Is there a way to choose which api to use through javascript

Discussion in 'Web' started by Suranjan_RedTailFox, Feb 28, 2023.

  1. Suranjan_RedTailFox

    Suranjan_RedTailFox

    Joined:
    Mar 6, 2020
    Posts:
    3
    I want to be able to choose whether to use webgl 1.0 or webgl 2.0 by checking which device or browser my content is running on. Is this possible? if yes how do i do it?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,438
    To my knowledge, you cannot set the API manually.
    Also, there is no point in forcing to use v1 when the browser supports v2 since the latter is (in my experience) always noticably faster anyway.

    In older Unity versions (where WebGL 1.0 hasn't been deprecated yet) you can set it up in player settings so that v2 and v1 are both in the list of display APIs with v2 on top. In that case, if you run the app in a browser that does not support WebGL v2 it will instead use v1.

    However, the issue with that is that you are forced to use Gamma color space even in v2. And you forfeit many of the benefits of v2 because of that.

    It is simply best these days to only support v2 and to use Linear color space.

    What you can do is to disable AA or some other rendering features (shadows, full-screen fx, etc) that are costly in performance based on the device/browser or versions thereof in case you run into performance issues on older devices.
     
  3. Suranjan_RedTailFox

    Suranjan_RedTailFox

    Joined:
    Mar 6, 2020
    Posts:
    3
    thank you