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

right click web player - quick question

Discussion in 'Web' started by scb, Dec 14, 2016.

  1. scb

    scb

    Joined:
    Jun 25, 2015
    Posts:
    3
    So when i build to web player with the newest version of unity, after the application is running in my browser,

    If I right click within the game, the browser(chrome) pulls up a small context menu "save image, copy image, inspect."

    I can't figure out how to turn this off, I don't know what is causing this.

    I'm also having trouble with the left click, if you hold down the mouse and move, your cursor will change to one as if you're typing, or sometimes changes to some kind of "you can't drag this" feedback symbol which looks like this ( / )

    Not sure why this is happening, or how to turn it off???
    Just installed the newest version of unity beta 5.6.0b1, never had this issue with version 5.4
    context menu.png
     
  2. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    If i right click on this web page it shows that too!
     
  3. scb

    scb

    Joined:
    Jun 25, 2015
    Posts:
    3
    Last edited: Dec 19, 2016
  4. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello scb.

    This issue should be resolved in the upcoming release.

    For now you may use the following workaround. Replace the following code in your index.html:
    Code (JavaScript):
    1. var gameInstance = UnityLoader.instantiate("gameContainer", "Build/your-build.json", {onProgress: UnityProgress});
    with this (just make sure you are using appropriate filename for the json):
    Code (JavaScript):
    1. var gameInstance = UnityLoader.instantiate("gameContainer", "Build/your-build.json", {onProgress: UnityProgress, Module: {
    2.   onRuntimeInitialized: function () {
    3.     this.canvas.addEventListener("contextmenu", function (e) { e.preventDefault(); });
    4.   },
    5. }});
    P.S. This workaround is actually a very good example of how you can use the additional UnityLoader.instantiate argument in Unity 5.6. Specifically, adding a Module property to the UnityLoader.instantiate argument lets you override the instantiated Module contents (in this specific case, the onRuntimeInitialized handler). You may use the very same idea to override other Module parameters, like TOTAL_MEMORY etc. directly from the index.html. Note that this keyword in the onRuntimeInitialized function call will be resolved as the instantiated Module object, which has the corresponding canvas as its property. You can also add other initialization code to this handler when necessary.
     
    scb likes this.
  5. scb

    scb

    Joined:
    Jun 25, 2015
    Posts:
    3
    Wow this is an amazing answer,

    I have been so confused about the [javascript] code which is generated within the index.html file. Up until right now, I had no clue what was going on.

    This is a great example of how to modify the parameters being passed to the game instance. TIL !