Hi I have a quiz game my problem is when the user tap the three choices at the same time they will always have the right answer, i want to disable that, is it possible? Thanks you.
it depends if you need multitouch for something else, or else you should be able to just do
multiTouchEnabled = false; (https://docs.unity3d.com/ScriptReference/Input-multiTouchEnabled.html)
You could also in your code disable all input as soon as you register the first touch, so when just one of the buttons gets touched, turn off the collider on all the other buttons.
If this doesn't help we will need to see some code to be able to help.
Related
I have an interactable ground like a network of hexagon tiles in my project. I am using a new UI system from Unity, UI toolkit, and clicking a UI button makes Raycast go through and interact with the tile below.
I read about some dirty solutions, but I believe there is a better solution than these:
https://forum.unity.com/threads/ui-toolkit-and-raycast-block.1034938/#post-8218593
In old UI system was something like EventSystem.current.IsPointerOverGameObject
Can anyone help me?
Is the clicked button working? If not you are probably missing raycast target. Make sure it is set to true on your button's image. If that's not the case you could try using:
UnityEngine.Event.current.Use();
in your buttons callback to consume the event and stop further execution.
I found the way to make EventSystem.current.IsPointerOverGameObject work.
I had a big #Screen VisualElement streching the whole screen. In the UI builder there is a property named PickingMode under the first inspector section. You just set it to ignore and it will not be detected.
If you want to check individual elements, I have no solution for that, but there is a method .Pick(Vector2) and I don't know how it works yet.
https://docs.unity3d.com/Manual/UIE-faq-event-and-input-system.html
I am currently developing a UI for my Unity game. Due that I have started creating a KeyBinder-Menu where one can reassign the keys. This works fine until I tryed to implement it for the Mousebuttons.
I tried using Event.current.button so i can handle mouse input, but first of all it returns 0 all the time when i am not pressing anything else then mousebutton 0 and secondly it does not react to my extra mousebuttons.
Then I tryed Input.GetKeyDown(KeyCode.MouseX) (X would be the mousebutton I want to handle) This works fine with mousebutton 0, 1 and 2 but does not work with my extrabuttons to. I have a Mouse from Logitech with 2 extra buttons and they work fine with all games (like lol, Rainbow, minecraft ....) so I dont know why unity can not handle them.
Thanks for all answers I may get.
This is currently a bug, i already submitted a bug report about it you can vote for it here:
https://issuetracker.unity3d.com/issues/event-dot-button-only-supports-right-left-and-middle-mouse-buttons
However Input.GetMouseButton(x); will still read your extra mouse buttons correctly where x is an integer
Eg.: Input.GetMouseButton(12); will read your 12th mouse button on a gaming mouse ...
You can also do release, push events:
Returns true during the frame the user pressed the given mouse button.
Input.GetMouseButtonDown(int button);
Returns whether the given mouse button is held down or not.
Input.GetMouseButton(int button);
Returns true during the frame the user releases the given mouse button.
Input.GetMouseButtonUp(int button);
Update from Unity:
Thanks again for reporting this issue. It has been reviewed by our developers and unfortunately, it has been decided that it will not be fixed. As of now, IMGUI doesn't support more than 3 buttons, and since IMGUI is being replaced with UIElements this ability is not going to be added.
I have developed a board game. I want to add one more feature onto it. If I move my cursor onto one of the entry on the game board. It will show relevant information right next to the cursor. I know I can add invisible controls onto the game board and use Control.MouseHover Event to make this feature work. However, what kind of invisible control I can add onto the board? The rectangle shape will be most useful. One more question, how to display text right next to the cursor? I have attached the board I was talking about in below.
Thank you for helping me.
I am making the game of minesweeper and I wrote the game all on the gui in c#. I want to now work on the model-view aspect of things and I need help bringing the gui together with the model.
Meaning:
I made a call called MinesweeperModel which in it will contain a 10 x 10 grid[,] of values. If the grid has a bomb the value will be -1 if not it will be 0. In the model view all of the methods are written there, like NewGame(), GameOver(), SetUp(), GameLogicChecker()(this checks if there are any bombs and assigns the square a value to how many bombs it is near) etc. However in the gui aspect of things I have a similar grid of buttons[,] which are also 10X10. What I am trying to do is when I click on a button that coordinate will correspond to a coordinate in the model grid, and therefore the method created in the model grid can work on the buttons as well. But I am not exactly sure how to bring it together.
Thanks!
You could go through and add button click events to each button by double clicking it in the gui editor. Then having it call the GameLogicChecker() function inside of it. Maybe you could give a little bit more information I'm not quite sure what your asking for.
I have for example a rectangle in a grid and I have a button "new" I want to make a new rectangle like the exist one and I want to make animation using c# to transfer the old rectangle to right out of View and transfer the new one from left to be on the show and I have a button back to reverse the animation and I want this animation everytime I press new and back how ?
I'm not exactly sure if this is what you are looking for. The way to go with Animations is to use Storyboards. MSDN has excellent code examples for this:
Check out: http://msdn.microsoft.com/en-us/library/ms742868.aspx
To execute your storyboard you can use Trigger. In your case would want to listen for Click events. An example can also be found in the link above (although they are using a different event).
I hope that helps you.