Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

WebGL - Resizing the canvas

Discussion in 'Unity 5 Pre-order Beta' started by impul101, Jan 12, 2015.

  1. impul101

    impul101

    Joined:
    Feb 8, 2013
    Posts:
    21
    I noticed that when I change the canvas size in the index.html, the value gets changed to the 'Player Settings' default after the game finishes loading. I assume one of the js files overwrites the canvas size in index.html. Can I manually set the canvas size post load and if so, how?
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Screen.SetResolution should work for this.
     
  3. Chris333

    Chris333

    Joined:
    Dec 15, 2014
    Posts:
    13
    Hi,

    i'am trying to set the canvas to fullscreen to make a website with WebGL.
    Screen.SetResolution dont work. It sets the canvas size always to the default player settings(960,600).
    I can't overwrite the canvas size with javascript.

    Is there a way like it was with the old WebPlayer as below?

    var w = window.innerWidth;
    var h = window.innerHeight;
    var config = {
    width: w,
    height: h,
    params: { enableDebugging:"0" }
    };
    var u = new UnityObject2(config);