Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
  • Help Room /
avatar image
0
Question by adibak · Sep 07, 2021 at 01:09 PM · inputwebglmouseclick

Why is input mouse clicking not working on WebGL build?

Hi,

I made an FPS game in unity3d and exported it to webgl (unity play). When I played that, however, and clicked on a gameobject, nothing happened. The gameobject was supposed to rotate on click. Even when I tried clicking on other similar gameobjects, the same issue persisted. I'm not sure why this is happening...can someone please help? Thanks.

I'm using Input.GetMouseButtonDown(0) for those particular mouse clicks. For the FPS controller, I'm using unity's standard assets Rigidbody FPS controller.

Here's my code containing basically all of my mouse-click related actions:

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 using UnityEngine.UI;
 public class OpenPaint : MonoBehaviour
 {
  
     public bool isOpen = false;
     public bool drawOpen = false;
     public bool isLift = false;
     public bool canUncScream = false;
     public GameObject battery1;
     public GameObject battery2;
     public GameObject battery3;
     public GameObject safe;
     public GameObject scream;
     public static bool enableBatteries = false;
     public GameObject clue1;
     public GameObject inputField;
     public GameObject pwQs;
     void Update()
     {
         if (Input.GetMouseButtonDown(0)) //FOR MOUSE CLICKS
         {
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             if (Physics.Raycast(ray, out hit))
             {
                 Debug.Log("Name = " + hit.collider.name);
                 Debug.Log("Tag = " + hit.collider.tag);
                 Debug.Log("Hit Point = " + hit.point);
                 Debug.Log("Object position = " + hit.collider.gameObject.transform.position);
                 Debug.Log("--------------");
                
                 if (hit.collider.tag == "book1")
                 {
                     StartCoroutine(showClue1());
                     Debug.Log("ssssscxxsx");
                     enableBatteries = true;
                     addStuff();
                 } else if (hit.collider.tag == "painting"){
                      isOpen = !isOpen;
                      hit.collider.gameObject.GetComponent<PaintingOpen>().Uncover(isOpen);
                  } else if (hit.collider.tag == "pillow"){
                      isLift = !isLift;
                      hit.collider.gameObject.GetComponent<LiftPillow>().Lift(isLift);
                  } else if (hit.collider.tag == "tvdrawer"){
                      drawOpen = !drawOpen;
                      hit.collider.gameObject.GetComponent<OpenDrawer>().OpenDraw(drawOpen);
                  } else if (hit.collider.tag == "book"){
                      if (PlayerCollisions.showedGJ){
                          canUncScream = true;
                         StartCoroutine(showPaintClue());
                         safe.SetActive(true);
                      }
                  } else if (hit.collider.tag == "safe"){
                      inputField.SetActive(true);
                      pwQs.SetActive(true);
                  }
             }
         }
      
  
     }
  
     public IEnumerator showClue1() //NOT SHOWING WHEN BOOK1 IS CLICKED
     {
         clue1.gameObject.SetActive(true);
         yield return new WaitForSeconds(10);
         clue1.gameObject.SetActive(false);
         enableBatteries = true;
     }
  
     public IEnumerator showPaintClue(){
         scream.SetActive(true);
         yield return new WaitForSeconds(10);
         scream.SetActive(false);
     }
  
     void addStuff()
     {
         if (enableBatteries)
         {
          
             if (battery1 != null && battery2 != null && battery3 != null)
                 battery1.SetActive(true);
                 battery2.SetActive(true);
                 battery3.SetActive(true);
  
         }
  
     }
  
  
 }

I've put all of the public gameobjects in their respective slots in the inspector, everywhere, and I've checked all of the methods using parameters and ensured they're called correctly. All seems fine regarding this. Plus, it all works within the Unity application itself.

How do I fix my mouse click when it's not working on WebGL build? Thanks.

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

0 Replies

· Add your reply
  • Sort: 

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

206 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 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 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

How can I disable mouse input completely? 3 Answers

2D Vector Composite input is not working on my WebGL build 0 Answers

Shift Input.GetKey returns true even if button no longer held down on Mac WebGL if Shift+Command+4 is pressed (screenshot) 0 Answers

How to control global mouse 0 Answers

Left Mouse doesn't register click when keyboard button is pressed 1 Answer


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