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
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 ...
13
votes
1
answer
80k
views
How does the Graphic Raycaster component work in Unity?
I'm making a small game for the first time and enjoying it thus far. The only thing that keeps bothering me is that I can't find a human explanation of what the graphic raycaster does. What's the ...
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 ...
4
votes
5
answers
2k
views
Clicking pause button makes character jump before pausing
I have an issue with my Unity 5 game. When I click on the Pause button, my character jumps before the game is paused.
My script detects the click to trigger the jump jump before the pause button. I ...
3
votes
2
answers
2k
views
What does this Yellow Outline represent in Unity Text Mesh Pro?
What does this Yellow Outline Represent around Text Mesh Pro Text objects in Unity? I don't see any regarding them in the inspector making it so that I have eye-ball it in the scene view to make it ...
3
votes
1
answer
1k
views
Screen split in different regions, each with a different scene
I am a complete beginner in Unity and, after having search for a while, I am still not sure if it is actually possible to achieve what I would like to do.
My goal is to have a game where the screen is ...
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 ...
3
votes
1
answer
986
views
enabling / disabling components from editor, while avoiding "SendMessage" warning
I am creating an editor tool that requires me to enable / disable components and or gameObjects via script while in edit mode. Currently everything that has to execute in edit mode is called from <...
2
votes
1
answer
14k
views
How do you repeat a tile texture horizontally/vertically in a UI Image?
It seems Unity UI Image supports Image Type 'Tiled', but I'm not sure how to get the tiling to work both vertically and horizontally. Can someone help me understand?
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 ...
2
votes
1
answer
5k
views
Sprite button not triggering "On Click()" event
Hi have created some buttons from sprite and I added image and button components on it.
I am just using sprites because In my game the camera can be moved on x and y. But I don't want my button to ...
2
votes
1
answer
115
views
Ball always showing in Unity
Some weird "ball" is showing when I select an element in Unity, preventing me to see the object itself:
I've tried to hide some layers, but even with all layers hidden it's still here:
Do you know how ...
2
votes
1
answer
5k
views
How to create instances of a Unity UI Toolkit template from code?
I'm using Unity UI Toolkit in Unity 2021.2.
Looking at the following example:
...
2
votes
1
answer
1k
views
How to make a Unity slider sit over evenly spaced points?
I'm working on a timeline UI element in Unity, that looks like this:
I generate the bottom ticks by instantiating a number of times over the length of the parent RectTransform, and offsetting them on ...
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 ...
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 "...
2
votes
1
answer
288
views
A way to test different DPI's in Unity?
Is there a way to force a Unity canvas set to "Constant Physical Size" to scale based on an arbitrary DPI value for testing purposes? It seems to only respond to the meta-data from the ...
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 ...
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 ...
2
votes
1
answer
916
views
Unity ScrollRect: Pass scrolling through to parent ScrollRect when reaching limits
I have a nested ScrollRect, or more specifically a scrollable list inside one of the items in another scrollable list. Think of it as a scrollable menu with one of the items including a scrollable ...
2
votes
1
answer
1k
views
Unity UI Toolkit | Select Background Image and Position of a VisualElement
I am searching now for almost an hour and I cannot figure out how correctly to select the background image and position of a visual element.
The query docu is really poor, there is literally nothing:
...
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 ...
2
votes
2
answers
2k
views
Understanding Unity-UI Layout Element - Mininum and Preferred Size
I have been working with Unity for some time, and I am trying to get a better understand of the UI system.
I am a mobile developer and am redesigning the UI but I am unable to achieve what I want.
My ...
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-...
1
vote
1
answer
186
views
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 ...
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.
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 ...
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
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?
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 ...
1
vote
2
answers
243
views
UI Scaling issues only with QHD and 4k UHD
I have a card game, where I'd like to be able to zoom in on a card if it's right clicked. I coded to make sure that if the zoomed card would go over a screen boundary, instead we would anchor it such ...
1
vote
1
answer
1k
views
Is it possible to keep a prefab of a UI element with UI Toolkit?
I'm digging into Unity's new UI Toolkit, and so far I like it a lot; but there are a few things bugging me about it.
I have a dynamic list in my UI which keeps track of way point paths, and it changes ...
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 ...
1
vote
2
answers
2k
views
How do I make several Image components transparent collectively as one sprite with a CanvasGroup?
I've run into a problem where using the CanvasGroup component to fade in/out several Image components under a hierarchy produces an unwanted result, where each individual sprite that overlaps with ...
1
vote
1
answer
3k
views
Unity UI Image not rendered?
In Unity I created a Panel with 3 children (An UI Image (LogoAch), and 2 TextMeshPro components (Name, Progress)).
It looks something like down below:
I saved this as a prefab and I try to instantiate ...
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,...
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 <...
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
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
1
answer
2k
views
Overuse of Canvas in Unity3D
I'm currently trying a new approach on a Card Game in Unity.
To capsuling my Card Prefab i have a root GameObject with the ...
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
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 ...
1
vote
1
answer
350
views
Canvas scaler does not work when the UI is Instantiated at runtime
My canvas scaler does not work when the UI is instantiated dynamically.
It does work well in iPhone 6.5 inch simulator:
The problem is when I use 5.5 inch or smaller simulator:
It does not follow ...
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 ...
1
vote
1
answer
835
views
OnPointerDown / OnPointerUp aren't working in world-space canvases
I'm working on a project where I have a main UI (Screen Space - Overlay canvas) and various game objects that have little popups above them (World Space canvas) that the player should be able to click ...
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 ...
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 ...
1
vote
0
answers
617
views
How to distinguish pointer up inside button vs drag-out
I am making a unity mobile game, I have a simple scene and a canvas with a few buttons and these buttons have scripts that detect if the button was pressed and released. Here is the code for doing ...
1
vote
0
answers
1k
views
How do I control drag speed of Unity's scroll view to make it slower than mouse drag?
I'm having an issue figuring out how to make the scroll move slower than very fast mouse drags/swipes.
I've tried changing the scroll sensitivity, inertia deceleration rate, and the EventSystem's drag ...