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
1
answer
52
views
Can't get a Prefab to scale down accordingly inside a Container
I have a prefab with some fixed sizes on itself and its elements:
Then added a Aspect Ratio Fitter and a Preferred Height:
.
When using that prefab from a container with Horizontal Layout Group with ...
1
vote
1
answer
74
views
Change sprites for multiple image in one function
I am trying to make a digital clock (24:00 type), where each number is an individual image, that should change. So, I want to change sprites for multiple images in one piece of code.
But when I ...
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
231
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&...
-1
votes
1
answer
81
views
How to match UI text size and position between editor and build?
In the editor, it does not matter if I set the resolution in the game view to my pc resolution (1920x1080) or to "Free Aspect".
The only thing that changes is that in "Free Aspect",...
0
votes
2
answers
138
views
How to highlight only specific part of the UI image in Unity?
How can I highlight only specific parts of an image in Unity?
My image would be something like the example below: a grid with text and fields. Text can be separated, but I would prefer it be part of ...
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 ...
3
votes
2
answers
1k
views
Rendering transparent UI in Linear Color Space
As you may know, Unity can have issues correctly rendering transparent 2D Sprites/Textures exported from Photoshop or Figma. Reason being that most of these tools operate in Gamma color space while ...
0
votes
0
answers
51
views
How to change colours of UI in Unity using Animation?
I'm making UI that's using controller support, and therefore I have to script it and use an Animation, but how do I make sure that a color change when hovering over a button happens instantly, because ...
1
vote
4
answers
2k
views
How to make TextMeshProUGUI truncate the left part (beginning) of a line?
I'm trying to display file names including their directory. When the file path gets too long for the text box, I want to align it right, because the filename is more important than the directory.
I ...
1
vote
1
answer
291
views
How should I go about handling multiple phone resolutions from a reference resolution?
I built my entire game in Unity based on my Android phone resolution, both for UI and object sizes. Now, everything looks good for a 1080 x 2400 resolution, but I know that's not the aspect ratio of ...
0
votes
0
answers
58
views
Blurry Board Game Node Images in Unity (UI & Sprite Issue)
I'm developing a board game in Unity and facing an issue with image clarity. The board consists of multiple nodes, each displaying a 480x600 px image. However, these images appear blurry and ...
0
votes
1
answer
66
views
How to build a Unity WebXR scene that uses raycasters?
I am fairly new to Unity. I want to create a VR project that I build to WebXR and publish to the web. I am using the sample scene from this project and it helps me get up and running. I am able to ...
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 ...
1
vote
1
answer
2k
views
is it possible to render world space canvas over other objects in unity?
for some pickable object, I display a UI canvas. It's attached to a scene gameObject. Sometimes the Canvas UI overlaps with some other objects. I need to make sure the UI is always renderer on top of ...
16
votes
1
answer
6k
views
Blank 2.2 KB sized PNG costs 2.1 MB in Unity? What does this represent? What to do?
I am starting to work on optimization for my app. I need to understand the information Unity displays about file sizes. For example, just to prove a point, here is a 2.2 KB completely blank PNG which ...
0
votes
0
answers
76
views
Unity UI Images without a sprite set are invisible when the containing scene is loaded additively
I have a game with several scenes, all loaded using addressables:
A persistent scene that stays loaded with things like the main
camera and certain common game systems.
A lobby scene
A game scene
...
0
votes
0
answers
56
views
Unity Editor Api for scriptable object apply on Edit Mode
So i want to design an editor which has the following requirements.
Suppose i already have a prefab called Player.prefab and script attached as Player.cs
And have a scriptable object called ...
2
votes
2
answers
1k
views
Should I destroy dynamically created Image.sprite?
Image sprite is created programmatically
_image.sprite = Sprite.Create(texture, ...);
Should I destroy it before replacing with a new one?
P.S.
My question comes ...
1
vote
0
answers
55
views
Unity Button ID is -1
I have a UI Document on a gameobject. while hovering on a UI button when i press mouse 4 on my logitech g502 it gives me an error. I did this by accident when i pressed mouse 4 instead of left ...
0
votes
1
answer
87
views
Coins Not Moving to Canvas Position When Camera Moves
I am currently developing a 2D game in Unity, and I'm having an issue with moving coins to a specific position in the UI Canvas when they are spawned. I want the coins to animate from their spawn ...
0
votes
0
answers
31
views
Bug Canvas image being stuttered when move follow player?
I tried to code an image to follow the character using canvas but it jerks when moving. Is this a bug? Do you have any solution to fix it?
https://youtu.be/OnT9Pabgi2g
...
0
votes
1
answer
94
views
How can I increase my counter and have it persist across scenes and runtime?
I am working on persistence and have an issue where a counter is not persisting across scenes and runtimes. I have a counter, and it goes up in on scene, but does not show changes when going to other ...
0
votes
2
answers
663
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 ...
2
votes
1
answer
507
views
How to manage UI sound effects?
I'm making the main menu for a small game I'm making, and when I was learning how to make buttons etc.
In order to make the buttons have a sound effect when pressed and so on, I was told to add an ...
0
votes
0
answers
28
views
why my button isn't showing clicked in unity [duplicate]
So i was following this tutorial https://youtu.be/lF26yGJbsQk to make a start button for my unity game. But some how the button is not working and don't know why?
2
votes
2
answers
157
views
How would I make minimap of racing track where dot follows track progress in Unity?
I would like to show race progress in my UI. My minimap is like sketch below:
Blue dot represents progress and red dot is finish line. I would like this to work in UI so only blue dot would move. If ...
0
votes
0
answers
300
views
Buttons in a scroll view not working
I have created a scroll view in Unity, and wanted to make the elements inside clickable. It would function as a level select menu. The level panels are instantiated from a prefab.
As a first approach ...
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
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:
...
1
vote
2
answers
3k
views
Interacting with World Space UI
Been struggling with this one for a while. I've found a few other posts across Stack Exchange and the Unity forums that seem to have the same problem, but their solutions don't work for me (at least ...
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
2
answers
169
views
Add round edges to heptagon shaped image with fill in Unity
I am not sure if this is possible I have this image:
This is how it looks when I do radial fill:
My question is if there is a way to make edges rounded while filling the image.
Rough sketch of what ...
0
votes
2
answers
820
views
Adding text label to sprite
I'm completely new to Unity. I'm trying to create something similar to Scrabble.
I've simply got a tile as a sprite (red arrow).Firstly, I don't understand it being so small.. I'm trying to give the ...
0
votes
1
answer
140
views
Image over everything Unity
I want to create a UI for a VR game to use it as a loading screen, the scene has a camera an image, a text mesh and a loading icon, the image is the background and the text and loading icon should be ...
0
votes
1
answer
55
views
Why does a numeric input field appear in my Unity event when it doesn't in the tutorial?
I was making a game main menu by watching a video online.
In that video, while setting the volume Slider, after adding the coded script in the On Value Changed section and selecting ...
-1
votes
1
answer
318
views
unity onTriggerEnter does not work
so in here there is a box to which i have attaches this script and ATTACH1 is a socket interactor here i want is when the box which i have attaches attaches to that socket interactor the text which is ...
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 ...
11
votes
1
answer
3k
views
Non-stretching health bar?
Here's what I want:
Here's what I got:
What is this procedural image unmasking called? Popcap didn't do image-splitting (source images below), but I feel like I'm missing the obvious here.
(Source ...
0
votes
1
answer
335
views
Unity debug error “Frame not in module”
I'm creating a 2D game, and all my game layers are UI canvases. Here's the issue: during debugging, every time I click on the screen, Visual Studio stops and displays "Frame not in module," ...
0
votes
1
answer
245
views
Canvas that should only be visible for local player is also visible for remote players
I'm using Unity NetCode for Game Objects. I have a player Prefab, inside it I have a canvas as a child of my player Prefab (I don't know if it's the best approach), which contains inventory, status, ...
0
votes
2
answers
64
views
Unity LookAt says reference not set but it is
This is my code
...
0
votes
1
answer
675
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
94
views
How to get value of transitionDuration in C# for Unity UI Toolkit
My existing code for this task is:
...
2
votes
1
answer
2k
views
How to make a sprite fill the image?
I created a custom UI Button:
However, when I use the sprite as the image for a button it doesn't fill out the whole "Collision" area:
This is an example of how I want it to fill the "...
0
votes
0
answers
59
views
Why do my shaders render differently in the simulator?
I am using simple shaders on the cards in my game. The shader is assigned as a material to a white image the covers the whole card.
They render as intended in the scene view, but do not in IOS ...
1
vote
2
answers
18k
views
How to get selected value in a dropdown
I made a simple survey from a guide on YouTube.
The trouble is that dropdowns are not mentioned in there, and I have totally no idea how to get the selected text value from it.
I tried multiple ...
0
votes
1
answer
192
views
UIElement button does not work when clicked
I have a small issue with my UI. Whenever I click a button on my pause menu ui nothing happens even when I hover over the buttons. However, in my main menu scene, the UI works without any problems. ...
0
votes
0
answers
72
views
Why do Unity UI toggle groups update *after* the default time in Execution Order settings?
Why is toggle group after default time in the default script execution order in Unity?
0
votes
1
answer
697
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 ...