Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by idchlife · Nov 08, 2017 at 11:50 AM · webglbrowsertroubleshootingscrollwheel

Webgl build disables mouse wheel scroll on webpage.

Is there way to disable "preventDefault" somewhere in the code or in settings? My game is kinda clicks only and webpage should be scrollable as it is by default.

Mouse scroll wheel event stops inside unity webgl player.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by idchlife · Feb 18, 2018 at 08:07 PM

@RagingPjotr I found partial solution. Well, it worked for product, sooo

http://hatebin.com/dmcgfbwqhc

Insert this into script tag after everything related to unity in html and modify 2500 milliseconds (2.5 seconds) to your preferred time.

My 3d loaded within 2 seconds so I made more time for this code to start.

If you have another selector than 'canvas' modify this too!

I solved it by basically imitating scroll. Feels clunky but gets the job done

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RagingPjotr · Feb 19, 2018 at 12:01 AM 0
Share

Good call. I didn't bother with the timeout though, but added the listener in the UnityLoader js. It works though, thanks!

avatar image CorstiaanMediamonks · Jul 08, 2020 at 03:54 PM 0
Share

The hatebin link no longer works :-( any chance you could re-post there or maybe copy-paste here? would be awesome

avatar image
0

Answer by RagingPjotr · Feb 18, 2018 at 10:39 AM

Hey @idchlife , did you ever find a solution for this? I'm having the same issue.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Ra_vael · Mar 05, 2019 at 04:48 PM

Found a great way to mouse wheel scroll a WebGL player in an iframe even without Unity<->Browser communication:

 <head>
     <style type="text/css">            
         iframe {    height:   calc(100%-120px);
                     width:    100%; }
     </style>
 </head>
 
 <body>
     
     <!-- 3d environment -->
     <iframe id="iframeUnityProject" src="UnityProject/index.html"></iframe>
     
     <script>
         // whenever a mouse wheel event occurs, execute ScrollingY()
         var iframeElement = document.getElementById("iframeUnityProject").contentWindow;
         iframeElement.addEventListener("wheel", ScrollingY, true);
         
         // manually scrolling iframe parent window
         // event.deltaY —> amount of lines to scroll as provided by OS
         // single line size in pixels —> usually the default font size of 16
         function ScrollingY( event ) { window.scrollBy({
             top: event.deltaY * 16,
             left: 0,
             behavior: 'smooth' });
         }
     </script>
         
 </body>

Hope this helps!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by TDVDev · Jul 22, 2020 at 06:00 PM

Hi, maybe this will help you https://medium.com/@tuznev/enable-m...nside-unity3d-container-on-webgl-8dd4dc6a1784

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Interact across browser javascipt and unity webgl 2 Answers

Webgl browser error " DirectoryNotFoundException: Could not find a part of the path" 0 Answers

blend4web is better than unity WebGl ? 1 Answer

Multiple Cursors - WebGL Unity 5.6 2 Answers

Javascript problem when try to display with webgl 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges