Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by strudi1986 · Feb 08, 2018 at 04:23 PM · guiraycastbutton

Problem with GUI Buttons with WorldSpace Canvas

Hi there!I have a problem that the GUI Buttons dont work or react if i click on them. The Canvas is in World Space, because i want to drop the GUI on a keypad model. I have tried several things now, but the buttons dont react. i give you the screens of my settings and my testcode. any ideas? Thank you!

alt text

alt text

Maybe something is hiding the raycast?

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityStandardAssets.Characters.FirstPerson;
 using UnityEngine.UI;
 
 namespace FPSHorror
 {
     public class Keypad : MonoBehaviour
     {
         public string correctPassword;
         private string passwordInput;
 
         //Buttons and Numbers for Keypad
         public Button ButtonOneUp;
         public Button ButtonTwoUp;
         public Button ButtonThreeUp;
         public Button ButtonFourUp;
         public Button ButtonOneDown;
         public Button ButtonTwoDown;
         public Button ButtonThreeDown;
         public Button ButtonFourDown;
 
         private int numberOne;
         private int numberTwo;
         private int numberThree;
         private int numberFour;
 
         public Text numberOneText;
 
         private bool keypadActive = false;
 
         public Camera mainCam;
         public Camera keypadCam;
 
         //Initalizing Variables
         private FirstPersonController playerController;
         private GameManager_ToggleCursor toggleCursor;
 
         // Use this for initialization
         void Start ()
         {
             SetInitialReferences ();
         }
 
         void SetInitialReferences ()
         {
             playerController = GameObject.FindObjectOfType<FirstPersonController> ();
             toggleCursor = GameObject.FindObjectOfType<GameManager_ToggleCursor> ();
 
         }
 
         // Update is called once per frame
         void Update ()
         {
 
         }
 
         public void MoveCameraToKeypad()
         {
             mainCam.enabled = false;
             playerController.enabled = false;
             gameObject.layer = LayerMask.NameToLayer ("Default");
             toggleCursor.isCursorlocked = false;
             keypadActive = true;
             keypadCam.enabled = true;
         }
 
         public void CountNumberOneUp ()
         {
             numberOneText.text = numberOne.ToString ();
             numberOne = numberOne += 1;
             Debug.Log (numberOne);
             print ("Clicked");
         }
 
     }
 }
 
 

pic2.jpg (218.4 kB)
pic1.jpg (362.0 kB)
Comment
Add comment · Show 4
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 hexagonius · Feb 08, 2018 at 05:02 PM 0
Share

the parent of the canvas has a mesh collider. $$anonymous$$aybe that's blocking all the input from the canvas.

avatar image strudi1986 hexagonius · Feb 08, 2018 at 05:55 PM 0
Share

Ive tried to disable the mesh collider after changing the camera but the problem still exists. the ui buttons dont react on any clicks. Thanks for the help anyway!

avatar image hexagonius strudi1986 · Feb 08, 2018 at 06:21 PM 0
Share

since you have the buttons, either EventSystem or graphicsraycaster are missing.

avatar image strudi1986 · Feb 08, 2018 at 07:32 PM 0
Share

no EventSystem and graphicsraycaster are there. dont work :(

2 Replies

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

Answer by callen · Feb 08, 2018 at 07:46 PM

World space canvas needs to know what camera is sending it events, did you set the Canvas.worldCamera to your keypadCam?

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 strudi1986 · Feb 11, 2018 at 11:28 AM 0
Share

hmm ...there is still the problem with the World Space UI on these objects. If i have more than one prefabs of this in the scene the event cameras (?) are overlapping each other and i cant click the buttons on the object anymore. and i dont know how to fix this. or if there is even a solution for this. with one prefab in the scene the world space UI works fine and i click all the GUI Elements on the object. but if i add another one the gui dont work anymore as intended or only some elements are clickable and some are not because they are overlapping for some reason.

avatar image hexagonius strudi1986 · Feb 11, 2018 at 06:32 PM 0
Share

use one ui camera only

avatar image
0

Answer by strudi1986 · Feb 09, 2018 at 08:54 PM

tanks that helped! i also need to uncheck "Ignore Reserved Graphics" in the "Graphic Raycaster" Component on the Canvas! THX

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

165 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

Related Questions

Stop RayCast Passing thru GUI 4 Answers

Select a game object and perform actions using GUI.Button (EventTrigger) 2 Answers

Why does my UIButton needs a raycaster if the parent has one? 0 Answers

[Logical Error] Select a game object and perform actions using GUI.Button 1 Answer

Making raycasts go to the centre of the screen 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