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
1
vote
0
answers
501
views
How can I instantiate an object at a certain position?
In my game, the player drives a car and when the car reaches the end of the road, I want a different road prefab to be spawned. I have multiple road prefabs, and want to be able to spawn one when the ...
1
vote
0
answers
247
views
How to tell which letter or vertex of a letter is at a certain screen position with a Unity UI Toolkit Label or TextElement?
I am using the Unity UI Toolkit and I would like to create my own TextField class (ie. input field, similar to the one I'm typing in now to write this message) with better functions using the Label ...
1
vote
0
answers
139
views
How to make UI animation blend smoothly from the previous state when interrupted?
I have a UI that I want to animate via PointerEnter and PointerExit, but if an event gets fired while an animation is in progress, it makes the animation jump to the start point of that animation clip ...
1
vote
2
answers
952
views
How to have unity inspector variables modify each other bidirectionally and update in real time [duplicate]
Trying to make some inspector controls that both modify the same thing but in different ways, and I want them to both update when the other is edited. Won't bore with the details but there's a reason. ...
1
vote
0
answers
196
views
How to control from which point radial image fill starts in Unity?
This is probably basic question but can I set the point from which fill starts. I know about down, up, left, right options but I want more control with start point, for example I want my fill to start ...
1
vote
0
answers
40
views
Editing an InputField on mobile with the keypad open, it wont let me edit another field without loosing focus on the current 1st. How to by pass?
When I'm typing into a tmp input field on a mobile keypad, I can't instantly edit another input field by clicking it!? I have to click off the keypad to loose focus on the current before I can click ...
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 ...
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
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 ...
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:
...
1
vote
0
answers
50
views
How to access List<T> items dring runtime? Where does this data go, and how can I use it? (I think this is a "fundamentals" thing)
So, I'm piecing together a nutrition-helper that's mostly a catalog, some lists, and a calculator. I'm using Unity C#, an xml deserializer, and building to the android platform.
The xml deserializer ...
1
vote
0
answers
2k
views
How to zoom image on Unity UI to particular point where mouse cursor is located?
I have some RectTransform on Unity UI. I have already implemented some Zoom functionality but now I need it to zoom to the area where the mouse cursor is located. Currently, it zooms to the anchor ...
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
2
answers
8k
views
How to set a variable from the selected text of a dropdown menu in Unity?
I am trying to set a variable from the value of a DropDown menu in Unity.
I wrote a script as follows, attached it to the dropdown and set it to run it in Unity under: On Value Changed (Int32).
I have ...
0
votes
1
answer
458
views
In Unity editor, how to import package from github?
In the latest Unity editor 2021.3.25f1 LTS, I'm trying to directly import the following package from github:
https://github.com/yasirkula/UnityNativeFilePicker/releases/tag/v1.3.0
But when I import ...
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
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
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'...
0
votes
2
answers
87
views
UI tween animation completely different on Phone and in Unity Editor
I have this function that spawns an Icon from a world position and animates it to correct UI position. In editor it works fine but in apk on phone it has a wrong starting position. Now as I understand ...
0
votes
1
answer
550
views
Clicking UI button calls event twice
I've designed a game where, when a button is clicked, the moving point stops. If the button is clicked again, the moving point starts moving again.
I only click on the button once, but the ...
0
votes
1
answer
134
views
"Button is not an attribute class" error when integrating Steam achievements
I am writing the code for my button, but it's giving me errors like this:
Assets\Scripts\SteamIntegration.cs (60, 6): 'Button' is not an attribute class
Where did I make a mistake in this code?
<...
0
votes
1
answer
1k
views
UI not scaling properly
I'm trying to create an endless runner type game where once the player dies, a popup opens letting the user know that the player can be saved by watching an ad. This is how the popup looks in the game ...
0
votes
1
answer
143
views
Remove default menu controls
I have a vertical layout group filled with UI buttons used as menus in my game. They work well for mousing over and clicking, and I am in the process of adding keyboard controls.
The issue I have is ...
0
votes
1
answer
466
views
Reference as local variable in Unity c#
In the script below, "btn" is a local variable in OnEnable() method. It's said that local variable is deallocated (lost) when leaving the countaining method. Why this one (btn) is not ?
Nb: ...
0
votes
1
answer
778
views
How to update the UI system in unity after changing a triangle in code
I am trying to write a real time Line Graph Renderer using the UI system in Unity 2019. Meaning I need to change the data on the fly and have the graph update.
What i have found is that OnPopulateMesh ...
0
votes
1
answer
2k
views
SVG Image in UI
I'm using Vector Graphics for my SVG Images,
though when I try to use it as a UI image (for a button)
The image doesn't look as I expect, unless I use a Sprite Renderer.
But unfortunately I can't do ...
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
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
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 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
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 ...
0
votes
2
answers
4k
views
Button to call Application.OpenURL not working
I have a public method
public void patreononclick(){
Application.OpenURL("http://www.patreon.com/HubakaGs");
}
This is supposed to open my Patreon ...
0
votes
1
answer
232
views
How to position health bars above units in Unity regardless of camera location, angle and zoom?
Here is what I want to achieve, health bars that stay perfectly above the units, regardless of where the unit moves or where the camera is: https://www.youtube.com/live/fZSaPDz-GJc?si=B868wwF5KAPCuEtw&...
0
votes
1
answer
165
views
Resizing a Sprite in 3D space to match its native pixel size at a target screen resolution?
I am placing a 3D game object with a SpriteRenderer + Billboard attached to it in my scene.
However, since it's a distance away from a perspective camera, the sprite gets scaled, losing a lot of the ...
0
votes
1
answer
54
views
How to prevent button drift (despite anchoring) when resizing game window?
My Unity game has graphics designed for aspect ratios of 16:9, 16:10, 4:3, 3:2, and 19.5:9. This worked for mobile. But now I want to create a PC version for Steam, and I have to deal with the user ...
0
votes
2
answers
64
views
Unity LookAt says reference not set but it is
This is my code
...
0
votes
1
answer
94
views
How to get value of transitionDuration in C# for Unity UI Toolkit
My existing code for this task is:
...
0
votes
2
answers
664
views
Unity UI Buttons not working (not clickable)
Buttons Easy, Medium and Hard can not be clicked even though Restart Button was clickable from the start. All of the buttons have interactable checkbox on and raycast target on. Shadow panels and ...
0
votes
1
answer
1k
views
How can I instantiate a prefab in a canvas and have it positioned relative to its parent?
I am trying to load, at run time, a UI prefab and have that display on a canvas. I was following the directions found on this forum. I am able to get it to load and display, but it is not showing up ...
0
votes
2
answers
201
views
How to remove loading delay when loading from Appdata? Or to load everything at start?
Currently, when loading from Appdata, there is a noticeable delay. See a sample video here, when it changes from the sprite set in UI to the sprite loaded from Appdata through C# script.
I want to ...
0
votes
1
answer
148
views
How to alternate child placement to the left and right in a vertical stack?
Is it possible to arrange alternate children separately in a vertical layout group?
I want to arrange the child elements so that one is aligned to the left, the next one is aligned to the right, and ...
0
votes
1
answer
677
views
When switching between two scenes: MissingReferenceException: The object of type '...' has been destroyed but you are still trying to access it
I recreated the problem in a new project to check and test the problem, but I don't understand it.
Two scenes:
First scene
A GameObject with this script that simply jumps to the second scene.
...
0
votes
1
answer
67
views
3rd Button on UI Seems to not Register the onClick.AddListener()
I have a UIManager meant to control the UI. The UI manager is attached to an empty game object.
The Canvas has three panels, ...
0
votes
1
answer
310
views
How to create custom UI element from Hierarchy Menu in Unity?
I have a custom UI element and I would like to instantiate it from Hierarchy like you do with any other UI element (button, text etc.). I know how to do this so it is instantiated in the scene but how ...
0
votes
1
answer
1k
views
Is it possible to detect if the cursor is over a GameObject with a specific tag?
I've tried quite a few things, but none of them have worked reliably. Here is what I'm currently using:
...
0
votes
1
answer
698
views
Particle system objects in UI disappears/appears on screen unless I change the sorting rank
This happens to all particle systems. I tried:
Changing the rendering mode to camera, setting culling mask to UI, particle system layer set to UI
Adding a canvas child, and attaching a particle ...
0
votes
1
answer
135
views
Show an image as Tooltip in a Unity 3D
I got the following question:
How to show an image as Tooltip in a Unity3D?
The image should only be visible if the user hovers over the 3d object.
Thanks in advance,
hidayah
0
votes
1
answer
85
views
How do I create a button with a font by code?
I have written a code that would create background image as a button and then show a letter on that button. This should become a virtual keyboard.
I am experiencing weird drawing that looks like this:
...
0
votes
1
answer
2k
views
Scroll UI Image
Currently, I am scrolling a UI RawImage using the following:
...