Questions tagged [unity-ui]
Unity UI is a UI toolkit for developing user interfaces for games and applications in Unity. It is a GameObject-based system that uses Components and the Game View to arrange, position, and style user interfaces.
222 questions
0
votes
1
answer
3k
views
DOTween capacity always increasing
I'm creating a sequence and adding a couple of tweens to it. If I call it a couple of times the tweens capacity gets increased exponentially till everything gets incredible laggy.
I've recorded this ...
1
vote
3
answers
2k
views
Thin lines appear differently even though they are the same height
I have an issue that is driving me crazy. All these lines are 2 in height, but when moving around the screen they change thickness. As you can see the top line is thinner.
What can be done to make ...
0
votes
1
answer
128
views
how does unity handle image scaling
Unlike in android SDKs, in almost all tutorials I've seen, creating UI elements like menus in unity starts with laying out a default background image onto a canvas object.
I don't really get the fact ...
0
votes
2
answers
820
views
Use Buttons based on Key Presses instead of Mouse Click
I have a UI button. I want a function to be called whenever I press a specific key on my keyboard while my mouse is hovering over the button. I want to make something similar to UI in Ark SE where you ...
0
votes
4
answers
2k
views
Interacting with UI with a locked cursor?
It seems like Unity has disabled UI interaction while the cursor is locked, which is frustrating because the store in my game is an actual in-world one, and thus means the player has to look at the ...
0
votes
1
answer
199
views
Trigger Button with specific key only
I am having trouble understanding how to trigger a UI button with a specific joystick key only.
Currently i have a pause menu in which i have several buttons. By pressing start i set the game time ...
0
votes
2
answers
5k
views
What's the best way to draw gizmos in build
I currently use Unity gizmos for many debugging purposes, but I'd like almost all of them to be visible to the player in-game (when the game is built).
For example, when a player is dragging to place ...
0
votes
2
answers
2k
views
Help Me Make Sense of the Canvas and Text-Based Non-UI Objects in Unity
I am trying to wrap my head around the concept of the Canvas in Unity and its many uses especially outside of user interfaces. However, I cannot really find a good tutorial that digs deep enough into ...
0
votes
1
answer
1k
views
Identify when Unity Button Enters Pressed State
I am trying to create a UI Button Prefab with a text child element that I would like to use all over my application. Its intended behavior is very simple:
Its size would be dependent on the text's ...
1
vote
1
answer
747
views
Circular draggable UI element in Unity canvas
I am trying to implement my own runtime color picker that's easy to use for touch interfaces. I want the hue slider to be a ring, along these lines, except the whole ring texture would rotate when ...
0
votes
1
answer
206
views
Updating settings UI from script also triggers method to update settings from UI interaction
My application has a UI for settings which is a mixture of textboxes and scrollbars with which users can interact. I have created a class for these settings and create an object to store them. The ...
0
votes
2
answers
1k
views
When serializing a class, can its fields take their defaults from the Unity editor?
Can I have a custom serialized class whereby I set a value in the editor and that value persists into runtime, as happens with serialized monobehaviour fields?
Currently it sets itself to 0 or a ...
1
vote
1
answer
260
views
Unity UI - Make text come out and go back in
In Unity UI I have a TextMeshPro Button and some TextMeshPro Text like in the following image:
Is there any function in a Tween Library like DOTween that could make the text look like its coming out ...
0
votes
1
answer
750
views
Unity update sizeDelta in OnValidate based on Layout Group computed values
I'm trying to update the sizeDelta of a RectTransform in OnValidate. I'm trying to grab the computed values from a Layout Group.
Here's what I've got:
...
0
votes
1
answer
1k
views
How do I set the opacity of a Button to 0? (Unity)
I'm trying to hide a button when you click that button (I meant setting the opacity to 0, not disabling the game object of the button). What the button does is it loads a scene async. If I disable the ...
0
votes
3
answers
13k
views
Unity text is very blurry. How can I fix it?
Unity text is very blurry. How can I fix it?
To be honest, I have no idea why it behaves this way:
Hope that someone faced the same problem and will be able to share how it was tackled.
0
votes
1
answer
2k
views
Starting a Coroutine after another Coroutine ends
I have a method that fades the screen to black, then fades away back again using coroutines but I couldn't get the 2nd part to work.
FadeToBlack() works if I put <...
0
votes
1
answer
1k
views
How do I activate a game action when a UI button is held?
I want to make my button do stuff when the player holds it. In this case, I want to make a grab function: when the button is down the character can grab objects, but if the button is up they do not ...
0
votes
1
answer
97
views
How to make prefabs UI work on any canvas scaller?
I want to make my UI prefab working on all size of canvas reference resolution scaler because I already make one which is not prefab UI its work to all reference resolution but when I make it prefab ...
0
votes
2
answers
214
views
Spawning a customized sprite with text
I'm making a game where I have circles filed with words or pictures drop from the top of the screen to the bottom. they should spawn right above and then drop.
I just started using unity a couple days ...
1
vote
0
answers
3k
views
Orientation changed event in Unity3D?
I'd like to listen to orientation change events, so for example my UI layout or the components themselves can be changed.
All I've found is that I should check the value of ...
1
vote
1
answer
64
views
Do we have events for +/- buttons for a serialized list?
Does Unity fire any events when the user clicks these buttons? Or is there a way how to hook up code to respond to these actions?
0
votes
0
answers
635
views
What is the difference between WaitForSecondsRealtime and a counter?
I am making my own button using the Unity UI code, but now I got to the OnFinishSubmit () coroutine
...
0
votes
1
answer
73
views
NullReferenceException in reticle color change script while cycling through children
I could really use another set of eyes on this. I am running into this error: NullReferenceException: Object reference not set to an instance of an object I can't figure out.
In the script below. I've ...
0
votes
1
answer
599
views
UNITY: How to LOAD save file from main menu
So I've created a simple main menu with a new game, load game, and quit game buttons. In the new scene where I've created pause menu save/load buttons work, I've created a new object and attached a ...
0
votes
2
answers
183
views
How do I stop clicks on a button from also triggering my gameplay scripts?
My character jumps when I press the right side of screen. The pause button is alsp in the top right corner. So when I press that button, the right side script always triggers and I don't want that to ...
0
votes
1
answer
76
views
Non-invocable memeber 'Text.text' can not be used as a method [closed]
Trying to change text in a text box, and have multiple lines on it, i found something online talking about "\n" but this came up.
Non-invocable memeber 'Text.text' can not be used as a ...
0
votes
2
answers
127
views
Button reacts to the screen event in Unity
I use Unity 2019.4. I made a script so that if a make a long press on the screen of my mobile phone, my Personnal Character stops. I created a button to shoot gun too. The problem is when I make long ...
0
votes
1
answer
1k
views
How to get a specific button component
I'd like Unity to get a specific button with:
GetComponent<Button>().interactable
But how do I get a specific button with a name?
0
votes
1
answer
979
views
Display musical symbol (unicode) in Text component not working?
I downloaded and specified to use a unicode font that supports musical symbols (Musica), but when I set the text value of the Text component to "𝄞" nothing is displayed? I tried using the ...
0
votes
2
answers
2k
views
Strategy for temporarily blocking user input
What are good approaches for disabling user input during certain moments in a game?
In my case, I have a grid-based tactics game (kind of like Fire Emblem) where I periodically want to toggle the user'...
2
votes
0
answers
651
views
Unity - Emission Material on Top of UI
I've already uploaded this question in the Unity forums but only got a response but not an answer or solution. Here's a link to the original post: https://forum.unity.com/threads/emission-material-on-...
0
votes
1
answer
6k
views
Unity UI Buttons Not Functioning
I have been working on a UI Inventory System for my Unity game and for some reason, none of my buttons work in my game. All the buttons have the ‘interact-able’ box ticked and an EventSystem which is ...
2
votes
1
answer
7k
views
How to Detect a Right Mouse Click on a UI Button in Unity
I've been recently working on a videogame, and I'm trying to make a script that will destroy the game object it is applied to whenever the right mouse button is clicked on it. It doesn't function at ...
1
vote
1
answer
4k
views
Unity: How to get the visible bounds of an object, i.e. as it is seen from the camera?
Imagine you'd like to highlight a 3D GameObject by drawing a (translucent) UI panel above it. The UI panel should cover the object exactly. Therefore the object's bounds, as it is seen from the camera,...
0
votes
0
answers
116
views
Need help understanding this script
I found this script on a tutorial that I want to implement into my game, but I first want to understand what it does and how it does it. The script is attached to a Joystick UI, which has the inner ...
1
vote
1
answer
2k
views
Difference between methods - onClick.AddListener and On Click under UI button inspector?
Within my Unity Project in my code, (see below), I have a button called Check which executes when CheckPress() function is called. I read two approaches by which this can be done.
Appraoch 1: Using <...
2
votes
2
answers
14k
views
How to call a function in response to a Button's OnSelect event?
I'm new to Unity and C# and have been struggling to figure out how to solve this. What I'm looking for is a way to make text display whenever a button is selected. (ex. Player selects a difficulty ...
1
vote
1
answer
2k
views
How to instantiate a prefab at mouse location in the editor in unity?
I want to instantiate a prefab at the mouse position in the editor. All the answers I found till now are for instatiate a prefab at runtime but i want to instantiate in the editor.
Currently I am ...
0
votes
1
answer
2k
views
Text boxes keep on moving in Unity
I have added a few text boxes in my Unity game and they are at the bottom. When I fullscreen the game after building it, the text boxes show up in the right place but if I shrink the tab, the text ...
1
vote
1
answer
481
views
What is the Unity 2019.3.5 version of `UnityEngine.UI.Text`?
I was following a tutorial on how to create a dialogue Box in Unity, and in one part of the tutorial the tutor imports UnityEngine.UI and creates an object of type <...
1
vote
2
answers
5k
views
How to trigger onclick for Unity Selectable by script?
As title, I know Button can be triggered onclick by button.onClick.Invoke();
But how to simulate onclick event of Selectable?
Thanks for the help.
0
votes
0
answers
352
views
How can I make a health bar — a UI element — part of a character prefab?
Description
I want my character prefabs to come with their own health bar, but I can't simply add one as part of the prefab, because it's a UI element and therefore goes into a Canvas.
Potential ...
1
vote
1
answer
2k
views
How would I go about adding a tooltip to a Unity UI Image?
I'm going to try out the community here once more, I haven't had very good look in the past with getting help.
I'm iterating through a series of List() and I'm creating a bar graph and a line graph ...
1
vote
0
answers
299
views
Unable to wire UI Text object to C# Script
I have created UI text object
And then created Text field in behavior class:
...
0
votes
1
answer
769
views
Unity - Transforming horizontal distance between two spriteRenderers to set UnityEngine.UI.Button width to this distance
In my Unity scene, I have a couple of spriteRenderers and a UnityEngine.UI.Button called ...
0
votes
1
answer
364
views
Gradient Input in Game view
I want to develop a little tool to help visualize fireworks before using them in a show in Unity where the user can set several parameters and gets a preview of the firework effect in a preview window....
0
votes
1
answer
2k
views
How to calculate a child UI image's anchoredPosition(?) based on screen position input?
How to calculate a child UI image's anchoredPosition(?) based on screen position input?
I'm trying to have the child UI image (Spotlight) show up where the eyeball UI is, but it seems to always be ...
0
votes
1
answer
721
views
Working with Screen Space - Overlay canvases
So, say you've started a new project. You drop your in desired sprite. You can see how big it is relative to the Main Camera. That's cool.
Now you want to add a persistent bit of UI to the game, so ...
0
votes
1
answer
3k
views
How can I use Drag handlers (IBeginDragHandler, IEndDragHandler, IDragHandler) with a 2D sprite renderer instead of a UI Image?
In my game, I assigned all of the blocks to be 2D sprites so that they could be easily converted into prefabs:
However, when designing the drag and drop scripts, I noticed that all of the drag and ...