51
votes
Accepted
Blank 2.2 KB sized PNG costs 2.1 MB in Unity? What does this represent? What to do?
PNG compression works by predicting the next pixel from the pixels that came before.
If the image is completely blank, ie. every pixel is exactly the same as the pixel that came before, then that ...
13
votes
Accepted
Non-stretching health bar?
Since Canvas > LoadBar > Grass has an Image Component, all you need to do is set the Image Type property to "Filled". Then, the Inspector will ...
6
votes
Accepted
Screen split in different regions, each with a different scene
This is easy to achieve with viewports.
Inside the Inspector settings on the Camera component, you'll find a section labelled "Viewport Rect" that defines the rectangle on screen that this ...
5
votes
Accepted
What does this Yellow Outline represent in Unity Text Mesh Pro?
These are 'margins'. In the inspector, you can find them under the 'extra settings' section. This is what the documentation says about them:
The Margins values can be used to add some space between ...
5
votes
Accepted
Seeking a more elegant solution to set buttons so they can increase specific ability level and stats
they can't derive from a base class. Yes, they share many of the same properties but they also share many unique properites. –
xmaximix
1
Actually I think you can. This a pattern I use all the time ...
5
votes
Accepted
How do you repeat a tile texture horizontally/vertically in a UI Image?
Unity's UI Image components give you many options to manipulate Textures for UI purposes, as long as such Textures are Sprites. If you want to display other Texture Types, you might use the Raw Image ...
4
votes
Accepted
Sprite button not triggering "On Click()" event
It looks like you tried to attach a SpriteRenderer to your button to render its visual in your game scene rather than as part of the UI. This means that where the player sees the button, and where ...
4
votes
Accepted
Ball always showing in Unity
Thanks to @TomTsagk's comment on the question above, I've found it.
It was light probes that needed to be switched off, this is done in the Gizmo menu (in scene view):
3
votes
Accepted
How to call a function in response to a Button's OnSelect event?
Edit:
I added the OnSelect version.
Note that selecting and highlighting / hovering are two different things. When you hover over your button with mouse, OnPointerEnter will be triggered (if using ...
3
votes
How to trigger onclick for Unity Selectable by script?
As you know:
button.onClick.Invoke();
Acts like the user has clicked the button, invoking callbacks, but there's no visual effect on the button itself.
Do you also ...
3
votes
Accepted
C# syntax for "This button is interactable"?
Once you have reference to a Button, you can use Button.interactable to determine if the button is interactable. ...
3
votes
Do we have events for +/- buttons for a serialized list?
The answer is here - we can use OnValidate event - https://forum.unity.com/threads/do-we-have-events-for-buttons-for-serialized-list.1074768/
...
3
votes
Unity text is very blurry. How can I fix it?
Make certain your UI Text object is not inadvertently upscaled.
This can happen any number of ways. In my experience, the most common occurrence of this happening is due to generating UI objects from ...
3
votes
Accepted
Thin lines appear differently even though they are the same height
The issue, as other folks have pointed out, is that Unity is doing ~the best it can with the information it has. Because the reference size of your UI and the actual size of the screen are different,...
3
votes
Accepted
How to make a Unity slider sit over evenly spaced points?
This solution sets the dots the same way as the rectFill of the slider with the anchors and should be reactive to the size of the slider. This script is currently placed on the slider. It is ...
3
votes
Accepted
How to create instances of a Unity UI Toolkit template from code?
Solution
You can use a VisualTreeAsset. It's a serialized Visual Element Tree. Instantiate it and child the resulting root node to the UIdocument of your scene. Then you can query for elements and ...
3
votes
Accepted
In Unity editor, how to import package from github?
You haven't used the correct URL. As described in the repository's README, the correct URL is https://github.com/yasirkula/UnityNativeFilePicker.git
The documentation shows that the URL should be to ...
3
votes
Accepted
Rendering transparent UI in Linear Color Space
Alright, I sort of lost an entire afternoon to this, but I believe I've got it nailed down now.
The problem comes down to the fact that doing arithmetic on colors is a finicky thing, because the ...
2
votes
Working with Screen Space - Overlay canvases
It's like this because UI is usually laid out in pixel coordinates, rather than the game's world coordinate system.
I usually just double-click or hit F to center on what I need to look at, and use ...
2
votes
Accepted
How can I use Drag handlers (IBeginDragHandler, IEndDragHandler, IDragHandler) with a 2D sprite renderer instead of a UI Image?
Make sure that:
You have a Collider2D(BoxCollider2D etc.) added.
Physics2DRaycaster added ...
2
votes
Overuse of Canvas in Unity3D
Canvas is rendered in the "RenderOverlay" call in he render pipeline. If we are talking about screen overlay the canvas is simply rendered in 2D space over anything previously rendered, which always ...
2
votes
Accepted
How would I go about adding a tooltip to a Unity UI Image?
Here is an easy solution for how you get it styled right and working without any need to write extra code.
create the Image/ Tooltip you want as a child of your element that should have the tooltip.
...
2
votes
Accepted
What is the Unity 2019.3.5 version of `UnityEngine.UI.Text`?
It's still the same.
UnityEngine.UI didn't go away, it's just considered a package now, so its documentation has moved out of the core and into its own sub-page.
...
2
votes
What does this Yellow Outline represent in Unity Text Mesh Pro?
It's like a bounding box for the text.
If you narrow it the text will overflow,
And here in the settings you can change what happens (like text going into a new line or creating dots ex ...)
2
votes
Accepted
Unity: How to get the visible bounds of an object, i.e. as it is seen from the camera?
As DMGregory pointed out, the solution is quite simple: Just iterate through the vertices of a mesh, convert them from world to screen coordinates and store the min and max values of both x and y axis....
2
votes
Difference between methods - onClick.AddListener and On Click under UI button inspector?
In this particular context there is no good reason to use one over the other.
But in general, there are a couple things you might want to consider:
Assigning buttons in the inspector requires no ...
2
votes
Accepted
Strategy for temporarily blocking user input
As DMGregory noted, a Canvas Group is an easy way to control interactivity for a group of UI controls. Just assign the Canvas Group to the parent containing your UI controls, and update the ...
2
votes
Accepted
How to get a specific button component
Remember, someObject.GetComponent gets a component attached to someObject.
If you don't lead with a specific object to look in, ...
2
votes
How do I stop clicks on a button from also triggering my gameplay scripts?
Yeah, actually I've fixed the issue using this EventSystems.current.IsPointerOverGameObject(), here the full doc
https://docs.unity3d.com/2018.2/Documentation/...
2
votes
Accepted
Starting a Coroutine after another Coroutine ends
You want to start your fade back to light coroutine after your fade to black loop has finished all of its work, not once in every iteration of the loop (ie. every frame the black fade is supposed to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
unity-ui × 222unity × 210
c# × 76
gui × 22
input × 13
sprites × 12
2d × 9
events × 9
text × 9
ui-design × 7
text-mesh-pro × 5
animation × 4
rendering × 4
transformation × 4
scale × 4
ui-toolkit × 4
shaders × 3
camera × 3
virtual-reality × 3
card-game × 3
menu × 3
unity-webgl × 3
android × 2
3d × 2
mathematics × 2