#📲┃ui-ux
1 messages · Page 24 of 1
Is it possible to have GameObjects clickable (with the exact same behaviour as a TMP button) and would that even be the correct way to allow the user to interact with buttons that are shifting around (slowly and then increasingly faster) while allowing visual interaction with other game objects, for example a gameobject which emits light would light up these buttons, and if these buttons emit light, they would be able to light up game objects.
Can you try distilling this question down to a single thing? I'm not sure what you're asking to be honest.
Can you try distilling this question
When designing UI element in Unity, how do you create the object structure?
I.e. I am making a "card" which will contain icon + header + body + footer
Root object is set to 400x400(default center anchor etc) and all child objects will be set to stretch to parent.
My question is mostly about the root object, but if you have other tips then let me know(like child objects set to stretch, is it a good practice?)
What is the default size you go for?
Is it around the size you want your object to be in the game?
adaptive ui is hard to master but is worth it. It's easier to do than explain, so if youll ask, probably attach some screenshots
once you got full understanding with the recttransform, ui will be a LOOT easier
Anyway, for a more helpful answer regarding to making card UI:
These blue things are the anchors, anything inside the anchors will adapt to the parent's size. Just play with it and you can make an adaptive card
Yes I figured out this part as I was playing and its nice, do you always put anchors at the edge of that element?
By adaptive UI, do you mean something specific? Or just the idea that setting up UI with anchors will let it scale?
Any recommended guides/tutorials on the topic?
as i said, everything in UI entire depends on what you want to happen
I always used pivots to set my anchors, but it doesnt seem like a good idea if I want UI to scale, so setting up anchors manually did the trick for me,
There is 1 issue I am having tho, if I want to resize things or move them around, my anchors break and I have to set them up again.
Is there a way to avoid that?
i didnt have any learning materials when i studied UI, i just played with recttransform for weeks til i master them
I want a general tutorial on the topic of anchors/pivots/positioning I guess.
I can't really come here with every example asking the same question 😄
then just keep practicing, recttransform is the only hard thing here
since you already understand how anchor work, that's half of the lesson already
As an example, I wanted to add padding around the content of my card.
That meant I had to add "content" object and put all other objects inside.
That content object had to have anchors set to : 0.05, 0.95 in order to add padding around.
But doing that caused some issues and required me to fix all anchors again.
So what is the other half of the lesson?
Pivot?
alright, I will read up on them to see the difference
pivots generally just tells which part is nailed to the parent
oh by pivot u mean typing values in the rect transform
not choosing 1 of the options like stretch/top/left
those are anchor presets
makes sense
they arre helpful for beginners, but custom is more fun to learn in the long run
yeah that was my issue probably, I often use those(they are good to quickly setup an object, but after that you have to manually change anchors anyway
esp, since there's no anchor preset (afaik) that will make card parts adapt to it's parent (holder)
yes, it definitely makes more sense to use custom so the UI works for different resolutions.
I assumed at the start that using those presets would be enough, but I was wrong 😄
Exactly that was my issue
anyways, goodluck learning, it's worth it. I can literally make UI with minutes now that would have took me 30 before
Thanks!
hey yall i want to intansiate a message when i press enter which works fine but for some reason it is compressed to a corner
the message text input works fine it just the instanciated text looks ugly
i want it to be a line at the top of the chatholder
i have this scene, no matter what i do this gap will not be filled, it appeared out of nowhere, i disabled everything from the scene to see where it comes from, and it still appears ???
my camera is orthographic, the color of the camera is solid
it doesn't show up on the camera
@supple basalt leaderboard button which is one of the buttons messing up.
Inner is the background sprite behind the text "Leaderboard" and it has the text inside it
Image is the icon next to the button
Do you have any code that modifies the transforms of these objects?
uh not for the buttons
for the scores, sort of. it retrieves the records from database and fills out the existing fields
but it doesnt transform the ui elements.
would you mind making a prefab out of the UI and exporting it as a unitypackage? you can turn off "include dependencies" so that it doesn't export a huge pile of assets and scripts
i'd like to see how it's set up
yea one sec
see if it works 
ive exported the entire UI
It has a GameOver screen inside
and yea the issue only seems to happen when it enables this menu a second time (first time is fine)
I wonder if this is because of the Drop Shadow Filter components
I don't see anything happening as I activate and deactivate different game objects in the UI
gonna try disabling
they are third party assets so could be 
aha! you're right disabled them for leaderboard and mainmenu and now everything else has the issue 
I suppose the component is changing the size of the rect transform
It might behave better if you add layout groups.
e.g. like this
so that the UI auto layout can completely control the size and position of everything
as for your original question: you'd usually reach for LayoutRebuilder.ForceRebuildLayoutImmediate to immediately recalculate UI sizes
ill give this a try
on another note, is there a way to force it to "refresh" the ui? the same way resizing the window apparently fixes the issue?
but I'm not sure that'll help here, since this isn't a problem with a layout group
ah i think i did try that to no avail haa
thanks
the other approach would be to just deactivate and activate it
I wonder if this is something you can fix by changing your anchors and pivot points
assuming that the Drop Shadow component is changing the size of the rect transforms
also, you appear to have parented a gigantic Background image to the Run Button :p
actually -- it's possible that this is caused by the drop shadow running in a random order compared to the canvas scaler
the canvas scaler has an execution order of 0
so I wonder if this'll change if you put the UIFX stuff earlier or later
uh uifx doesnt have a priority field to set i think :o
hmm yea nothing about uifx in here 
you have to add a script asset to the list with the + button
ooh ok ill do that
hmm yea i added all uifx scripts before 0 and that didnt fix stuff either.
I'm gonna work with layout groups a little more and try other solutions you've recommended. If nothing else works, i contact the devs for support i guess since its a 3rd party asset
thank you so much for your time Fen 
I'd try sticking them after 0, too!
but yeah, I'd have to look at the asset to figure out what's going on there
wow i did not expect that to work 
was literally about to sign off for the day but that worked out
thanks again haha
sounds like they're mucking with their size in Update or something similar
If two script assets have the same priority, they run in an order that depends on when the individual instances were created
(and i'm not sure it's even that well-defined)
I don't like messing with execution order for my own scripts, but it's more of a necessity for third party stuff
Hey, I'm having difficulty with arranging objects in a layout - I'd like to get it so that when only one of these are shown in the game, they will start showing on the left and then expand on the right afterwards (in no particular order). I.E is SPD+ is applied first, it will be on the left, then when RNG+ is applied it will be "next to it"
As it is, they all just show/hide in the current locations
Use a HorizontalLayoutGroup
I am/was but they aren't moving position. I was watching some tutorials before I had to do something else but I'm assuming I may need to script it instead?
When setting the UI in Unity it's hard coded so I'm assuming Unity doesn't have that "freedom" and in the script, I'm assuming I need to get a list and then populate the groups I've set in the inspector?
You're assuming wrong, there must be something wrong with your setup
lmk if this should be posted into a different channel
been trying to work on card game to mess around, but the cards aren't scaling with the panels. Anyone got any tips as to how to get this to work ^^;
I've tried looking up solutions and haven't been able to find much that helped
Something on the 'Hand Panel' is controlling the size of the card
Hey! I was wondering what you all use for your UI? I want to be able to loop through my UI items infinitly and I would like to be able to add to the list of items during gameplay.
sounds like you want a recycler view
Correct
off the shelf solution?
https://github.com/framg/RecyclerView-for-Unity
Thank you!
Hello guys, i have the following hierarchy:
Canvas
- Parent_Mask
- - Child Image
I need to resize the mask and only the mask, but in order for the mask to work the Child Image need to be a child of the Parent Mask, is there a way to scale the mask without scaling the children? Or is there any other free mask solutions to address this problem?
Is there any way to mask a non child image or raw image?
Generally you shouldn't be scaling UI period
Resize it via the RectTransform settings
I can chage it to this, but ill still have the same problem
As it will affect the child g.o
A hacky fix could be aplying the same thing up and down, but still kinda tricky to do
When using TMP Input Field the text area starts moving horizontally when using large characters, when the left edge should remain fixed and the written text not move
I guess this behaviour would have to be a setting but I can't find anything associated with it
Doing inputField.textComponent.rectTransform.localPosition = Vector3.zero; every frame kind of prevents this behaviour but the text then flickers when the input field fights to move it
I'd think it was something to do with pivots but it's just totally ignoring them
Try extending the TMP Area (the yellow borders) to acommodate your expected max text so it would not move.
guys is there a way to make images with preserve aspect ratio turned on corners round?
Hi guys, is anyone familiar with an issue where on Legacy text and the console, a text displays correctly (A), but on TMP_Text it displays as A whitesquare? (A when copied into discord)
To be more specific it's trying to show A'\u25A1'
It's as if there's a char at the end that is normally not seen/ignored, but TextMeshPro's trying to display it anyway
I'd have nearly assumed that it's the EoL char tbh
Experiment with another font asset perhaps. To figure out which character exactly is missing.
In the [warning](#archived-code-general message) you've previously sent was written that LiberationSans SDF simply doesn't support that character
I don't think you can do anything about it is the character is not supported
Ah, dam, the other font is LegacyRuntime
There's also a method to check whether your font supports the character
if (t.font.HasCharacter('\u25A1'))
Tbh ig I never really considered font to be a possible issue here
Though that does mean that other fonts must be interpreting it as nothing, no widths or anything
Yeah, do you want to use this character with exactly this font anyway?
It's for key rebinding, the method I call returned me that string which TMP has issues with
You can make it so that not supported characters are either not displayed or displayed as another characters
Honestly, pretty sure it's meant to be ignored
The "normal" is just displayed as A, the other adds the hidden char
Is it an issue for you?
Is it supposed to not be written?
So yes, I'd assume that the other simply hides those
I'm asking whether you have an issue to be fixed
Do you want to use a specific font without an empty rectangle being written instead of the character, not supported by the font?
I'm not sure how it should be done so I can't directly answer on that
Am currently searching about hiding missing chars or stuff
Does any of you use pre-built solutions for your UI? I am having a super hard time getting my UI built the way I want. I also don't have a grid based UI so pretty much 70% of videos on YouTube is not helping , (Fair warning I am super green at UI)
Mistake: It's \u0001 missing, replaced by \u25A1, \u0001 means Start of Header, not that it makes any sense in the current context.
Bigger confusion: Most action names besides a few, like RMB, LMB, and the arrow keys, adds \u0001 to the end, SpaceBar is represented by \u0001, and the same goes for the Return key, like seriously tf is this? I'd expect such things to work out of the box but I find myself kneedeep in troubles with it
Even if I had a font that supports \u0001, first of all, it's literally StartOfHeader, secondly, it's oddly shared between multiple use cases
The Esc key returns \u001B, which is the escape key, so I'll give it that, it's somewhat countable as a bad font issue, even though I'd honestly expect them to just return "Esc" and not a single char
idk where else to post this, but I'm having trouble getting rid of these weird lines with tiled textures on certain resolutions
It's really weird and specific
heres the single player button idk
only happens when it's set to tiled
what kind of canvas is it
mhmh
I haven't touched this in 2 years so I'm not too knowlegable
this bug has just been here for years
Hi. I'm copy and pasting steam player names to see if my game will display all characters. There are some characters that won't display (shows the empty square symbol). I think Steam uses the Motiva font, but it's not free. What is a good fallback font to use when displaying steam player names? I'm currently using Google's Noto font.
I do use various Noto fonts like simplified Chinese, Korean, Japanese, etc. as fall back fonts so I suspect they are symbols not in any of these fonts.
I't a multiplayer game and I'm sending the text as bytes, using utf-8 encoding. Is this perhaps stripping out those characters?
Im having problems with text mesh pro's Dropdown component.
I am trying to add, sort, remove from a TMP dropdown, but every time I interact with the dropdown in any way, the selected value gets lost and it resets/defaults to the top most value.
I've tried everything in the documentation but for some reason I just cannot retain the dropdown's value
I need to be able to add and remove from it, without changing the selection. (of course, if your selection itself is the thing removed, its fine to then reset selection to the top most value)
Thats a weird behaviour. You can try changing the Overflow value on your TMPro to Masking and the Wrapping Mode to Normal. Also you can limit the zone of the gamObject if you change the Anchors from the top-left corner to some custom anchors dragging the arrows to the zone you want. Hopes you solved it yesterday or this info could be useful for you
Can you just save the selected index in a variable and set it back after you rearrange it?
With a +1 or -1 if a thing was added or removed before it
In case your Dropdown stores Strings before adding any change you can save the lastSelected, make the changes you want and after that just go throught all the values of your dropdown and select the one which value match with lastSelected. This is useful if you are adding in order instead of adding at the beggining or the end of your Dropdown
@indigo egret @full heath I just got back to it and with your help got two solutions
I believe what I'm seeing is the default Overflow behavior when Wrapping is disabled
Expanding the yellow area so overflowing can't happen even with wide characters does work, and using Overflow: Truncate simply cuts off the text rather than moving it
Hi everyone!
Before i start asking random question do you know a good guide to layouts?
I come from a web dev background and i'm trying to find something like flexbox from css.
So like creating a sidepanel covering full height and a 1/3 width of the screen with the other panel 2/3.
I managed to do this with horizontal layout and layout elements but then when i added a textmeshpro component to the panel with autosize=true it ruined the layout. why is that?
Could you, please, show how it looks like?
well, I think i've solved it D:
I have to put the textmeshpro inside the row
instead of putting it as a component inside the row element itself
but im still curious if there's some guidelines on how to use layout out there
got any suggestions?
Do you mean general guidelines on how to use Unity UI?
like best practices yeah
There should be a bunch of videos, but I was just creating UI when needed. So I have learned it simply thru practicing
Just make sure you know about the components like Layout Groups, which help you to structure the object correctly, and use anchors to not align the objects manually
Also make sure you simply have an object to structure all your texts. You usually don't need a separate empty object for every text you have.
Upper Panel
- Text 1 | aligned to the top
- Text 2 | aligned according to your stretching objective
- Text 3 | aligned to the bottom
thank you
actually, i tried having them all without a separate empty object but when i set the autosize to true they stretch out of the constraints of the horizontal parent layout
ruining the 1/3-2/3 screen layout
Why would autosizing a TMP_Text do that?
idk i just started trying game dev 😄
Oh, well, right, of course it does
I thought you've already applied that Upper Panel I have shown
So if you have them directly inside of your canvas, they're going to stay in it
You need a parent gameobject, which fits all those texts together
Is there a way to position something relative to something else?
In what context?
You can create a empty object (parent) and inside of it add the two objects that you want to be realative. For example if you have a label and an input area. So the child will onnly use the space of the parent and the parent can be moved
hello! can you tell why this happens?
The X value is decreasing on it's own, in editor view with and without entering play mode
Not without more context
There is a chance some component has an attribute that lets it run in edit mode (https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html). Alternatively, some editor scripts can modify it.
If you want to narrow the problem down, I would suggest creating a backup, then:
- turn off gizmos (to ensure that OnDrawGizmos code is not affecting it)
- close unnecessary windows (some custom editor windows can affect it)
- delete other objects in scene (some scripts can affect it)
- disable other components in this GameObject
I believe at some point the issue should be gone. Then it will be easier for you to figure out what exactly is causing the problem.
hey sorry to bother, has anyone reading this had this issue before?
What issue? The warnings?
Oh sorry meant to highlight this
Hi all, new to Unity and looking for some help.
I've currently got a button sprite that has a lot of transparency. The sprite image get's cut off when I use it on a button:
How it looks in the sprite editor:
I've turned off as much Alpha/Transparency related things I can find but still have no success. Any pointers to what it could be?
Try changing the compression from the Inspector and Sprite Mode to Single instead of Multiple if you want it to be just one sprite
There's this annoying artifact I'm getting in game-mode (in-editor), doesn't appear to occur on build, but it persists during editor play. Any idea if these can be removed? The scene which holds the canvas and the scene which holds the background and other elements are separate (loaded additively)
Should probably mention I'm on Unity 6.1f
Has anyone had the problem where they places UI somewhere on the screen, then you reopen the project and the UI is just gone, with the cordinates being NaN? How do I prevent this for happening next time?
I can't even change it back to 0
how do i make it so that the amount of space from the grid layout elements (dark green boxes) is the same from that of every side?
The grid, containing the elements, should have the same Layout Group's spacing as all of its RectTransform's offsets
I don't think you can fix it. Unity has its own issues and the most common for me is setting the Top and Bottom values to ~ -4..., but acting as if they were 0
never seen it. What's the hierarchy setup etc?
hi sorry i dont really understand what you mean by "all of its RecTransform's offsets" could you elaborate?
You first have to fully stretch your anchors, then assign all of its offsets to the same value, as shown in the images above.
what if dont want to assign my offets the same value though?
So you don't want to make the spaces between the elements and the sides be the same? Then don't do it
oh i meant that like the panel holding my grid elements is bit closer to the left side of the screen so i cant make the values the same otherwise the panel would shift to the center sorry for the confusion
You can't do it without the suitable size of the elements
Make sure the elements have the sizes which fit into that grid
Well, actually, you can simply use the Content Size Fitter to resize it automatically
In your case, both Horizontal and Vertical Fit should be set to Preferred Size. The Padding and Spacing should then be the same
Hope, this answers your question
oh yes, it works!! thank you so much for your help!
Yeah, I first thought they were distributed within their own empty GameObject. It's strange for me how I haven't instantly thought about Content Size Fitter and paddings
can someone help with vr UI ? i'm new to unity i just made a ui with health system, the canvas is set on overlay but it doesn't show when i test the game
anyone know how to do ?
All VR UI must be world space canvases
VR only supports world space canvas
ok i used world space and fixed it on the camera but i need to fix it on the left corner and rn when i look around the healthbar go from left to right idk why
this is the script i used to make it appear in front of the main camera
how can i fix it in the left corner of my screen ?
Very very stupid question, but does someone know why I cant click on the elements of my canvas?
I can move the elements changing the transform values, but I dont know what option I touched that I cant move them using the mouse in the editor
Did you disable their scene pickability in the hierarchy?
Where is that option?
letme send a quick video
Im cliking on the elements, but it just dont work
as seen in the video, If I select an object in the hierarchy I can move it freely
but I cant select them by cliking
Oh its fixed
I just need to close the scene window and open it again
seems like a bug
I've got a Vertical Layout Group controlling a text mesh text so it dynamically expands doing down based on the amount of lines in it
but I wanted the childed image to fill the relevant text box area dynamically
I see the vertical layout group isn't actually updating the text transform values which is why im assuming its not working as i expected, any suggestions on setting this up?
A layout group is for laying out multiple UI elements
a single text element isn't going to really benefit much from it
fair, i'm open ears for alternate suggestions on doing what im trying to do with it
like per line?
yes
this is for a dynamic console
i basically swap between different code based string holders (im pressing tab in the gif)
w/ the vertical layout group the gif is showing what i want to happen but i also want the effect of a image that fills the dynamic space the text is taking
oh it maybe looks like the layout group has the size i need internally
@mortal robin i think its slightly hardcoded for the anchor im using but got what i wanted using this 😄
public void Update()
{
float newX = verticalLayoutGroup.preferredWidth;
float newY = verticalLayoutGroup.preferredHeight;
image.rectTransform.sizeDelta = new Vector2(newX, newY);
image.rectTransform.anchoredPosition = new Vector2(newX / 2, -(newY / 2));
}
Hello, im trying to set up two groups of buttons. I want two groups of buttons because I want to be able to have one button in each group in the "selected" state is there an easy way to do this using a toggle group or something or do i need to add the functionality in code?
I'm sorry, I don't seem to fully understand your issue. What does 2 groups of buttons mean?
public void Update()
{
Vector2 newSize = new(verticalLayoutGroup.preferredWidth,
verticalLayoutGroup.preferredHeight);
RectTransform rect = image.rectTransform;
rect.sizeDelta = newSize;
rect.anchoredPosition = new(newSize.x / 2, newSize.y / -2):
}
I would create a Vector2 and not access the RectTransform twice
Also, does it do what you want? This seems a bit strange for me
@tawdry ferry okay lets say i have 10 buttons. currently if i click on any of those 10 buttons it goes into the "selected" state and changes its color accordingly, when i then click on any other button the currently selected button goes back to normal and the new button becomes the selected button
instead i want it to function where my 10 buttons are in two groups or sets of 5 buttons. where each group of 5 buttons can have up to 1 button selected the (way the original 10 buttons worked) so at any given time one button from each of the two groups can be in the "selected" state
i can for sure do this with code without much issue im just wondering if there is an easier/faster way using a toggle group or something like that
I don't think there's a built-in solution. I would create a simple script, which stores a List of Buttons and makes you able to select just a single one
gottchya 👍
I have done it in the previous year, so I may find the code of the script I've used if you need it?
ill dm you if i get stuck but i should be able to figure it out. thanks though!
Please, simply reply to this message when you're stuck
Good luck!
how can i fix a frame in the top left corner of the screen in a vr game ? i have my frame in the worldspace but i only can put it centered or it moves
it needs to be a child of the camera, so it moves with the head
i made it so the frame has the position of the head where the player look
UI 2-sided card with thickness, is this doable with a Custom Graphic?
At least even with shaderwork
Someone knows why when i try to update a toggle depending on if the screen is fullscreen or not
i get a bug in which i cant change it?
probably because your updating that per frame
Do you know how can i update the toggle depending on wether the screen is fullscreen or not when i come back?
My problem is that when i come back from another scene the toggle is always on even if the screen is not fullsize
that sounds like you need a saving and loading system
if i put toggle.isOn = true;
that triggers the onvaluechanged method in the inspector?
i think yeah
so how do i change that value without triggering? Because the toggle always reset as I restart the game or change scenes and come back
you need to save and load your settings
theres no possibility to do it with playerprefs?
you can use playerprefs tough i personally wouldnt reccomend it
but how can i disable teh OnValueChangedListener so i can change the isOn without triggering the method?
Or how do u do it with playerprefss
you dont need to disable it, once the game starts or you switch scenes it will load your settings by setting the values of your UI elements to the saved values, that will call the functions and apply the actual setting
but i dont want to apply again the value
like if i swith scenes i dont want to go back and apply again the windowed mode
i wont, cuz is saved
so right now if i have in the start this:
if (PlayerPrefs.GetInt("Fullscreen") == 0)
{
toggle.isOn = false;
}
if (PlayerPrefs.GetInt("Fullscreen") == 1)
{
toggle.isOn = true;
}
what should I do so the toggle image is in the correct form
first of all you can make that shorter by doing this
toggle.IsOn = Convert.ToBoolean(PlayerPrefs.GetInt("Fullscreen"));
2nd put it in awake since is called before start
actually put it in a function that gets called in awake
well that gets the saved value, you also need to set it
in the function you call when toggling, save the value to the playerprefs
thats also done
and still im getting the bug
whats the bug again?
let me show you a video so its easier
wait a min, this is a build
yea ofc, i cannot change fullscreen in the editor
you did build again after the changes i told you right?
correct
also make sure you dont have any misspelling in the playerprefs key
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is all i use
and the method is being called through here
you dont call PlayerPrefs.Save()
i have a lot of player prefs and i never used Save
and they work perfecly
Oh btw, if i dont change res, only the fullscreen, when going back to the menu fullscreen gets enabled automatically
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is the complete script
what is this supposed to do?
if the playerpref is not 1 or 0 (1 Should be for fullscreen and 0 for windowed) then it sets it to fullscreen
yeah i got that but why is it there?
where should it be
okay nvm i fixed it already
oh, k
but i have another problem
what is it?
that sounds like something overriding the current resolution, im sorry but i cannot go trough your entire script and fix the issue for you put some breakpoints in your code and see when that happens, to do that in build you have to make a develpoment build and link the visual studio solution to it
you can also do it in editor and watch for the dropdown value changing
{
// Comprobar si los valores de la resolución están almacenados en PlayerPrefs
if (PlayerPrefs.HasKey("ResolutionWidth") && PlayerPrefs.HasKey("ResolutionHeight") && PlayerPrefs.HasKey("RefreshRate"))
{
int width = PlayerPrefs.GetInt("ResolutionWidth");
int height = PlayerPrefs.GetInt("ResolutionHeight");
int refreshRate = PlayerPrefs.GetInt("RefreshRate");
// Establecer la resolución guardada
Screen.SetResolution(width, height, Screen.fullScreenMode);
Application.targetFrameRate = refreshRate;
}
}```
why my fps doesnt cap at my HZ chosen in the dropdown for the resolutions?
refresh rate and framerate are different things first of all
to cap the fps to the HZ you have to enable vsync
no clue where to put this- idk if it's coding issue or unity
no clue how to describe the issue so I recorded it-
here are the codes related to this if that helps
selecting which cards get hidden
public GameObject cardInDeck2;
public GameObject cardInDeck3;
public GameObject cardInDeck4;
void Update()
{
ThisCard card1 = cardInDeck1.GetComponent<ThisCard>();
ThisCard card2 = cardInDeck2.GetComponent<ThisCard>();
ThisCard card3 = cardInDeck3.GetComponent<ThisCard>();
ThisCard card4 = cardInDeck4.GetComponent<ThisCard>();
card1.cardBack = true;
card2.cardBack = true;
card3.cardBack = true;
card4.cardBack = true;
}```
### ThisCard.cs (card back booleans)
```public bool cardBack;
public static bool staticCardBack;
void Update()
{
...
...
staticCardBack = cardBack;
}```
### covering the cards
```public GameObject cardBack;
void Update()
{
if (ThisCard.staticCardBack == true)
{
cardBack.SetActive(true);
}
else
{
cardBack.SetActive(false);
}
}```
static variable gore
also - you should use a list or array for your cards, not numbered variables.
I'm kind of out of practice when it comes to coding-
can you point me in the right direction for how-? ^^;
Hey everyone,
I'm facing an issue where my UI isn't displaying in full screen on my Android device. In the Unity Editor, when I set the same aspect ratio, everything looks fine. However, on the Android device, the UI is cropped. Additionally, the black screen appears because I set the skybox to a solid color; previously, the skybox was visible. It doesn't seem to be a device-specific problem, as the splash screen displays correctly.
Can someone point me in the right direction to fix my blurry text?
It's good when the scale is at 1, but then it get blurry for some scalings:
When you say "scale" what are you referring to exactly?
That can mean several things
the scale at the top
Only 1x is relevant
but users can resize the window not?
Tehy can resize the window, but that's not the same as the scale slider in the game view
ah alright thx 🙂
That's like changing the resolution here
hey guys?
anyone here can help me with an UI problem?
if u use Canvas with RawImages and Buttons...then the images are on his place...
but if i restart Unity, (sometimes its same if i just stop and restart the game) then the UI Elements are not on his place...sometimes they are smaller, or bigger but every time have another position...
how i can fix that??
Do you have selected Free Aspect or any fixed aspect like 16:9?
Maybe if you have set FreeAspect and change the size of the window that shows the scene the UI Components moves. You can have the elements fixed on a specific position but you have to set propperly the anchors. But first of all lets see if you have FreeAspect or any other aspect ratio
Hello I'm trying to create a menu scrolling system where there's a base sidescrolling menu with horizontal scroll
And in the child of this horizontal scroll there are few vertical scrolls.
If my finger is on vertical scroll but I'm scrolling horizontally, it should scroll the base horizontal scroll but nothing ends up happening as base scroll is blocked by vertical scrolls.
In essence I want to achieve something like this
Any suggestions on how to go around it?
It seems you need some kind of nested scrolling, maybe this forum can help you : https://forum.unity.com/threads/nested-scrollrect.268551/
I'm hoping to put together a Netflix-like interface for users to select the scenes in my project.
I need to be able to scroll up and down overall, but...
That seems to be the same issue I am facing, thanks! I'll try to see if it works for me
It worked, thanks a bunch! Really struggled to find the solution online due to limited vocab 🥲
use a list instead of multiple variables and then iterate the list.
also dont call GetComponent in Update. use the Start method for them and cache them into variables (or just assign the components through the inspector)
@low sluice so i added world space and nothing happened when i tried to click the text or a gameobject
Did you put the world space canvas at the correct location instead of your render texture?
i added under the map
the second image is where the camera is
(sorry i never used world space)
also i like more using render texture for the effects and stuff
You don't need the render texture at all for this. Just put the world space canvas at the correct location
but then how can i add the post processing stuff for the effects
If you insist on using the render texture then I already told you how you'll need to handle that 🤷♂️
i have screen space - camera
I mean here, on your Game window
there are standard settings from unity, i never changed that
Have you change that? Consider that if you change the aspect the position of your ui items change depending how you put your anchors
It's on Free Aspect by default - you do not want it on this when working with UI
As this is a visual issue, SHOW the issue rather than describing it. It will be easier/ quicker for someone to spot the problem
Has anyone had any luck generating TMP Sprite Assets at runtime? I need to be able to embed sprites into text, but I won't actually have access to those sprites prior to runtime since they're loaded from user-provided files in streamingassets.
How do I change the material of a TMP object? I have another material without a text outline, but it's not letting me swap out the material
in this screenshot, I'm trying to assign the circled material, but dragging it into the inspector doesn't work. Also, there's no option to remove the current material
Hello ! I would like to display a vfx above a button(the button will be invisible) but I struggle a lot.
technically this is what I got
But when I make this button spawn (it a simple dialog box) everything spawn except the vfx or lets say it spawn because I found it in the hierarchy but the camera don't render it.
VFX live in world space.
UI lives in canvas space
Two completely different coordinate systems
The easiest way here is to make your UI use screen space - camera
Ok thanks for that info 🙂
why is my scrollbar fully white and why doesnt it scroll properly?
What's wrong with the scrolling exactly?
shouldn't the content size fitter have its vertical field to preferred?
im kinda new with ui, i am using a horizontal layout group to center both (text + image(currency)
i want the image to not get stretched when the text increases in length dynamically
how could i achieve this
case ex: none
case on which the img is stretched
I have issues with scrollview cus scrolling doesn't work when your mouse is over ui with RayCastTarget on
So I ended up making some sort of wrapper...
But then I've got serious trouble with controlling the scrollview via the other script
Is there a solve for the first problem without using another script? If not... How was I actually meant to scroll a scrollview by script?
This is the issue I'm currently having
Unless you are blocking it with something scrolling while hovering over scrollview should work just fine. If you absolutely have to have something overlayed, you can pass raycast with custom event under it.
For animated scrolling on scrollview, I've manipulated scroll progress variable, it's 0-1f I think. So calculating height of the content area object vs, for example height of an item, would allow you to calculate the percentage for the scroll step you want.
The original issue where I have trouble with ui element blocking my scroll was in the backpack
Where you can't scroll while hovering over inventory slots
Items should be part of the content container
Part of the content container? Wdym?
It's just a bunch of inventory slot arranged by a grid layout group within the content tab
If you have everything under https://docs.unity3d.com/ScriptReference/UIElements.ScrollView-contentContainer.html scrolling should work
Each inventory slot consists of
- Slot (Background img)
- Content (Item img&has event triggers)
- Text (Item amount display)
If you are blocking events preventing them from reaching scroll view, then it won't work
Nothing has raycast target except Content
Use event manager debug screen in the inspector and see what's blocking
when event manager selected, make sure it's extended on the bottom in the inspector
It's active only at runtime
I'm not quite sure what the event manager debug screen is... No results show up
After a simple double check, it's 100% confirmed that it's the Content that's blocking the scroll
However I'm not using the scroll event
At runtime select event manager to show in the inspector and look at the bottom of it when you move the mouse over UI
Easiest way to test is to create default scroll view and examine what elements exposed while scrolling to work properly
Welllll... Definitely the event trigger
Hmm... Maybe the scrollview also uses OnPointerEnter & OnPointerExit to know if you can interact...?
Nope, the mere presence of an event trigger blocks it
I'm guessing it supposed to take over all the events, so you need to forward them if you want them to work
Never used that component. If you want castom event redirection it's simple enough to add Selectable script and capture and redirect only events you want
All I need are these two functions to be triggered ngl
How would you do it?
The Selectable script looks like... Just a base ui component?
Your component needs to implement Selectable interfaces you want
public class ScreenEventsManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IScrollHandler, IPointerDownHandler, IPointerUpHandler
Ahhh I see
So Unity probably searches up the hirarchy for components that implement those
And also if the component is blocking one, you can reference blocked component and redirect event, receiving it like that
public void OnDrag(PointerEventData eventData) => OnDragProxy(eventData);
And Event trigger implements them all?
Never used event trigger. I use events through scripting
Yeah I mean, probably why it blocked it while empty is cus while events are optional, the implementations are always there
it might implement everything, thus blocking everything, I can only speculate
That's what I mean lol
Hell no
I think that it's OnBeginDrag and OnEndDrag
Ig I'll just implement them too (While I don't need them)
You need corner case handling. If you start drag over an item to block drag for the scroll view
Uhm... Exception?
Pffft okay
Pretty sure I just need to implement the few stuff I need to intercept
I mean, inventory slots are meant to be dragged after all
Even if I don't specifically utilize them
So the item would need a Selectable drag interface, which will block scroll event for the scroll view
Hmmm... I don't think that it'd be necessary?
Cus honestly no one would actually care if they can use the scrollwheel while dragging
That's not scroll view being scrolled, that looks like drag event working for the item you are dragging and for the scroll view
Yep
Anyway, you have all the information you need to handle it now
That's why ig that I'd just need to implement PointerDown and PointerUp OnBeginDrag, OnDrag and OnEndDrag
I'm trying out Unity 6 preview. I am trying to reference a TMP_Text. I have asmdefs setup, and since there was no Unity.TextMeshPro assembly, I found out that it was merged to ugui 2.0.0. I verified that I have that package installed. But I still can't access TMP_Text. Is it under a different class name or what am I missing here?
I temporarily removed the asmdef file and now it can see TMP_Text using TMPro. Is this broken in Unity 6?
Hello please help me how i can fix this
When i add UI prefab in small resolution it become big and small on big resolution
Use the settings on the canvas scaler
Im trying to make a button that respawns the player when he dies, it works but the text "Restart" covers the button. How can i make the text like transparent?
change the alpha of its color
trying to create a chess move history panel, I wrote the script, but Im not sure the best way to show the info during game play, I thinking scrollview? but anybody have suggestions?
Vertical layout group in a scroll view sounds pretty typical
Having an issue where a small gap appears at the top showing the game when I'm trying to hide it (a pause menu is supposed to obscure it). This only occurs when I set my game view to 16:9 aspect ratio.
Show the inspector for your canvas game object
Show the inspector for the background image
Hey im having real issues with the layout groups, and cant find a good tutorial about it, do you have any suggestions?
my problem is that the tutorials show only the basic uses but it you try to do something tiny different all hell break loose
SOS
What are you trying to do and what is going wrong
so many things 🥲 . should i make a list?
Just focus on one thing at a time
the most annoying is when i use vertival/horizontal layout some elements cant be stretch , so i need to resort to silly hacks
I try to anchor it and it jump back... sometimes it workd but then give length -XXX and i need to manually remive the - and it works-ish
sometimes it will start on the wrong place. and mess everything up
im sure im just missing something out, it cant possibly be that bad
this is the first issue
What do you mean by some elements can't be stretched?
for example
wtf is going on here? i enchored it to stretch and it got backwords, but all the elements inside are on place...
You have width set to -550
here, the text starts before
this is what im saying... the layout did it, not me
The layout doesn't change the size of itself
i can remove it and it will kinda work, but i refuse to keep doing hacks, im sure im doing something else wrong
ok ill record the screen for you
@mortal robin sorry me recording software didn’t work
nothing working like it should with the elements inside the layout, you can also see that the texts are starting before the edge of the container...
so many things are fucked there, i assume i did something wrong along the way but i have no idea what
but that object have layout component too, maybe they interfere?
does the parent game object have a layout group on it
yes
parent
problematic child
if i give the child anchor stretch it gets -width, and if i remove the - it kinda work but stuck to the left even thought the parent is not
any clue what's happening? @low pike
ok, for a start, never change the scale on the rect transform*. You're going to have bad things happen because your scale is not uniform. Keep it at 1,1,1.
Only use width/ height to change the size.
- unless animating
i didnt change it manually ): i only saw it now
what's the hierarchy - do any of the parents of the background have their anchors set to not be flush with the top edge?
nothing else changes the scale
gtg now, can we get back to it in 3h?
just ask someone in the channel - if I'm here and I see it great
LevelLoader (an empty GameObject meant to keep things organized, with a transform set to 0) -> CrossFade (the canvas) -> Image
do any of the parents of the background have their anchors set to not be flush with the top edge?
How do I check if it is?
look at these
The image object's transform looks similar to the one above; pretty default with max stretch.
This is the Crossfade object's rect transform 👇
There does seem to be a solution in Canvas
If I set the Render Mode to Screen space - Camera rather than the default Screen space - Overlay
Messing around with that rn
Yep works 
thanks for the help
Hey, I have a button and a Scrollbar, when I press the button it turns to its "selected" color. But when I press the scrollbar, the button is no longer "selected" and I do want it to stay in its "selected" color. How can I achieve this?
Hey there! Can anyone tell me how to enable the Achor Presets? As you can see their disabled in my Inspector.
does this object have a parent?
Yes it has. Its a blank GameObject.
Saw that one in a tutorial where the user was doing the same and for him it worked out using this method.
and Healthbar has a REctTransform too?
Game UI (Canvas) and both Healthbar (Image) and Fill (Image) do have a RectTransform but without Achor Presets.
any else idea?
If you make a fresh canvas does it work?
It actually does.
So maybe just recreate it
Other suggestions would be:
- Make sure all your packages are up to date
- Make sure you don't have any third party plugins interfering
- Upgrade to a newer version of Unity
Are there some features in the Canvas Inspector that do effect that cause ive needed to change some. But from what ive tested there wasnt anything changing that.
Can anyone tell me what caused that? There should be my HealthBar but instead of that there are just this
red crosses. The problem occurred after restarting the program.
I absolutly have no clue how to solve the problem or what might cause that.
it's caused when the width/ height have negative values
I found out the same so far but im wondering how that happend and also, I cant undo some of the visual problems.
As soon as ive recreated the UI and started the game twice the same problem occured. So if anyone has a clue what could cause that, let me know.
A layout group doesn't seem to update itself when its parent is disabled, is there anyway to force update is? I've tried ForceRebuildLayoutImmediate and MarkLayoutForRebuild from LayoutRebuilder and also ForceUpdateCanvases, no luck there. What is happening is that I'm loading what is inside the layout group at runtime, but I need the correct positions of them before they're enabled.
complete UI noob, why are they different sizes if they have equal scale? canvas is set to scale with screen size
Never change the scale, keep that at 1,1,1.. use height/ width to change the size
What you want here though, is a parent object with a vertical layout group, and these two as children
wdym verticle layout group?
You need to anchor your UI elements properly
Btw, why are you playing on 0.29x scale?I'm new on game developing but as far as I know it should be always 1x since is the scale the build will be. Someone please correct me if I'm wrong
But yeah, it's an anchor problem. It was hard for me to understand the anchors at the beggining but once you know how they work it's very easy to use them.
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html
I have a problem - i'm using a combo of sprites and UI elelemts to build the menu and will be using the same for the game too (2d). I'm using UI becouse of anchors and sprites becouse they are easier to use. They dont combine well together tho. The reason why i don't use imges for the decoration is becouse they can't be rotated on a shader level (I'm using shaders for the dynamic moving patterns on the rectangles), as seen in image 2. Idk how to aproach this anymore.
Look this: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/HOWTO-UIWorldSpace.html
If this is what you want there are some tutorial on youtube that explains this better
I use this for a simple example where I need a particle system on my UI
Hello! I'm pretty new to UI creation, so I've been watching some tutorials and I've seen that some people have a 'ball' or 'circle' source image. At first I assumed this was build into unity, however I do not have what they have. (Multiple tutorials). My first thought was to just import an image of a circle, although I dont know if this would work since I'm trying to make a circle progress bar, and I need to use the fill amount feature. Does anyone know what I can do.
Also I apologize if the answer's very simple 😅
There's a default circle sprite in the 2D sprite package
But it's really just a white circle image afaik
So would I download this from the package manager?
Assuming it's not already installed in your project
I dont believe it is...
also my apologies for the late responses. Im packing for a trip
randomly had a bunch of my RectTransforms get values replaced with NaN
any idea why that could happen?
I'm trying to create an inventory and hotbar with slots...
It is essentially just a background image with square images in a layout group.
I have set the spacing to 6, but for some reason it is impossible to actually force it to be 6. Different spaces have 1 pixel difference for some reason. Same issue with different layout components. Any clue how I could fix this small, but annoying issue?
Easy to see that the spaces are changing when you move it a bit:
https://streamable.com/bck1oz
where is this recording from? Scene view?
yes, scene view
but game view has issues as well
What resolution is game view set to
1920x1080
Basically I'm wondering if it's some interaction with the pixel perfect canvas and your canvas scaler and the resolution
I also removed the pixel perfect options from stuff on the picture, but still have it on camera itself
fiddled around quite a bit with everything, nothing mattered really
same with built game in full screen if that could matter in any way
hey hey, apologies for bugging you again. After installing the 2D sprite package I'm still unable to use any of the placeholder sprites. Could I still control the values used to cut it in a circle without the placeholder sprites? (<- if I were to use my own sprite instead)
Try changing on the Grid Layout Group the Child Alignment to Upper Center or Middle Center
didn't see any changes :/
But I think is due to your Fixed Row Count, since the Hotbar slots game object is not big enough to store all the slots with the space
I will also suggest to add the component Grid Layout Group to your hotbar panel game object
the video was cropped, I have enough room on all sides
hm, will see how that last suggestion goes
This way and with the child alignment on center it should be better
You have space on your hotbar panel game object but it looks that your hotbar slots (the one you are resizing) is constrainig the elements inside
the issue was same when it was way larger as well
That's weird then
yeah it is pretty strange, I've been on it for hours in total 😄
moving the group up in hierarchy also doesn't seem to do the trick, but thanks for the suggestions
Also you have Pixel Perfect enabled on your Hotbar Canvas, I just see that
yeah already turned it off some time ago, changes nothing for given issue
but i do have it on my main camera
then again disabling that only changes my world scene, not that UI
I don't know anything more to suggest, sorry I can't help you more.
I don't know how is your padding, but with chil alignment on center you can put 0 on Left and Right, maybe the padding is high
I'll see what happens if I disable the padding and just make my slots smaller
atm even with padding 1, some slots have none
Also, why do you have another Grid Layout group on your slot elements? Maybe this is conflicting with the layout on the parent
it is easy way to center an item that is being dropped there
for the science, I'll see if removing those helps, after I'm done with the other test
really appreciate it
I have to play around with the sizes a bit to be sure... but I think removing the padding and only using smaller slots did the trick
thanks again ❤️
one can go mad when debugging these things 😄
@kind storm you want to adjust the Left and Right bounds of the Handle Slide Area
You will also need to adjust the Left and Right values on the Fill Area
These values represent how many pixels of space you have on the left and right sides
0 should be a good starting point though
because that means the fill and slide areas are exactly as wide as their parent
and both are children of the slider object
Ohhh thanksss! I'll take a look at it tomorrow :>
figuring out how the Slider works was a big step in understanding UGUI as a whole, haha
@supple basalt I made two versions of the background one using game objects and one using the canvas I went with game objects because I couldnt figure out how to put other game objects infront of the ui background I had made
(to clarify, both of these are using game objects)
it's just a matter of using a sprite renderer vs. a Graphic (which gets drawn by the canvas)
So one option would be to just use a "Screen Space - Camera" canvas
You'd create a second canvas and switch it to that mode
A "Screen Space - Camera" canvas is positioned in the world (at 100 meters from the camera, by default)
So it'll wind up behind everything by default. Normally, that's a nuisance, but that sounds useful here.
one moment
as I try to find what youre talking about
I appreciate the help too
thank you
Make a new Canvas and have a look in its inspector
found that
The SpriteRenderer one is not working because SpriteRenderer has no understanding of RectTransforms -- it just draws a sprite when the camera looks at it.
So it'll get positioned, but it won't draw in the area you want it to
So I swapped out the background with ui componets using the new canvas like you said but now its not displaying the background on the game view
Does your other canvas have a gray background on it?
The original canvas is still drawing in "Screen Space - Overlay" mode, so it's being drawn directly on top of everything else
no but the camera does
show me the inspector for the background image's object
done
then go to the parent object (it's called "scene" in your screenshot and set it to stretch in both directions and have left/right/up/bottom values of 0 as well
would it be better to just delete that?
if you don't need it, then yeah
also, why is there a "foreground" object?
the grass was the fore ground
both are 'background items' I just had them split for later on stuff so that I could change out the scenes
I see both on the camera now
So now when I increase the game view the canvas flips the images themselves
show me what that looks like
can I post clips in here?
you can post images and videos
no thats just an empty that houses game objects
there's a RectTransform on "Gamebounds"
which is very odd for something that isn't UI
thats an empty trigger box for one of the games mechanics
okay, but that doesn't answer the question
or are you using RectTransformUtility methods to check if something is inside that region?
yes
i see
game items isnt a canvas
inspect your scene canvas object
and how about when you've changed the game view size and your images have gotten screwed up?
yeah when I change the game size it appears to flip them if you give me one sec I can make a short clip showing you what I mean
the red "X" indicates that the images now have a negative height or width
inspect the "foreground" object again
Put the scale back to [1,1,1] and set the left/top/right/bottom values to 0
Also set the Z position to 0
That could be relevant
it very much was
especially with the screen space - camera rendering
since you can actually get perspective effects there
np (:
Children render on top of parents, and later siblings render on top of earlier sibilngs
Maybe another object is drawing on top?
How do I make sure all the "Answers" are lined up perfectly in a nice grid?
Look at the Layout groups (Horizontal/ Vertical/ Grid)
You can use a combination of hor/ vert , or just a Grid layout - I never use the grid layout because the cell size is fixed, it doesn't resize when the resolution changes
Indeed. The main thing to know when using layout groups is that you need groups all the way down to individual layout elements or graphics
- Rows <-- VerticalLayoutGroup
- Row <-- HorizontalLayoutGroup
- Button <-- VerticalLayoutGroup
- Text <-- Nothing
- Button <-- VerticalLayoutGroup
- Row <-- HorizontalLayoutGroup
e.g.
even if you only have one child, you still want to have a layout group
I need to write some kind of blog post about this. The default settings are a bit bad (you want to turn off Force Expand and turn on Control Child Size)
Hi there @supple basalt the problem is that i'm doing it with with UI toolkits and I can't find that handel slide area property
also i've made the slider point bigger by changing that... and i don't think is the right way to do that...
oh, if this is UI Toolkit, then you need to look in #🧰┃ui-toolkit
I'm not familiar with UITK
When creating a ui element that uses the material of a shader, the shader is black in game but the correct color in the editor and graph
WHen you say "in game" you mean in a build? On what platform?
When I say in game, I mean either a build or just running the game in general (after I press the play button from the editor)
What about just in the game view (not scene view), before you hit play?
Same issue
ok so your shader or material just isn't appropriate for UI I guess
what shader are you using?
Strange. I’m using an unlit
It needs to be specifically made for UI typically
Hm. I mean the shapes appearing and everything, just not the color. I even got desperate enough to make a second after following a tutorial (still same issue)
wdym by "shapes"
Oh okay. Forgot to explain this. I’m just making some simple shapes using some nodes and then cut out the black space. For instance, I made a circle
Although I’m trying something now which might fix it
Did you actually make it a UI graph?
For example in URP you need to select Canvas:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@17.0/manual/canvas-shader.html
I fixed it. I just had to change the screenspace-overlay to screenspace-camera.
Stupid me. Thanks for the help though!!
Has anyone figured out how to reference TMPro from within a asmdef script? Currently using com.unity.ugui@2.0.0. I am able to reference TMPro successfully without asmdef, but under asmdef it doesn't exist.
You have to reference the package in your assembly definition
I.e.
I know that, but that is the issue though. It doesn't show up for me.
try restarting Unity - or edit the asmdef manually:
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],```
Restarting didn't help either. But I will try manually. Thanks for the GUID.
Thanks. Adding manually did the trick.
why are the buttons hitboxes are weird
or maybe its something different
i dont know
Take an actual look at their RectTransforms in scene view
Use the rect tool
There ya go
does anyone know how to grab the gameobjects and stuff that a dropdown creates
like i wanna grab each value's gameobject (which in the template is called 'item') at runtime to change certain child objects in it.
How do i do that via script, as for example when adding a script to the Content that triggers something in the main script that executes what i said above, it just looks at the template and not the shit it instantiated?
I'm new to Unity UI and struggling mightily trying to get a grid that will dynamically re-size depending on screen size . The grid is made up of individual gameobjects for each cell, each with a RectTransform. I'm trying to constrain the grid inside the gray rectangle (which is also the parent of all the cell objects). But as you can see in the other image, if I go full screen, the cells don't re-size. (I know they're not constrained in the image with the larger cells, but I previously accomplished that, but now it's just a mess from so much trial and error)
I've been working at this for like 2 days and can't figure it out, feeling pretty dumb. The reason I have gameobjects for each cell is because I want each to be clickable and contain coordinate info. My intention is to allow dragging of bocks that "slot" into the grid cells.
Super grateful for any tips!
Are you using the Grid Layout Group component so that they automatically grid themselves?
I did try using that, yeah. But it doesn't seem to provide the dynamic/responsive sizing I need. For example, small game window vs full screen game window
I also have a Content Size Fitter, but perhaps not using it correctly
Seems like it might not be possible without some extending, unless something has changed since this thread:
Grid group is a bit lacking. See Fen's post above #📲┃ui-ux message
how can i make the objects in this group move upwards instead of downwards? the select box is the box for the notificaitongroup
child alignment bottom left
that doesnt work
What's your end goal here? WHat do you want to accomplish?
Each dropdown item has 5 images contained in it. These are for displaying different colors within esch color scheme (so each scheme has 5 colors, which are shown on those 5 images)
Each dropdown item is a color scheme, and i want to be able to update each image of each dropdown item
Basically you can override TMP_Dropdown, and override this function:
https://docs.unity3d.com/Packages/com.unity.ugui@3.0/api/TMPro.TMP_Dropdown.html#TMPro_TMP_Dropdown_CreateItem_TMPro_TMP_Dropdown_DropdownItem_
Hasn't even thought of overriding - thank you!
this looks like it'll do lovely :33
anyone knows how i can make a circkel fill itself up
I'm going to try the Flexalon asset. Feels like it was made to address gaps like this
Hey, is there an event alternative for the Transform.hasChanged flag for RectTransform?
EDIT: Apparently there is https://docs.unity3d.com/2018.4/Documentation/ScriptReference/EventSystems.UIBehaviour.OnRectTransformDimensionsChange.html , looking into it.
One solution I found using UIBehaviour.OnRectTransformDimensionsChange results in this (rather ugly) code, do you have better ideas?
protected override void OnRectTransformDimensionsChange() => OnDimensionsChange?.Invoke();
public Action OnDimensionsChange;
Hello can someone tell me what the issue is with this Box Collider 2D? It seems to be rotated 90° to the direction of the camera.
At the beginning of the gif the object its on has rotation 0,0,0. I then change the Y rotation of the object.
I need the collider to span the white box when the objects rotation is 0,0,0.
I dont think 2D colliders are ment to be on UI-elements?
Yeah why do you have a Collider on a UI element
2D Colliders are permanently on the x/y plane
I have a prefab for a on-screen joystick that has a field in the inspector for a 2D collider that enables limiting the area where the user can drag the stick.
using a 2d collider for that doesn't make a lot of sense
since colliders live in a completely different coordinate space than UI elements
I didnt make that component, so I guess Ill have to check back with the person who did and ask how he intended this being used.
Yeah Ill ask the guy about that. Thanks for clarifying, I am not too well versed in UI and 2D stuff myself.
When I apply a textmeshpro outline it makes an ugly outline centered on the bounds of the letters, so the ouline clips inside. I can use the underlay to fix that, but I'd like to use that to also make a shadow effect, and its also not wide enough as an outline. Any ideas? Thanks
I have a problem, i made list of objects/graphics, but when i enter playmode it shriks to object size, and changes back if i change anything, but when i add CSF component it moves object/graphic, is there any way to fix it?
There is a problem with canvas ordering. There are two canvases, both have the same order. For example canvas A is rendered on top of canvas B. The problem is UI events (click) does not work for canvas A and instead, it works for canvas B!
Canvas A contains several buttons. It does not work when CanvasB is active
If I increase Canvas A order, it would be OK
Now, I resolved it. The problem is because of render mode. Both have screen space- camera render mode! but why?
If I change them to regular screen space - overlay, it is OK but I want screen space- camera
I wanna make my custom UIsprite for a button, but it don't work. What do i have to fix?
You don’t need to make it multiple sprites in the texture importer
what?
btw i followed this tutorial for button sprites
https://www.youtube.com/watch?v=vleull-aONk
In this video, I show how you can create custom buttons for your UI in Unity. We will use the sprite swap option to change sprites when the user clicks on the button.
Please consider supporting my work with the links below.
https://www.buymeacoffee.com/SodaRocket
https://www.paypal.com/donate?business=2XAWU43T4DFVG&no_recurring=0¤cy_code=USD
but i need a stretchable one
3x3 spritesheet that works
like UIsprite
When I add a UI element into my scene, Unity creates a bunch of gameobjects with all many components
Is there a good way to know what does which ? And which ones I can safely remove ?
Hey everyone, how can I get my pixel font to look crisp?
Unfortunately TMP smooths out the edges
Trying to use materials for my UI
It is visible in prefab mode, but in play mode it all goes invisible
They typically are all needed
But give an example
does anyone know
why ui here is disorting?
the first one is unity (what I expect)
and the second one is build
Presumably you didn't anchor your UI elements properly
but why only final build is disorted
different resolution
Test different resolutions in the editor via the game window resolution drop-down
I don't see why you would use constant pixel size
But that's scaling
I'm talking about anchoring your UI elements
You need to read this
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html#anchors
I'm having a problem related to vertex colors being reset on TextMeshPro components in a camera space canvas. I have a type writer effect that sets every letter's vertex color alpha to 0 and then loops through every letter of my text and sets the alpha of each vertex to 255. This works completely fine until ANY change to the camera's FOV is made. As soon as the FOV changes due to my character sprinting, every single character on every single TMP text in this camera space canvas has it's alpha reset to 255. I've tried caching the alpha values that the characters should be and setting them in late update every frame to override the changes made by the camera updating, but I just end up getting this horrible flickering effect. If anyone has any tips, that would be very much appreciated.
POV: Me
Made a gameobject for a button
But they dont work on different screen resolution but I am to tired to make it as a ui 💀
can I add animations on ui too?
wait
in my opinion, this is better
why my text is blurry, what am i doing wrong?
You would have to show your settings for it
can't tell anything from this picture
i fixed it by messing around with size and width/height
but still so dumb that i had to do that to make it clear
and now im having a 2nd problem, the text does not show in game
more context like - where does this lie in the hierarchy, what kind of canvas is it in, where did you position it, etc... are all needed as well
ok so you're using Legacy text
so that explains a lot about the blurryness
well im following a tutorial, thats what the guy did
you've also positioned it completely OFF the screen
which explains the rest
Overlay canvases have nothing to do with cameras
you're likely making the typical rookie mistake here of trying to position the UI according to your game camera
If you double click your canvas in the hierarchy it will show you the full extents of the canvas/screen
position your UI elements accordingly
That's your screen yes
do yourself a favor and open the game view window side by side with your scene view
and you can see the UI updating there in real time as you position stuff in the canvas
i am using the text mesh pro thing now, which is way more clear, but how do i cant drag it into a script public thing
You have to change your field type from Text to TMP_Text
how can i fix my u.i when changing resolution? some are fine but others dont stay put
See layout link in the pinned messages top right. There are also tutorials on Unity !learn teaching how to use anchors rescalable UI components.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
tanks
You are rescaling text element there, it's probably part of your problems. Never rescale UI or its parents, it messes up with fidelity, it should only be used for temporary animation. Set element size instead.

how do I add animation on an imported panel
Easiest way is with Unity animation. You should contain the element in own canvas probably as well to not redraw entire UI each time it changes.
I added the sprite to a panel anf an animation with the animatuion on it but when I play it dosent work
You can find resources pinned in #🏃┃animation explaining how it works
how do I add a custom font
Had a rendering bug with Unity where child ui objects were not rendered in the correct order. Where's the documentation for rendering order by hierarchy?
I made menu for my (fan) game, and separated buttons to different images, but now their "collisions" are squares and they cross each other, is there any way to fix that?
You need to go to the sprites themselves and make sure they're imported as "tight mesh" rather than "full rect"
they are
can you showe the inspectors for them
rn no.. 12 AM for me.. i remmeber trying both
I wanted to see other things too
mostly likely tomorrow
but if you're not available at your PC right now kinda hard to work on this
yep, gonna try to do smth and text here again (tomorrow)
... what? 😄
I am trying to use horizontal layout group but it sets every child object transform to 0.
So it looks like it. Content has Horizontal layout group(child force expand enabled both) and content size fitter(prefered size both).
What components are on the children?
image
If there's nothing with size, then it'll be 0
an image shouldn't go to 0 tho
Do you want the layout group to control the size of the children ?
you can put a layout element on that object, and set the preferred size
Will this method be compatible with other resolutions as well?
I create a few prefabs in a certain area and I want it to fit in.
Obviously, in order for the prefabs to fit in this area, the layout group needs to control the dimensions of the child objects. But its just not scaling
@supple basalt you mean this?
This is part of a VerticalLayoutGroup. That means it's going to be put below everything else
If you want it to fill all of the space of its parent, you need to:
- add a LayoutElement and set it to ignore layout
- Set the RectTransform to stretch in both directions
then set left/right/top/bottom all to zero
okay, add the LayoutElement to PlayerRow?
what do you mean by "Set the RectTransform to stretch in both directions"? on the PlayerRow? @supple basalt
so, again this is the layout..
or do you mean on the Vertical LayoutGroup to Child Force Expand?
@supple basalt idk, i'm trying different arrangements and keep getting the same problem
On PlayerRow, yes.
Your vertical layout group should be set to control child size, and to not force-expand children
This will probably break your layout
ah: I misunderstood where PlayerRow was. I thought it was a child of the actual row
You should still go ahead and set the vertical layout group like this.
After doing that, show me the scene view with PlayerRow selected.
LayoutGroup has a height of zero
oh
After fixing that, switch to the Rect tool (second from the bottom in that list) and show me what PlayerRow looks like in the scene view
Note that you might want a ContentSizeFitter here, so that LayoutGroup adjusts to fit its children
You're making a scroll view, correct?
yes
That means the content can grow beyond the size of the Viewport
which will then mask out everythign that's out of bounds (if it has a Mask component, at least)
ContentSizeFitter makes the object ask its children about how much space they want
so i think i should set Horizontal Fit to Preferred Size
You only really need vertical fit
The LayoutGroup object can already just stretch to fill its container
(that's how you have it configured)
ok
If PlayerRow doesn't need to automatically resize itself (e.g. it contains a fixed amount of content), you can slap a LayoutElement on it
This lets you manually configure how big it should be
Give it a minimum height that's big enough to fit its children.
i don't actually have the Rect tool on mine, in Unity 2023...
that's with the second row selected
still having the same issue, experimenting with different setups
The rect tool is right there
2nd from the bottom
Give it a flexible width of 1, so that it'll fill the horizontal space
That tells its parent that it can accept any leftover width
ok, gave it flexible width of 1
but yeah, the button only hits if it's about 20 pixels below the row
LayoutGroup's "Right" is set to 188, so it has a 188 pixel margin on its right side
that may be getting in the way
Now show me the inspector for the "Player one" text object
TxtPlayerName, looks like
Its pos Y is -16.7
I guess it's kind of positioned right
You should set the text to be centered and then fix the width and height
ok
Pos Y will need to go to 0 ,and Pos X will need to be reduced
also, is this an old image? it looks identical to this one #📲┃ui-ux message
and in this image, the image has a non-zero width
well i think that is because i had the text object selection in the latter one, the first one had the PlayerRow selected
oh, but i changed the Layout Element to Minimum Width just now too...
since that actually works for the image in the PlayerRow so it shows up
fix LayoutGroup having that huge right margin
it might just have a width of zero, meaning its children also wind up getting 0 width
basically, you should have this:
- Scroll View
- Viewport <-- Mask, stretch in both directions, 0 margins
- LayoutGroup <-- VerticalLayoutGroup, stretch horizontally w/ 0 margins, ContentSizeFitter that grows vertically
- PlayerRow <-- LayoutElement with minimum height of 20 and flexible width of 1
- Stuff
- Stuff
- Stuff <-- this is all manually positioned, so auto layout doesn't matter here at all
- PlayerRow <-- LayoutElement with minimum height of 20 and flexible width of 1
- LayoutGroup <-- VerticalLayoutGroup, stretch horizontally w/ 0 margins, ContentSizeFitter that grows vertically
- Viewport <-- Mask, stretch in both directions, 0 margins
i may have found the issue, 1 sec
well, no... but here is a more telling demonstration of what's happening...
the third button down is actually fine, seems like a pivot thing?
idk, i will get lunch
well, i've got it working after understanding things better, thanks Fen
Hi, wasnt able to send stuff yeasterday, and cant fix problem myself.. can someone help?
Hello, I'm having an issue with the scrollview, for some unknown reason, a child image of the scrollview is still showing up when I scroll down.
The image is clearly a child of the view and has no special property or component
The parent Gameobject "Delete" also is an image and does not have this issue, it's really weird.
Here is if I disable the viewport mask, everything shows as expected.
Would anybody have any idea what could cause this problem?
OK found the issue which was dumb... The maskable bool on the problematic image was disabled... No idea why, I must have messed it up previously...
Hello. This s probably a very simple fix, but why does my UI appear to be pixelated in my game view but smooth while editing in my scene view and what can I do to fix this? Could this be an issue with anti aliasing?
Is your game view zoomed in
Currently this is a zoomed version of my game view, but otherwise, no its not zoomed in when actually running the game
The slider at the top of the game view says "1.0x"?
Yes. As an additional piece of information, the UI is quite small.
what are the canvas settings? Can you show more screenshots and context overall?
My apologies. These are my canvas settings. Are there any other properties you'd like to see? Currently I just have an empty game object containing my interaction UI, which controls the functionality of these elements. All 3 children listed are images using a shader as their material (more configurable). The progress bar contians text labeled 'tool tip'
For some weird reason my image keeps dissapearing in Game
The anchors aren't anchored to anything? Change this to top right.
And - Why is the z pos not 0?
@lilac egret ☝️
im trying to figure out Scroll Rect component... How do i change the bounds at which the scrolled elements start disappearing.
i made little arrows to show how its overflowing from its inner component. how do i make it so it doesnt overflow like that 
use a mask
oh i have a mask component but is there no way to modify the dimensions of the mask? 
i have the mask component on the ItemList gameobject that also has the scroll rect component
of course you can change the size of the mask - the mask component uses the size of the recttransform it's on
oh interesting
guessing the sprite im using is just a bit off thats making this small issue
That gap could be the scrollbars