A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Separate names with a comma.
Discussion in 'UGUI & TextMesh Pro' started by Sargaxon, Aug 25, 2016.
I solve it, Actually some transparent panel was blocking it.
If you have created something like a pause menu then make all over canvases disabled whilst within the Pause Menu using (Canvas Name).SetActive(false); Make sure to Reference the canvas as a game object if your new to unity
I solved mine by deleting all canvas in parents of the button. Why did the canvas block raycast in the first place? I have no idea.
I was using canvas to group batches and with them gone now nothing batches according to the frame debugger.
Definitely a bug. I have done A/B testing and makes no sense whatsoever
canvas > set order > 1
I had the same problem, and for me the solution was to look for the EventSystem in the hierarchy. There is a Standalone Input Module which I disabled because it always creates additional inputs in the input manager which is quite annoying. However as soon as I reenabled it, the buttons worked...
This might be the most accurate solution. Show us your hierarchy.
Don't forget to add EventSystem in your scene. If the scene doesn't have any event trigger is not able to track any events that's happening in the scene
Ensure that the scene contains EventSystem
oh yes i deleted it thinking that it not needed to me i feeling self as idiot
Before Changing Any Settings or adding Anything, DO THE FOLLOWING:-
1. Create an Empty Project.
2. Right Click in Hierarchy and from UI, select Button.
3. Play The Scene and Check if the Button is working or not.
Point1:- If the Button is Working, that means you have done something wrong in your Project(where it's not working).
In that case, follow the solutions provided by others. One of them might surely work.
Point 2:- If the Button is not working, then that means Your Unity Editor has some bugs or You did something (unknowingly) which caused the UI's not work.
Solution: If your case is Point 2, then I guess nobody know how to fix it, or if Someone knows, then he didn't shared it.
The Only thing You can do is Upgrade Your Unity Version.
The Problem Happened to my Unity 2020.1.4f1. I tried all the solutions(from different forums), but nothing worked.
Then I decided to change the Unity Version to see if works or not.
I opened UnityHub>Installs>Add, there I was about to install the Recommended Released LTS version, but then I saw there is a Pre-released Alpha Version Unity 2021.
I installed it(cause I wanted to) and when I opened that same Project in this alpha version. The Problem is just gone.
* Since I got the solution in my first attempt, I didn't bother to install any other version. But I am pretty much sure changing to any other version will work.
* Remember I installed another version from UnityHub, not from Unity Edtor>Help>Check for Updates.
Damn Right! I forgot to ADD the event system
BRUH ME TOO
My button needed to be inside a canvas with a "Graphic Raycaster" component.
My button needed to have "Raycast Target" checked.
In my case I fix it by just adding event system that I coincidently deleted it
My Buttons are working on the canvas, but as soon as I enable a player controller script (attached to a player with camera) they stop working and don't even change color when you mousehover them. I am very new in unity and couldn't find the error
I'm doing this for a university project and would be very thankful for any help.
This is the code from the player controller script:
public class PlayerController : MonoBehaviour
[SerializeField] Transform playerCamera = null;
[SerializeField] float mouseSensitivity = 3.5f;
[SerializeField] float walkSpeed = 6.0f;
[SerializeField] float gravity = -13.0f;
[SerializeField] [Range(0.0f, 0.5f)] float moveSmoothTime = 0.3f;
[SerializeField] [Range(0.0f, 0.5f)] float mouseSmoothTime = 0.03f;
[SerializeField] bool lockCursor = true;
float cameraPitch = 0.0f;
float velocityY = 0.0f;
CharacterController controller = null;
Vector2 currentDir = Vector2.zero;
Vector2 currentDirVelocity = Vector2.zero;
Vector2 currentMouseDelta = Vector2.zero;
Vector2 currentMouseDeltaVelocity = Vector2.zero;
controller = GetComponent<CharacterController>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Vector2 targetMouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
currentMouseDelta = Vector2.SmoothDamp(currentMouseDelta, targetMouseDelta, ref currentMouseDeltaVelocity, mouseSmoothTime);
cameraPitch -= currentMouseDelta.y * mouseSensitivity;
cameraPitch = Mathf.Clamp(cameraPitch, -90.0f, 90.0f);
playerCamera.localEulerAngles = Vector3.right * cameraPitch;
transform.Rotate(Vector3.up * currentMouseDelta.x * mouseSensitivity);
Vector2 targetDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
currentDir = Vector2.SmoothDamp(currentDir, targetDir, ref currentDirVelocity, moveSmoothTime);
velocityY = 0.0f;
velocityY += gravity * Time.deltaTime;
Vector3 velocity = (transform.forward * currentDir.y + transform.right * currentDir.x) * walkSpeed + Vector3.up * velocityY;
controller.Move(velocity * Time.deltaTime);
There are so many things I love about Unity... but one of the most steep curves they put in front of people should be one of the most simple things possible to troubleshoot. I have a ton of courses i've put on Udemy and my own private courses, I've consulted on over 200 games and this is in my top 3 pain in the neck troubleshooting areas. Too many poorly integrated and documented systems that do nothing to provide the level of feedback a developer would need to troubleshoot what is going on. They need an intelligent camera/view/layer manager that can look at what is trying to be done and setup configurations that work out of the box. Let the computer go down a checklist of 8-10 settings to determine why you can't click a button or see your sprite. Crazy town. End rant.
Ok--I have found yet one more possible cause:
As with others, the button didn't work---it would visually depress, but nothing would happen.
It turned out, I was having the button call a method on a persistent singleton object, one that was loaded in another scene and placed under "Do Not Destroy On Load". The object the button was calling from wasn't the same object that existed, as a result, but a copy that had been destroyed by the singleton on scene load.
The solution was to make a new script, attach it to the button itself, one that is neither persistent nor a singleton, and I called the method from that script instead. Very frustrating problem solved!
wow I solved the problem by Disabling it but THANKS
public class MouseLook : MonoBehaviour
public float lookspeed = 100f;
public Transform playermo;
float rtr = 0f;
// Start is called before the first frame update
Cursor.lockState = CursorLockMode.Locked;
// Update is called once per frame
float mouseX = Input.GetAxis("Mouse X") * lookspeed * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * lookspeed * Time.deltaTime;
rtr -= mouseY;
rtr = Mathf.Clamp(rtr, -90, 90);
transform.localRotation = Quaternion.Euler(rtr, 0f, 0f);
playermo.Rotate(Vector3.up * mouseX);
When I enable the script I cant click the button why?
That's because in the editor if you press escape it actually forces the cursor to free, bu the game still think's that's what has happened.
So the cursor.locstate=lockmode.locked is what's causing that.
Create a script that frees the cursor to cursorlockmode.none when paused and lock it again when unpaused.
If you have or make during any coding any Ui it is best to make sure your colliders, shown as a box moving w each UI , is stacked, best to make sure they all are the same but definitely needs the parent panel and each item or yu get the touch wherever that ui collider is
My Issue Was solved by Removing empty functions GameObjects in the Onclick. This issue Might have started when I deleted and duplicated them at runtime to replace them.
My Issue Was solved by checking "interactable" in the canvas group of the parent gameobject and the button itself.
Updated for the new Input System.
Under Player Settings..... Input System Package, check that the Default Button Press Point has not been set to 0.
This prevented buttons in Android raising an onClick event. Setting the value to 0.5 worked fine.
Thank You sooooo much for this. I would have gone mad if i didn't find this comment so thank you
my buttons were not working too. It is working now because there is no event system. Thank you very much.
Sometimes if you parent a button to something inside the canvas and not directly to the canvas it causes the button to not work.
ahahah me too!
Hey guys, after days trying to solve this problem, a friend help me with that!
If you are using a type of first person controller asset and nothing was solved, you have to check the camera movement script on this asset.
In my case, the asset mini first person controller was disabling the cursor when the player returns to the main menu scene. So if you have this problem, you have to change the asset script, and menu will work.
omg ilysm ik this is an old thread but oh my god you just saved me from dying
It took me hours to figure this out.
I found out just now that TMP messes with the shader channels and that broke my UI, I got it fixed now.
I tried everything more than half an hour and seemed that nothing was working for me.
The issue was that by using the new input system i didn't put a mouse in the Project Settings -> Input System Package -> Supported Devices.
Another Point. If your cursor is set to CursorLockMode.Locked while clicking, it wont trigger OnClick() for buttons
My Problem is my Main Menu were you start the game is working and when you press start in the main menu it took you to the first level which have a pause menu and no buttons sliders or dropdowns ... are working
I have also tried every suggestion in this thread, but none worked.
After some sick trials, I found out that,
if I create the button right clicking the children of the main canvas like layout groupers etc., the button didn't work.
if I add button component to the children, the button didn't work,
if I create the button right clicking the main canvas, than the button work flawless.
Seems to be weird but it solved my problem, hope it helps anyone else...
Many people looking up this thread should check if they deleted their EventSystem. If that is gone the buttons wont work, I have no idea why but this was the problem for me. and as a newbie I bet others do the same mistake.
After 3 hours of searching the solution for me was to just delete the EventSystem and created a new one.
Thank you so much you saved my project i have been deppressed for 2 days thank you one more time
maybe you download package couse removed ui
delete or remove the package
omg you saved me!!, thank you soooo much <3, i almost fall into depression.
I had a similar issue. My problem was that I created an empty object to help organize some game objects. Then I added a canvas component to the empty object to control "Sort Order" for the group. But buttons under that object stopped accepting inputs. I added a Ray Caster to the empty object and now it all works.
I had the same problem. I have TextMeshProUGUI in my hierarchy. First I set the font size instead of TextMeshPro's scaling. But it prevented the button's event and because the background was transparent ı couldn't notice it.
After that, I made smaller the scale of the TextMeshPro and made bigger font size. And problem was gone.
And adding the camera to the canvas can solve it as well.
I have this problem. And although I followed all the steps it ain't working.
Can't find any solution I am confused.
I have tried every possible comment in this page and my button still doesn't work . Please if anyone can find the solution . I am making a game which has levels . In it I have the first level which work completely fine and there is the second level which doesn't work and it has the exact same button / UI . For the first level I made the buttons fresh and made them into prefabs . In the second level I used the prefab which doesn't work now