Search Unity

  1. Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice

How to get page language?

Discussion in 'WebGL' started by aubergine, Dec 23, 2020.

  1. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,751
    I need to get the current pages language (its a prefix or sometimes a domain) and send it to unity webgl via sendMessage function only after the webgl is fully loaded.

    Im stuck at how to determine if the webgl is fully loaded or not?

    I prefer to be able to check this via the html/js if possible (the webgl build is big and dont want to recompile) but ill do otherwise if i have to.
     
  2. TypicalT

    TypicalT

    Joined:
    Sep 23, 2020
    Posts:
    1
    Well pretty much since the unityinstance is loading in the <head> of the project. You can use
    window.onload ()=>{
    //Logic goes here
    }
    This way all code will execute after everything is loaded
     
  3. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,751
    I meant the webgl file itself is loaded.
    Anyways it seems to be simple that documents explain we can call webpage javascript functions from unity, so thats how i did it.
     
unityunity