Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to get page language?

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

  1. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    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,878
    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.