#📲┃ui-ux
1 messages · Page 15 of 1
in css I would do grid-template-columns: repeat(4, minmax(0, 1fr))
I can somewhat acheive it with Grid Layout Group, but I have to set a fixed pixel amount for the cell size, which I dont want to do, I just want Unity to distribute the available space evenly
Grid layout element isn't really useful if you want dynamic, I've never used it
There's a "layout element" component, with various settings on for sizes, that might be what you need
ok Ill check it out, thanks
theres something sussy going on. When i enter play mode the content becomes smaller, but i just need to touch it for it to go to the intended size.
and when i build the game everything is on top of each other, like what happens second 1 when i enter play mode 
theres no data being inserted programatically or anything
So, did Unity just assume no one would ever use Dropdown menus with controllers? Because that functionality just doesn't work out of the box....
i mean yeah dropdowns are not really ideal for controllers. Something like a carousel is more typical
Sure, in the cases that you might be thinking yes.
However in my case, its just for a changing the resolution of the game.
Exactly!
I see this in games all the time
probably precisely because dropdowns are weird for controllers
oooooo. That is a valid solution...
I shall bring that up to my artist. Thank you.
(For some reason when you said carousel I was thinking like.. seeing the options on the left and right, and having it actually spinning. I blame lack of sleep)
nah it's probably not called a carousel I just don't know what it is called
is there anyway to filter img not from the asset?
it shows too many unwanted textures
This chan is for making game UI with Unity's UGUI, not editor gui questions. However look at the quick search package, that might be able to do specific searches like what you're after.
Why does my build turn out like this compared to the editor?
possibly the anchors messed up..
Did you design your UI with the game view on 'free aspect' ?
I'm not sure, but it looks perfectly fine regardless of the view in the editor, and when displayed at my native resolution in the editor, it seems fine too
I have reason to believe it's down to the sprite system and how i've set it up though
But it would't make sense as to why every single UI image would tile
Hello, I am making a game and I need icons/pics but I don't know how to make them does anyone know of a course (free) that would teach me how to make it and make it look good also preferably if it also teaches rounded corners.
Any one can me suggets plugin or way for Expandable Recycler scroll view ?
try enlarging the text box or increasing font size
Hey there. I have a UI button that takes in an On Click() function from a game object. But the script attached to the game object is not appearing and thus I cannot choose the function I need. I attached some images. Anyone know why this could be happening?
drag in the gameobject with the script, not the script itself
Have done, it's the game object as you can see and not the script 😦
may I see the function you're trying to call
just to check, no compile errors, right?
Yeah none-no-rino
I believe it's the parameter
but do check out that link and perhaps save it for future use 🙂
Okay thank you so much!
you're very welcome
hey, any good solution tips when we have seperate UI camera and game gamera, how could we use same particle effect prefab on both? scaling becomes an issue
Look up 'prefab variants'
yeah sure we can have variant for both, was wondering if there is anything one could do with scripting
I believe the usual way to get particles working with UI is to have them on a second camera, rendering to a render texture for UI
https://stackoverflow.com/questions/58830542/unity-particle-effects-on-canvas
It would probably be worth looking at this though
How to deal with sprites with 1 pixel borders if they can disappear in some specific resolutions? I managed to keep constant size for a line through code (pic 3), but is there a way to do the same with a more complex images?
Are you using 9-slice?
is it possible to have bigger space inbetween certain rows in layout group without wrapping item in empty gameobject shenanigans? I need bigger space between 2nd and 3rd rows as thats where selected items end and possible items start but whole list is scrollable
You can have an empty game object in between those rows, with the height set to what you want. No need to parent those in empty game bojects
how would that work grid layout enforces same cell size and it doesnt care if element is bigger than that
actually my prior "solution" wouldnt work either cause I need to have same cell size for everything unless im missing some option
yea so if I could edit size and not scale I could get 4 empty elements to make a spacing for me perhaps but layout group wont let me
I avoid grid layouts, as the cell size is fixed - they don't resize with the screen.
I use nested vertical and horizontal layout groups
If you want to keep thr grid layout though. You'd need to have 2 grid layouts.
Vertical layout group on the ScrollArea game object, with 3 child objects.
ScrollArea with vertical layout
- GridLayout
- Spacer
- GridLayout
nice ill try this ty
Hey I am confused about rect transform and setting width and height vs the scale of UI elements in the canvas, is that just me? If any has resourcs they can point me to would be helpful!
Thanks!
Always keep the scale of all UI elements to 1,1,1
Change the width/ height to size UI to how big you want them
The canvas won't be a scale of 1,1,1.. but that's ok
Ok thank you @low pike !
In the case of having one UI element match the scale of another UI element - should you use SizeDelta? or make the transform.localscale equal to one another? Thank you!
you shouldn't be touching the scale ever
you also don't touch the transform when dealing with UI, you always manipulate the RectTransform, so yeah.. use .sizeDelta , but the only time you should be changing this is for animation
Ok, I understand, thank you!
Just so you know why you should always keep a uniformed scale (1,1,1)..
if you have parents/ children with different scales, and then you try to resize them (either manually or because the screen size changed) then nothing will scale correctly and it'll all go out of whack
Makes sense, this has happened to me, which prompted me to ask the question, thank you for your help!
No problemo
The same thing will happen with normal game objects too, but you have to scale them by the transform
Ok I will keep it in mind thank you!
Additional question(since your answers have been very helpful!) - should the canvas typically be of square shape? Or should it be resized to be the same shape as its children?
Thank you!
The canvas will be the shape of the screen
Never develop UI with the game view set to 'free aspect'
Ok thank you!
whats up with this stuff if I dont use content size fitter I cant scroll down if I do use it my vertical group default position is in the middle of list
I did have same problem before I just set it through code through scroll rect verticalNormalizedPosition property before showing list but im at this again like bruh
The scroll area needs to be the size of the children. The content size fitter just auto does that for you, if you don’t use that then set the height of the scroll area manually on the rect transform
what's the proper way to resize a slider without the handle knob stretching in weird ways?
Thank you!
Is there a way to 'stretch to safe area' or something?
This is a Samsung s8 vs. Iphone 12
there is an asset for it in the asset store https://assetstore.unity.com/packages/tools/gui/safe-area-helper-130488
for this
I second this asset. Super easy to use and helpful
is there a way to have this fill amount be symmetrical?
so like the fill drain heads towards the center like Halo Reach for example
like this
Make 2 images back to back that fills in opposite directions
Hey 🙂 Does anyone know why i cant drag and drop this in there? It is part of a prefab, is that the reason?
in the code i used:
public Dropdown ColabDD;
(also does this go here or in the toolkit one?)
Is it UGUI or UIToolkit UI?
What type of drop-down are you using?
DropDown - TextMeshPro
is that a different command?
well that makes a lot of sense then 😄
thanks a lot ill take a read ❤️
is it possible to have UI canvas/image slighty under angle? so its not pure flat toward camera but angled?
Yes. I think a camera or world space canvas can do that
Anything except overlay
Hey does anyone know what these errors are from? Ive been receiving (and ignoring them) for a while now. Thank you!
looks like internal GUI errors in the editor
Ok thank you @mortal robin
https://forum.unity.com/threads/ui-appears-weird-in-build-but-not-editor.1483719/
Can somebody figure out what's going on here?
why dont i see the little orange square on my inspector? (my inspector is black, his is white)
nvm i fixed it sorry
Please HELP! I am using 2023.1.0f1. The first image was in a build, the second was in the editor. I did mess around with the video/graphics settings before I built the game. I have been stuck at this for days. Everything keeps tiling in the build but not in the editor.
Have you tried the LTS version of Unity as a baseline to see if it at least works there?
No, I'll try that in the morning. From what I remember, this didn't happen before though
Well it's not normal, so likely it didn't ... because it shouldn't.
But instead of trying to fix the issue, you need to find out when and where it started.
I've tried diving into the github commits, however I had not built the game whilst I was messing with the graphic settings
So I wouldn't really know when it started
Can you not make builds from some old commit?
It took about a day to compile all the shaders
Right, well, rolling back and building would be your best bet. But if not that, then at least verifying LTS.
Which you'll still need to compile for ...
Is there a way to make ScreenSpace rendered in perspective?
I have a mostly UI Toolkit project, but I want an effect where a Playing Card flips over and it currently looks quite bad because there is no perspective. I tried making the card UGUI instead and in Screen Space - Overlay, it is still ortho. I swapped to Screen Space - Camera, but then it can't be rendered over the UI Toolkit elements.
Am I just screwed?
DOn't make your game out of UI
if you're looking for an MTG arena style thing - you should be using 3D objects for your cards
It's not quite that. I think I'm just butting up against the limitations of UI Toolkit. Trying to make my inventory system fancy.
But I think I'm coming to the conclusion that UI Toolkit just isn't fit for more complex systems yet.
Even with normal screenspace UGUI, you wouldn't be able to do perspective. I'd imagine in both cases you need to fake it with scaling it big (lifting the card) and then scaling it horizontally (flipping).
This canvas pops up in the scene view but not in the game view. It works perfect when I die before defeating the "boss" but after defeating the boss it stops working. No errors are thrown. Any ideas?
what's your canvas setting like? is it Scale with camera or overlay?
Thank you for the reply. It's overlay.
I did some more trouble shooting and I have some text appear after some time (like credits) and when this new text appears.... I realized that this is somehow messing up my menu UI's.
Is there a way to put text on a gameObject without it messing up the canvas?
i dont know about that, but you can try to change your canvas setting to Scale With Camera...
Hello, i have a little game with some ui and need to create a menu for upgrades, do i just create the window of it on the existing canvas and enable/disable it or is there some more proper way to do it?
That's fine
New to Unity so.... How do you get a "Screen Space - Overlay" Canvas to appear - in editor view - as you'd see it in the game? I want that so that I can more easily place UI elements on the Canvas and don't have to worry about things like perspective. The docs mention a "Fit Canvas" button but I can't find that. I tried double-clicking on the Canvas and that alternates between bringing it into view (but not perfectly aligned - basically a projected plane that consumes about one-third of the total screen real estate so the UI is very small unless I manually zoom in and orient the camera) and zooming in on it such that you can't see any of its elements (i.e. camera seems to be on the Canvas' plane so you're looking past its projected elements.) Once I jump into the game everything shows up as you'd expect - the button that I placed at the top left of the Canvas is at the top left of the display and stays fixed there regardless of where I move the camera. Essentially, I want to be able to see the Canvas and move the UI elements around on it like it shows up in the game.
Press the 2d button on the scene view -> select the canvas -> press F
also, press T to use the UI gizmo tools
To go back, toggle 2d off and select something in the game to focus on (F)
I had tried the 2D view and that half worked - doesn't fit the Canvas exactly (or even close) to the screen size (without my manually zooming in maneuvering.) Is there a way to address that bit?
You cant afaik with screen space overlay but you can do screen space camera which is basically what you want.
I don't fully understand your problem,that's how I always work with UI and don't zoom in/ move around unless I want to get closer to something
record a vid?
When I focus ('F' key or double-click) on the Canvas the camera alternates between two views. The first is close to what I want, especially if I'm in 2D view. That is, the Canvas shows up without any perspective and is centered on the screen. The problem is that it doesn't fill the screen like it does in the actual game and instead consumes just a small fraction of the visible real estate - roughly 25% so it's actually zoomed out pretty far. Placing a lot of UI elements precisely on such a small display is difficult. To address this I manually zoom in to the Canvas and get it pretty closely aligned with the full extent of the display. Unfortunately, that effort is lost as soon as I maneuver the camera to look at something else and then seek to return back to the Canvas (via another focus operation), which once again occupies (by default) just a small fraction of the display.
Pressing F on it or double clicking it should show the full canvas
Make sure you have the Rect tool selected
And note that the canvas is not supposed to line up with your 3d scene in scene view
It will be much larger than your scene typically
Use game view to preview what it will actually look like in the game
Yes, good point - the UI presentation in Game View - which is identical to being in game mode itself - is exactly what I'm after with one shortcoming. Is there a way to select UI elements in that mode - at least those that are a child of a "Screen Space - Overlay" Canvas - and move them around the screen? I can do that via typing into the Pos X/Y/Z fields - would just be way more convenient if I could drag the UI elements around the Canvas like I can in Scene View.
I have a horizontal layout group with several elements with left anchors - when I grab an element and drag its width, it stays anchored on the left side and resizes on the right, causing the elements to the right to also change their position - this is good. But when I change its x size through the inspector (and therefore through code) it resizes relative to its own center and doesn't effect anything else in the layout group. Wtf?
Oh, and just discovered - if I change the element's width when the game isn't running, then it resizes while respecting its anchor and works normally. But if I do the same thing while running it resizes relative to its center
game not running - change width to 180
game running - change width to 180
(from width 300 in both cases)
(if I drag it with the mouse then it works as expected whether game is running or not)
Eventually figured it out. Need to change pivot point x to 0, and also have to force the layout group to rebuild inside the coroutine which lerps the resize
Hey, is it possible to mask out an Image material in the UI? It seems like Mask doesn't work in the UI if the image is using a custom Material, it does work with standard sprites though. Is there a way to get around that? Or does it require custom code to force some kind of render mask?
I'm trying to mask down my "map fog" to my "compass" so it obscures the player map when in specific areas (code trigger). Maskable is checked but it appears to be ignoring it
hello
yo
ooh this channel will be useful later
so what is this ui object
it's a healthbar
has a sprite render, image, and text mesh
so delete that sprite renderer
in that order
well the sprite renderer is the backfill color of the healthbar
wait no it is an image nvm
so basically screenshot unity?
yeah
oh i messed with the screen resolution dropdown and now it's here
i got it on camera at some point before
and then i havent seen it for 2 days
ok so basically the canvas things are resolution specific
so if you manually position them, it can mess up if you change the game resolution
@tight hazel im back
hellohello
so basically what you wanna do is change the anchor position of the object
the canvas?
no
the healthbar object?
the healthbar object
the healthbar object.
the healthbar object
the healthbar object?
so like where it's anchoreed on the whole canvas?
it's set to 0, -400, 0 right now
or do you mean this
so its is centered righ tnow
what you want to do is hold ALT and click the middle bottom one
the one below the outlined anchor
now you see that windmill looking thing
mhm
so its x y and z are 0 at that point
it go up
it will always y amount higher than the bottom of the screen
and it's marked like a drafting chart yay
no matter what resolution
ooh let me go mess with that
mhm
and you will hopefully see that the health bar stays at the bottom of the screen
and it doesn't ever go offscreen
perfect 😭
hehe i can figure out making it a bit more scaling friendly later
for now it's on the screen
and it's mostly readable
and that's good enoguh
tysm!
and with that i think it's nap time
no problem
im surprised i was able to help honestly 😅
i'm also very new to all this, but i'm learning
have a good nap
You're using the wrong tools for UI, press T to swap to the rect scene tool
no worries, i prefer the precision of typing in here over the mouse guided controls
You can still type in there, the rect tools give you more control than the transform one
oo noted
I am trying to set to canvas rect transform's position in code.
What am I -supposed- to be doing to do this?
My code is broken and does nothing like I expect, so me posting it is pointless because I have no idea what I am doing
You can't move a canvas position. Unless it's a World Space canvas
Yeah its not in world space, its screen space - overlay
So you can't move the canvas
You can move the children RectTransforms around, is that what you mean?
I dont know what you mean by this, I am trying to move rect transforms in the canvas, not the canvas itself
reading my own question I can see how that is confusing, I didnt word it well
You need to set the .anchoredPosition
How do I set to the rect transform value of elements within a canvas, correctly
And the values you put in depend on the pivot and anchor setup
doing that is 100% my exact problem I am having, setting to anchoredPosition hasnt worked in any way I expect
anchor position in that gif is being sent to the curor's positon, but its nowhere near the cursor's position
I am not trying to move it in 3D world space
I said I am trying to move it in the canvas
because its a UI element, on the canvas, with a rect transform, not a 3D world, there is no 3D, no vector 3s at any point
I understood exactly what you want. Did you read beyond the title?
"How to move a UI GameObject using Mouse Position in 3D World Space?"
why would I need to read beyond the title if the title doesnt pertain to my question?
Go read the first answer?
its a bad title if the question isnt about 3d world space
I don't really give two forks about that, I didn't write it.
k
okay I read it now, and it has nothing to do with my problem
world space is not my problem, 3d is not my problem
You read the first answer?
Yes
I guess I'm just too fucking stupid to understand how their constant discussion about 3D space world points relates to my 2D question that hs nothing to do with world space
alright, well, I'm done googling for you
k
Dumbass
k
<@&502884371011731486> this guy is verbally insulting me
Let's refrain from insulting people. I think they would end up with a world position with that?
When I add a Mask to IconBackground, the Icon disappears entirely despite being situated on the background (only small portions extending beyond the background)
the heck?
without mask
with mask
Is the maskable property turned on?
Rect Mask 2d works like it should. But that's no good since it's a rectangle and not a circle
Can you show the mask component?
Hm, when I uncheck Show Mask Graphic, the Image doesn't disappear like it should either
Can you remove the GlitterMaterial so it's default
huh, that made it work
K so you have to make a 'dummy' background with no material to child the icon to. Can't have both a mask and material on the same image. Feels like a bug? 🤷♀️
Why is this text always setting itself to minimum size even when there's tons of room..?
(there's no layout groups or other components on the text obj involved)
Figured it out...
what is the best way to render a list of points on unity canvas?
is one image per point the only way?
I dont think there is another wa
ah
u guys use instancing but then positioning might be an issue
unless you are rendering thousands of points there is no reason to use instancing
how many?
from 100 to 1000
i see
I dont think u need instancing, should be fine with components
you should also try and render only what is needed etc
It is all needed
For a world map
Drawing path from player to some pin
I will try using normal images
yea, go with the default, if that doenst work, then pull out the big guns
Buttons not working for UI?
See the UGUI input issues pin
Help guys
Change the width on the handle transform, or set 'preserve aspect' on its image component
Anyone know how to force a TMP Dropdown to show more?
Right now it only shows (height wise) [total items -1], would love to have the dropdown have a max height for scalability.
I.e. at 1 entry be 1 entry tall, 2 entries be 2 entries tall, but at 3 entries + have scrollbar and still be 2 entries tall
How do I make an area in my UI where images that enter that area go invisible?
So if half of an image were to enter that area, that half would become 100% transparent
indeed a good question
i tried a few things but no results
maybe with a ui mask?
but it is actually the opposite of what you want when using mask
Is it possible for me to have a different layout for vertical aspect ratios?
On desktop this looks nice, but on mobile, I want to make it bigger so the text is more visible.
well your font is small by default
it would look ok if it was slighty bigger evne on the mobile version
there is a way how you can handle ui for different plattform but it is trickery and you would need to define all the plattforms available
here is a topic : https://discussions.unity.com/t/can-i-use-platform-specific-uis/140556
you could also stretch the ui text holder completely so it covers the whole width which will also give you some more extra space to make the font bigger. This should be enough to make it readable.
i'm thinking of expanding the text box vertically on mobile aspect ratios which should give it more space for a larger font
but not sure how to handle that necessarily
Gotcha, so have a small script sit on my dialoguebox monobehavior and adjust based on platform?
yeah but i would not recommend doing this tbh. Just make your ui flexible so it automatically fits the width
I don't think width is the issue here though, I need the dialogue box to expand vertically more than it would on desktop since mobile will have a smaller line length
you could also make use of this:
i believe that's only for the font
yep it is on the TMP
and if you add an aspect ratio on your panel where the text is it sould be what you are looking for
one issue i've found with auto size is it makes the text wayyy too big for a given area, especially if there's only a word or two, and since this can have variable text i'm not quire sure how to handle that
i imagine that's what the "max" field is for but I need it to change depending on the height of the box
yeah you would have to find out. Unity´s ui system is very powerfull it provided a lot of nice options and features.
why is the video not playable hmm
because its requiring AV1 video extension
i think
I've spent 16 hours trying to solve why this panel wont drag correctly and nothing I do is fixing it and im at my wits end trying to solve it
every single mobile app ever made has press finger -> drag
so why is it so unbeliebly difficult, why is nothing I do working
its literally three different vector2s, start, stop, yourfinger
unity's UI Canvas thing is so utterly dogshit but I'm not allowed to say or think or feel that because the REAL answer is that I'm a stupid worthless dipshit
and thats why im here now asking for help to solve this because I am too stupid to solve it myself
and im going to come back every single 8 hours, every day, until its solved
I cant even post the code because the code is like 30+ methods
and all of them are critical
and all of them are broken and worthles
private Vector3 SetOffsetPosition(Vector2 touchPos, MobileCanvasUIElement uiElement)
{
RectTransform rect = uiElement.GetUIRectTransform();
Vector3 touchInWorld = cam.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, cam.farClipPlane));
Vector3 offset = rect.position - touchInWorld;
uiElement.SetTouchOffset(offset);
Debug.Log("Rect Position: " + rect.position);
Debug.Log("Mouse Position on Canvas: " + touchInWorld);
return offset;
}```
do you see why this is fucking up its intended purpose?
all SetTouchOffset does is store that value
i think its not because of your code but rather because of your canvas settings/ element
or you need to change its pivot position aswell
I dont know what any of those are or how to set them up or change them, they are all default
im 90% sure its my code though because without any code, the panel doesnt do anything.. since there's no code
i just want to press my finger on it, and drag it, and have it be dragged, along a line
why is that too much to ask for :/
your panel does do something though. it sticks to the pivot
Okay, how do I make it do that and also do the above drag functionality?
ive tried assigning to position, to anchor position, ive tried offseting every possible variable from every other variable in all 8 different coordinate spaces Unity has
none of it works
I dont understand why its so immensely nontrivial to just touch and drag a thing
i dont remember, search it up, use google
I have been
I can barely find anything because apparently im the only one who's ever had this problem
nah i had same issue i solved it but i cant remember how honestly, just try stuff untill u make it
u could make it easier if u just make it in slider and just slide it off screen
scroll bar/scroll view actually , something like that
its an UI element that u can use without ur code, to just slide through scroll content
Why Canvas component is blocking button on child gameobject?
Blocking button? What do you mean
What is happening, and what do you want to happen instead
I am trying to sort particle system on layers and made empty game objects with Canvas component and different layers. Empty gameobject has an object with button and it doesn't work. But if I delete Canvas component, it works.
I don't think you can have particles on UI
So your issue is you have a child button
Particles must be on bottom with background.
The parent has canvas component
Is your issue that when you add a Canvas component to an object, the child button cannot be clicked?
Is that it?
Yes
Make sure your canvas also has GraphicsRaycaster
But main Canvas for all UI has it. Or all interactive canvas must have it?
All interactive ones must have
You are my savior! Thank you very much.
in the future you can check the pinned messages for troubleshooting links
Thx
I am trying to debug the difference between spacial coordinates with canvas and world and screen positions.
In this picture, why is the selected canvas UI panel's anchor position (teal) so far to the left outside of the actual panel itself?
the values being shown are all in reference to an initial tap position on the screen
The anchored position is the position of the pivot relative to the position of its anchor, in canvas coordinates. It looks like you're drawing the teal dot using that canvas coordinate, but as a world space position, right? So the position you're seeing doesn't really make sense because it's a misinterpretation of the value.
you ahve a right-center anchor on that element and a centered pivot, so really the -302 is just saying that the parent is 604 units wide and you have it centered (with a right anchor)
That's my interpretation anyway 🤔
Ill post the code, since reading that alone I don't have intrinsic comprehension yet
InstantiatCanvasUIDebugPoint(debugTarget.anchoredPosition, "RectTransform Anchored Position");
private void InstantiatCanvasUIDebugPoint(Vector2 position, string spaceName)
{
GameObject debugDot = InstantiateDebugObject(debugUIDotPrefab, position, canvas.transform);
SetDebugObjectName(debugDot, spaceName);
Color textColor = SetDebugObjectColor(debugDot);
SetDebugText(debugDot, spaceName, textColor);
}```
in the above, the instantiated dot is made at debugTarget.anchoredPosition
right so see how you're passing debugTarget.anchoredPosition into the position parameter of Instantiate?
Yes 🤔
Instantiate expects a world space position
but anchoredPosition is a canvas space position
so it's not really a correct thing to do
Hm okay, what is the reccomended proccess for instantiating elements into the canvas in that case?
Most of the time I'm doing that they're going into a layout group, and I just use the Instantiate(prefab, parentUiTransform) form
and the anchoring etc will already be set up in the prefab and it "just works" ™️
If you want to preserve that specific anchored position I suppose you can do this:
GameObject debugDot = Instantiate(debugUIDotPrefab, canvas.transform);
RectTransform rt = debugDot.GetComponent<RectTransform>();
rt.anchoredPosition = position; // where position is the anchored position you want it to have```
Thusfar on my end sadly nothing has just worked™️ so I am trying to visually and numerically debug the exact relationship between everything 
good plan
Ill try this code. You're instantiating it any old place and then moving it to the location of the anchor point with this right?
basically yes
I went to impliment this but I have reached confusion.
You're not setting the debug dot's position, you're setting the debug dot's anchor position. I want to see where the other thing's anchor position is, am I misunderstanding something here? Shouldnt we be setting to the debug dot's position to the anchor position of the other thing?
I'm not sure I understand what "the other thing" is here
I went to pass in the reference panel's anchor position as a vec2 'true position' but realized you arent assigning to that value
the other thing in this context is a random arbitrary panel I have placed in the canvas
because I need/want/think that I need/want how all these positions inter-relate, not just to the canvas itself but things in the canvas
so atm all of the canvas part is being done relative to that asset
the values of position and scale and anchor and all of that are entirely arbitrarily set for no reason other than to make them not identical to the size and shape and everything of the canvas itself
should I be doing something else? Is that not what I should be trying to come to comprehension?
so for the above, when I set the debug dot to the panel's anchor position, it shows up at -16459 x
I am not comprehending why its anchor position is way over here 🤔
the debug dot rt's position is being set to the anchor position of the reference panel, which is aparently -16459x in the canvas
things like this are why I am so confused and having so mant difficulties, why is the anchor position at -16459x? What am I supposed to be setting to? There are just too many "positions" in coordinate systems that all have nothing to do with eachother :/
I am trying really really really hard to not get distressed
but its not easy
can you or someone you know tell me why the anchor point is way over there? Or at least tell me that you don't know why its over there so that I do not sit and wait for a reply that may not be coming?
does this data help?
this as well
the end goal I am trying to achieve is to be able to take input value in space X, and return output value in space Y
use case example - take in finger touch position, use it to drag a panel 😐 which is not going well
🫠
I have the data, but I am not sure what to do with the data, what to infer to get results
Im still poking at it
but I am realizing I dont know what I am doing or what result I am even trying to get
I have Data™️ but no comprehension what that data means or how to use it
I guess the most practical result would be that when I tap, every dot appears in the exact same space? But not like, I brute force them all to be in the same space, that each are in the same space relative to themselves but in whichever input space I sample?
eg I can tap, and every dot appears at the pixel coordinates in world space that Screen Space Finger Position is at
I am guessing you stepped away Praetor, if anyone else reads this and has any ideas let me know please, I would appreciate it
are these three assumption methods correct?
am I making a mistake from minute 1 of trying to solve this?
seems correct so far
step 2
assigning that position to the anchored position
expected behaviour: cube is on the dot
actual behaviour: cube is not on the dot
private void CaptureFingerInitiatePress(ET.Finger finger)
{
if (debugClick)
{
//This value is in screen space. Screen Space is pixel dimensions of viewport or physical device.
Vector2 fingerSpot = finger.screenPosition;
Debug.Log($"The value {fingerSpot} is the finger's screen position.");
Vector2 canvasSpot = ConvertToCanvasSpaceCamera(fingerSpot);
Debug.Log($"The value {canvasSpot} is the relative canvas space position of the finger's screen position.");
InstantiatCanvasUIDebugPoint(canvasSpot, "canvas relative to finger");
debugTarget.anchoredPosition = canvasSpot;
}
}```
am I even supposed to assign to AnchorPosition? How are you 'supposed' to move rect transforms?
I know you can use the <color> tag to make TMP text colored, but can you specify an RGB or hex value? I tried <color="#hexvalue"> but that doesn't work
Rich text documentation for TextMesh Pro.
ah, so just not marking it as a string, thanks :)
I had fun Joining Newbies Genshin World to steal their chests in Genshin Impact Co op... now I feel bad for scaring them :(
If you like the video, be sure to like and subscribe! https://bit.ly/3Fq9e0k
Nuzlocke Playlist 👉 https://www.youtube.com/playlist?list=PLwn8q1k5Zg44nkiliWGIQmM5uwzhABig5
Re:Genshin Playlist 👉https://www.youtube.com/playl...
Is there any way to animated vertical layout groups like that?
<< the obtained list
Not automatically, no. You would have to build that yourself.
uhh not sure if this is the right category but... does anyone here know how to make UI elements have a neon style efect
basically glowy edges for sprites
I searched up some tutorials but they only work in 2D
but I have a 3D game with 2D UI elements
you mean you input the white points and get the curve?
Use bezier curves
Or a catmull Rom spline:
https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline
In computer graphics, the centripetal Catmull–Rom spline is a variant form of the Catmull–Rom spline, originally formulated by Edwin Catmull and Raphael Rom, which can be evaluated using a recursive algorithm proposed by Barry and Goldman. It is a type of interpolating spline (a curve that goes through its control points) defined by four control...
LineRenderer?
Freya Holmér is working on a splines library that integrates with her Shapes plugin
Can be done with the Vectrosity asset too:
https://assetstore.unity.com/packages/tools/particles-effects/vectrosity-82
but you can also draw this with GL lines, or LineRenderer, or a shader
probably?
could also be a dynamically generated mesh
do you guys have any tutorial about red zone like this?
or any key words about this
this red zone is like evade from this
you just need to find out these things
- how to spawn objects
- how to set their position
- how to make them scale up over time
@celest remnant
Game dev is not "how to make hit warning indicator". think in more generic terms
thanks for your reply, hope i do it correctly
can I prevent ui elements from resizing when I unparent them? I had issue with them prior if I instantiate without canvas it needs to sit on as parent, element expands massively and it doesnt resize anymore to proper look with parenting but now I really gotta make them homeless for a moment 
oh nvm its obvious they always need canvas to be in but this weird expansion threw me off
how do we feel about this as a ui layout
I'm not sure if health / mana being all the way down there will be easy to parse if youre looing at mid screen 
alternative is something like that
I'm trying to make this image scalable to all ratios but it scales awkwardly. It's just a menu in the center. I'm a beggar so anyone help please
scales awkwardly how
and please take a screenshot, not a photo
be more specific on what's wrong and what you want to happen
Oh sorry for that i apologise. Also my problem got fixed i changed the match of canvas scaler and it worked fine. The problem was that it was stretching too much in horizontal. And even though i tried anchor points to stretch vertically it didn't like a messy thing. But now it's fixed 👍🏿 also thanks for telling me I'll try to be more specific next time and share screenshot
Postprocessing
i think if u play with bloom scattering u could get there
Since this docs page has nothing useful on it...when is this method actually called?
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ISubmitHandler.OnSubmit.html
I want to get an event when a selectable is either clicked or activated with a gamepad
Hello I'm mostly a programmer looking for feedback on UI layout for a mostly vertical climbing upwards type game. I looked at downwell as a reference but was wondering if people here might have suggestions for improvement. Trying to set up both portrait for phone and more square/landscape for desktop/web
I have a text but on each device it has a different position, someone told me to change the resolution to fit mobile but now I've been told there is no resolution for tmp text
because you are not using anchored position but manually puttinh the ui element on the screen
I have been using it, no use
can you show the inspector of one of your ui elements
you need to familiarize yourself with https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html#rect-transform
to learn how to use anchors and pivots etc
thanks!
In a 2d core project
i tried to create a ui raw image
put the image in the raw image
dragged it over the camera
but the camera doesn't see the image it's still showing the background color
ok my issue was that i should put my stuff over the canvas and not over the camera
I have a custom UI element that sits behind a TextMeshPro text object, and I'm using the UI element to render colored rectangles behind the text. Think like the <mark> tag in TMP rich text but instead of rendering in front of the text, it renders behind. I'm doing this for a terminal emulator in Unity, and I've got it almost working fully. Game's framerate is also much better with this technique than it was with my old one.
Problem is I've screwed up the measurement of line heights. Not sure what's wrong with my math but the rectangles are ever-so-slightly taller than the actual lines of text TMP is outputting. You can see here how the text cursor looks like it's a line below where it should be
Clear the terminal though and it looks fine
10 linnes down though, and it starts to look slightly misaligned
This is the code that does the font measuring to figure out how wide and tall a color cell should be
private void CalculateTextSize()
{
char ch = '#';
var style = FontStyles.Normal;
float fs = fontSize;
// Compute scale of the target point size relative to the sampling point size of the font asset.
float pointSizeScale = fs / (font.faceInfo.pointSize * font.faceInfo.scale);
float emScale = fs * 0.01f;
float height = ((font.faceInfo.lineHeight - font.faceInfo.underlineOffset) * emScale);
float styleSpacingAdjustment = (style & FontStyles.Bold) == FontStyles.Bold ? font.boldSpacing : 0;
float normalSpacingAdjustment = font.normalSpacingOffset;
// Make sure the given unicode exists in the font asset.
font.TryAddCharacters(ch.ToString());
if (!font.characterLookupTable.TryGetValue(ch, out TMP_Character character))
character = font.characterLookupTable['?'];
float width = (character.glyph.metrics.horizontalAdvance * pointSizeScale +
(styleSpacingAdjustment + normalSpacingAdjustment) * emScale);
Vector3 scale = transform.lossyScale;
this.characterWidth = width / scale.x;
this.lineHeight = height / scale.y;
UnscaledLineHeight = height;
UnscaledCharacterWidth = width;
}
Widths are fine, but the height is slightly off
I didn't write this code, got it from an ancient forum post or something, can't really remember.
I've tried messing with the way the height's calculated though and I just can't seem to get it
I have an object in the scene I want to receive UI events, but, for some reason, doesn't, despite me implementing the right interfaces. The eventsystem only seems to distribute events to UI objects, like buttons. Can I flag my object for receiving events from the EventSystem somehow?
You need a Physics Raycaster on your camera and a collider on the object
(or the 2D equivalents if 2D)
does anyone know why these buttons arent working
they worked before but now they seem to have 0 functionality
im sure its not unity but rather something im not seeing (please ping when replying tysm)
check pins for the UGUI input issues link
but from what I can see, you seem to be missing the EventSystems in your scene. that's the issue. the link covers that
an image with a circle texture? 😅
I really like the UI Extensions package for this, it has support for drawing several shapes procedurally
https://github.com/Unity-UI-Extensions/com.unity.uiextensions
I dont understand how buttons exactly work I have disabled every single thing button has as raycast target apart from button itself and it still doesnt click through images on top of it so only white area shown is interactable
have you checked that it's the image that's blocking the button?
you can check that in the EventSystem's inspector
and if there's nothing on top of it, can you interact with the button in the first place?
you mean this event system?
nothing changes when I click on anything and yeah button is interactable
in the white area which is the actual button with no images on top
yes
see that link to learn how to use it to identify what you're currently detecting
it's pinned in this channel
it was text btw now million dollar question why starter button isnt blocked by its own text but when you add your own it now becomes an issue 
because of thing called raycast
I have UI Elements that look fine in edit mode (Screen Space - Camera) but when I play, they are moved thousands of pixels off screen. Anyone know why this is happening?
double click your canvas in the scene view
it will show the full extents of the canvas
which represents the screen
arrange your UI as such
you should not be arranging the UI according to your game world
Does someone know a solution for the following solution?: I have an Overlay Canvas with Joystick, some Buttons and an image, which works as a swiping-field to look around with the camera. Now I've added a World-Space-Canvas with a button, which I want to click. However, the Overlay-Canvas (The image swiping field) is blocking it.
instead of an overlay canvas for the swiping bit, use a Screen Space - Camera canvas with a high plane distance that puts it behind the world space canvas
(leave the joystick and buttons on the overlay canvas)
Ohh okay, thank you so much!
is there a way or trick to update layout group manually through code I instantiate text elements on it but they have content size fitter on them and last text is always inside of second last my guess is layout group puts in text with default height then fitter expands it but what to do
actually found solution just had to do it next frame + randomize spacing a bit but idk
```IEnumerator Refresh()
{
yield return null;
verticalLayout.spacing = Random.Range(19.99f, 20.01f);
}```
I did this and it works amazing. I have a prefab of an objects with World Space Canvas. When I place a prefab manually, I can click the Button, however when they are instantiated, the Space Screen Canvas blocks it again
can anyone help please?
I'm using UGUI. I have a "hand of cards" and when the player hovers over one, I'd like to have it rendered ontop of the other cards. I initially thought that adding to its Z-position would work, but that doesn't seem to be the case. Moving it to be last on the hierarchy affects its position in the layout. Is there a known solution for this?
One option is perhaps a separate UI element (underneath the whole layout group or whatever you're using so it always draws on top) or even separate canvas, and you basically duplicate the card on that thing and just draw it over the "real" card
For card games though honestly I'm a fan of not using UI elements at all - use spriterenderers and let them fly around more or less in 3D like they do in MTG Arena and Hearthstone
you'll have to write some logic for fanning them out and stuff but it's not that bad compared to the benefits IMO
this is what happenes when I move my button
why does your button seem to have a collider?
Seems you're doing something very strange
what do you mean
Thge green outline is a box collider
should I delete that
why do you have it
and why are you moving it, apparently, instead of the ui button
I'm trying to move the button but it moves that insterad and everytime a make a button the colidor comes with it
how are you making buttons?
Colliders most assuredly are not part of the default button you create through the menu
you need to show your hierarchy and the inspector of the selected object - otherwise I have no idea what you're doing tbh
I press ui > button - textmeshpro
I'm trying to move the button
Ok so show what you're clicking on in the hierarchy
And the inspector for it
1 you're doing this at runtime? What happens when you're not in play mode?
Also what happens if you use the Rect tool instead of the move tool?
sorry about that
It's fixed now
My issue is that this is in a pause menu. I'm wondering how that would work for spriterenderer.
Does someone maybe know this? This also happens, when I just place this prefab during PlayTime
Hi guys, i need some suggestion, i am new in unity, lets say i want to make software in unity,in which i will have tool bars on top and left side, and view port or game view in right bottom side (which is in red in picture attach), can anyone guide me which approach should i use to divide screen and which approach should i use to make buttons on top and left in tool bars
Approach in what sense? You can use UGUI or UI toolkit, but as for how in either, that's just something you need to learn the basics of by following some intro tutorials to UI.
Are there any downsides to mixing images and sprite renderers for UI?
Yes, mainly that sprite renderers can't be used on the UI.
for simplicity, is it recommended to have all ui elements have z position of 0?
bc sometime when i create new object i get things other than 0 so each element has something like 1, 0.333 , -3000, etc
for z value
Might be a noob question, but how can you automatically fit a parents width/height to its children?
I have a horizontal layout group with a bunch of items inside that will vary in number, the overall width of the layout group will change, but the parent object acting as the layout group doesn't get resized accordingly
Is there a way to not do this manually or through dynamic code?
Some sort of editor option
It makes the Horizontal Scrollbar not work properly if the width of the layout group is incorrect
For the layout groups this
but in general, youtube "Unity UI Anchors"
follow up question on this, is there a way to type in the height/width I want the children to be? Because this way the children are based on the width of the parent, but what if I want to make them perfectly square? or perfectly 16:9 ratio? Is there a way to control the size of children elements with a specific width/height?
Cause here I'm just playing an approximation game with the width of the parent element
Hmm, looks like Grid Layout Group allows you to do that but not a horizontal layout group
Ok looks like I figured it out thanks @grave quartz
For a shop youd probably do grid anyways
Could use some advice for post-processing. I have my game camera and my UI camera (Screen Space - Camera) ui.
My UI camera has a higher priority so it gets drawn ontop.
It appears that causes the postprocessing to only be applied when drawing the hud camera.
I only want post processing on my game camera, not my UI camera.
Any advice?
I've tried using layers and that doesn't seem to work.
Under rendering on each of your cameras, the second option is a check box to enable / disable post processing
I've definitely got that enabled.
Whelp, i'm out of ideas
how to make UI elements keep position and size relative to different resolutions, from PC to wide-screen mobile for example or from HD to 4:3 2K
I'm a beginner and this is a very important issue since I want my game to work with as many platforms as possible
I'm using a single canvas to store everything if that helps
had the same issue, but I wanted to apply different post processes to my UI and game, gave up and used the same for both, anyways, if the UI is drawn on top
then just disable post for UI camera
and use post on game camera
and now it will only work on the game
That's exactly problem. My postproc is very different for either layer.
well all information I found on the web didn't help
it was outdated
or not supported anymore like clear flags
anyways you can deactivate post on the UI but that's as far as I could figure stuff out
if you find a fix eventually let me know
I'll do the same
hey, does anyone know if it is possible to have a subscript and superscript on the same level in textmeshpro? example here:
Don't think that's possible no
shame
Hello
Hello all, how are you?
I am a Unity MMO P2E game developer. Now I am developing a new MMO P2E game using Unity.https://vimeo.com/861569495?share=copy
The backend features are mostly completed. I am stuck in front end development.
I tried many UI frameworks/libraries/packages for my game.- https://www.noesisengine.com/
- UI toolkit/UI builder- uGUI- and many more
I couldn't find a proper solution for my game.My only requirement is to make a game UI which looks like Microsoft's Fluent UI.URP or Standard RP doesn't matter.
Could you please recommend what package (which has been maintained by powerful and famous team) could I use for my MMO game?
I would be very grateful if I could get a reply from you. Thank you
This is "bandicam 2023-09-06 00-52-56-176" by JamesWaterson on Vimeo, the home for high quality videos and the people who love them.
Does anyone have thoughts on hiow to approach creatging something like this? Thank you!
Hey guys, when I use TMP input fields in screen space - camera, the function to select highlight a piece of text doesn't work. And i cannot click to change the position of the caret. Instead of changing the screen mode to overlay, is there a work around to get it to work in camera mode?
Ahhh, it was the z-order that was the issue. all good now.
Is it recommended to not work with many decimal values in UI? Like having a height of 1023.754857
or does it never matter
I prefer nice easy numbers. Humbly.
But it doesn't typically mess with your game
Clickable Entities + Disabling Panels On Click Away
how do i change the sorting layer of UI?
my gameover screen is currently showing up underneath the regular ui
is by hierarchy order
the lower it is the more priority it has
So, i have a question about this thing.
I have been designing my app with a reference of 1920 1080.
The app has scalable functionality so the user can make it any resolution they want.
But the default resolution will be 1280 720 and is what users will most use
( the app will always be windowed mode in case that matters )
Should i start using a reference resolution of 1280 720 and edit the UI thats already done or does it not matter and i should keep doing things in 1920 1080?
oh i figured it was but i was expecting higher up to be higher, ty!
hi guys i have a question about views. My simulator view looks perfect however this messes up the game view. If I try to change things to look good on the game view, it messes up on simulator view. Does this matter? should I keep the simulator view?
You can set the game view resolution to anything you want from the resolution drop-down
You should design your UI to look good on any reasonable resolution
And test via the game view resolution drop-down
Thank you
would TMPro related questions apply here?
i feel like it would. so I'm trying to use the Distance Field shader builtin, because i'd like to do an outline on some text. but using that shader, i get this weird coloring in the spacing between the letters when zoomed away from the text (see left two text displays in image below)
If I change the shader to the TMPro/Bitmap shader, it looks fine but then those options for outline go away
i have a timer with two child objects, a background and an icon
how do i change sorting layer in this case?
i dont want the timer to be underneath the backgrouns
The order of the objects in the hierarchy defines whether one is on top of the other. Objects below others are on top
so i cant have them be children of it huh
ah i guess there's no reason it cant be their child
(Children are below their parent in the hierarchy, so they will be on top of it)
can i change TMP's default font?
mostly placeholders, but i feel like this gui is too bare/layed out so far?
reckon i should add some other little things to make the screen feel less square (like the pink lines ive drawn)
or is this okay
Hi all. When I set a canvas to pixel perfect, text renders sharply but moving images are, naturally enough, messily pixelated. When I switch off PixelPerfect, images are smooth but text becomes blurry. Is there some solution that allows for crisp text but smooth images? And I tried using two canvases, but that ends up being fairly awful when, for example, a text box tries to move along with a sprite. I.e., I want anti-aliasing for images, but not for text.
Hey, maybe try out using an other font which is more sharp, and make sure to use TextMeshPro (you probably do already) because TMP is more high quality/sharper
So far I don't, but will try. Thanks!
you dont??? yeah definitley use TMP. I think thats where your problem comes from, espacilly if you text is small the default Text seems blurry.
Yeah, I figured this kind of stuff should work out of the box 😄
But eh, such is Unity.
Looks OK to me. Leave out the meaningless clutter, I'd suggest.
is there any component similar to an image, but with a gradient slider?
I think you'd have to make that custom
Shader Graph might be of help
any like plugin for that then?
i saw textmeshpro has gradient built in
so like
what if i do the stupid route
make a font of only squares
I suppose you can try that. I've got no opinion one way or the other.
Though I know Text Mesh Pro has it's own indiosyncracies
How do I get the scale of my text backdrop to match the height of my TextMeshPro text?
you mean the parent container?
I have it as a sibling right now but potentially.
When I tried to scale it as a parent it would stretch the text.
Usually, to have a box or panel resize to match what your Text Mesh Pro is doing, you have to use a combo of a Layout script and a Content SizeFitter
Feel free to Like and Share to show support for this channel.
Don't forget to leave a comment if anything comes to mind.
Have a nice day :)
#Unity #TextBg #UGui
new unity user here how can I stop my health bar from resizing weird when I change resolution
Google "unity 9 slice"
How can I ensure that a scaling object will keep a distance from the parent border and not expand out when resolution ratio changes?
not exactly sure I understand your question but generally - just through proper anchor/pivot settings
I have anchors set to center, I need the object to keep its size ratio (that's why I don't use stretch). Pivot is in middle
What I mean is that I have an object in the center that scales with the screen size but doesnt stretch. When I drastically change the screen size (like 100x300) the object will have an ideal x size but on y it will be bigger than the canvas parent. I was thinking whether I can make it so that instead it would stay a bit smaller but respect the canvas size.
Whats the best way to change all the Font Assets of your textmeshpro components at once? Is this possible in the editor?
just select all of them at once and change them in the inspector
Where do i get UI design inspirations?
What about learning to make UI?
Or do i just look at inspirations and try to follow them?
Hey everyone.
So I was trying to make some of my UI elements get affected by a global light I have in the scene by changing the material of those images to Sprite-Lit-Default (I use URP).
And it works, but I get this warning in the console and I'm not sure how to get rid of it: "Material Sprite-Lit-Default doesn't have _Stencil property"
Is the Sprite-Lit-Default material not supposed to go on Image components?
EDIT: And I think I have one more problem. It seems like the Mask component no longer masks the UI Images that use the Sprite-Lit-Default material.
Hello, today I opened my Unity project, and suddenly the canvas in my scene was no longer visible. The GameObject "Canvas" is active and present in the scene, but when I start the game and in the editor, there is no UI visible. The last thing I did in my project was to code this shader script here:
{
Properties
{
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white"
}
Category
{
Lighting Off
ZWrite Off
//ZWrite On // Uncomment if you have problems like the sprite disappearing in some rotations.
Cull back
Blend SrcAlpha OneMinusSrcAlpha
//AlphaTest Greater 0.001 // Uncomment if you have problems like the sprites or 3D text having white quads instead of alpha pixels.
Tags {Queue=Transparent}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
ConstantColor [_Color]
Combine Texture * constant
}
}
}
}
}
Could this be related? Can you help me? I would appreciate any assistance. 🙂
btw @supple basalt u asked for the hierarchy of the size fitter thing
its just somethin like this
the menu object have horizontal layout group
I need to see the inspectors for the Menu and for one of the items
the Menu is set to stretch horizontally. It's going to grow in both directions like that.
I think moving its pivot to X=0 will help.
You should reset the pivot of the individual items to 0.5, 0.5
since I think we were messing with that before
lemme recreate this
oh, I see. you have Content Size Fitter on the child.
oh btw in the child it got text
Put it on the parent.
This looks like what you want.
one moment, screenshots
actually, here's something better than a screenshot
the content size fitter on the child is to uhh
make the texts background (the childs from the menu) to fit the text
check this out.
The Menu has a Content Size Fitter. It is set to "Preferred Size" in both directions.
It has a Horizontal Layout Group set to control the child size in both directions
Each child has an Image and a Horizontal Layout Group. It's center-aligned and controls child size in both directions.
Each grandchild has a TextMeshProUGUI component and...I forgot to remove the Content Size Fitter. They don't need that.
Adjusting the font sizes works correctly
My understanding is that you put a Content Size Fitter on the top level transform to make it grow or shrink based on the minimum or preferred sizes of the children
how is the text parents resizing itself without a content size fitter
is the root content size fitter resizes them also
because the top level Horizontal Layout Group controls its height
if it doesn't, this happens
I have no idea why the layout groups don't default to controlling width and height
and instead go on "force expand"
The preferred size bubbles up from the text to the image to the top level
and then the top level sizes the image, and then the image sizes the text
so in conclusion what are the differences between my version and urs
the children doesnt have content size fitter?
import the package and you can look!
it'll add a "Menu" prefab
content size fitter up top. horizontal layout groups that control width and height on the Menu and on the Images.
yeah im looking on it rn i cant tell much of a difference :()
wait wait let me look at it more
ooh
my menu deosnt have content size fitter
Also, the Menu's anchor is [0, 0.5]
The content size fitter needs to be on "Preferred Size" for the horizontal axis so that the Menu widens and narrows
and for the vertical axis so that changing the font size correctly increases the size of the images
The documentation doesn't quite explain these high-level concepts properly
from my experience, at least
no prob! it gets a lot easier once you learn the "rules"
and again, absolutely no idea what's going on here...
lol
Does someone know, how to render a World Space UI Button ontop of everything? I didn't understand the unity forum solutions
for a mobile landscape pixel art game, if you're setting up the pixel perfect camera are you supposed to do something like 1920x1080 reference resolution, 16 asset ppu size, and then scale the assets up? Or should you instead do something like 240x135 resolution to have everything scale at once?
using pixel perfect camera, i mean
does anyone know how to get crisp text?
I tried text mesh pro but it still is blurry in the game view
make sure you're not changing the UI text scale
and that your game view is not zoomed in
how would i unzoom my game view
show your editor please
with the game view visible
there should be a scale slider at the center top
Does anyone have any tutorial on drawing game art with illustrator?
Hey, I have a problem with UI scaling, or perhaps anchoring, hard to say. I have this type of panel around the car, with the orange dots (buttons as children). The issue is, that when I change aspect from 16:9 to either 16:10 or 4:3, the panel breaks and is too small (as shown on the 2nd screenshot). How should I anchor it, or generally do it, so it stays the same size, and the buttons do not move?
Does someone know the problem, that a Screen Space UI Image reacts to clicks randomly? It randomly doesn't recognize clicks/swipes, but when I move a little bit it only sometimes recognizes it again
It somehow works when I set distance from 100 to 10
For example
Probably something blocking it
Maybe, but it also happened after disabling all other UIs
check the event system preview window
thanks its crisp now
but if i launch my game on different screen sizes does that mean the text would get blurry again? (since the scale would change)
No. That scale is just for your game view
If you want to see how it looks on different sizes, click on the Game dropdown in the top left and there should be a Simulator option
That is where you can see diff phone screen sizes
@frank shadow
I am currently working on a Custom Input Manager, but how come one of the inputfields is more grey than the other after I interacted with it?
This only happens every now and then, not every single time
That's probably the selected color for the button
Ooh alright, thanks!
A Unity component to show a camera's render right inside UI!
https://gist.github.com/somedeveloper00/2eb02d976986a3eaff78bd4d97e05b8c
hey! what would be the best way to make a ui like this -> the line is always pointing at the selected objects/ does scale with the distance?
Hi all again. I'm looking for a font that works well at small sizes. Ideally as small as size 8 or less - a big ask, I know 😄 Still, I'd appreciate any suggestions.
Check the Unity Camera API: https://docs.unity3d.com/ScriptReference/Camera.html. You can use WorldToScreenPoint to get the screen coordinates of the scientist in your example, and then you just need to place, scale and rotate an image so it looks like the line you want and connects that first screen point with wherever you want your message to appear. There are other ways, but that's how I'd do it.
my game looks fine with these details
and many other phone resolutions
but breaks in tablets
use premade sprites, usually hire a designer or make something that looks unique
dont use the in program unity sprites for buttons
anybody online that's good with Buttons/Canvas in particularly in correlation to scrolling via keyboard or gamepad?
I have a working Menu for my game (via mouse). The game starts at the Main Menu. Then if I select "Options" from the Main Menu it goes to the Options Menu (when done via mouse). However when I select an option on the Main Menu with the up and down buttons on the keyboard and 'Enter" it automatically starts playing one of the levels that is listed under the 'Options Menu' after it flashes a non-interactable version of the OptionsMenu for a millisecond.
i.e. it 'feels' like I am visually seeing a selection on my Main Menu (which is actively & correctably) interactable via mouse. But if I choose to highlight via keyboard it seems to do a double entry.
TL;DR
Mouse Menu Select = Good
Keyboard + Enter Menu Select = Crazy Town
You should attempt to debug the problem first. Then post the code that suppose to do that with debugging messages.
I'm not ignoring you. I'm suddenly a naked Archimeds displacing water.
#TotalEurekaMoment (I hope)
no matter what i do i feel like i don't like this ui for the bestiary tooltips
right now
green = animal, white = common enemy, blue = uncommon/elite enemy, gold = rare enemy, +star = boss
hello, I have TextMeshPro inside an Image. I'm using Content Size Fitter and set it to Preferred Size to make my textmeshpro size expand vertically to make up for spaces for the text.
But if I do the same for the parent, which is Image, it doesn't expand to make up for the space for TextMeshPro, why? How do I make the parent image auto expand?
Looks fine, just needs a better background
Look up the super mario rpg background for the menus. Thats what i think it needs
Hi.
So I have a code that generates an island using noise and a seed, so far so good. I also have a UI button that calls the method to generate the island when I click on it so that I don't need to exit game mode when I want to change values for the generation.
The problem comes when I add a seed to the world gen: if I give the seed normally, outside of play mode, it work as intended. But once I give it (the same seed) on play mode and use the button to re-gen everything, I get very weird results.
The first image I'm giving the seed on editor mode normally. The second image I'm giving the same seed, but clicked the button to regen the world.
Is this the button's fault?
My only guess is: because the land is still the same, the problem is with my water level detection, which is in another class (that inherits the Tile class)
And for some reason using the button is passing the wrong values to my water class
(btw, do I send this here or to one of the codes channels?)
Better off posting it in the coding channels, and with some code to work off of for where you think the problem persists as one could only guess what operations you're doing to achieve this.
hello guys, want to make a menue for a game for ios. what background size should i use or how can i make it so it adapts to the screen size of the user
i'm not seeing anything specific?
is the main thing a boarder?
Like this with the muted shapes and a scrolling background nothing too flash since its not supposed to be distracting of course https://youtube.com/clip/UgkxojArYhNLvlBKPRN-kITzelnh4pX1hqaA?si=fAlWWE0Nff82EDCh
26 seconds · Clipped by Sofern · Original video "Super Mario RPG Legend of the Seven Stars Full Walkthrough NO COMMENTARY" by AMHarbinger
Forgot to @meager quartz
these are just meant to be popups when you mouse over something so i'm not really sure how to apply the ideas in this video to them
did try something with boarders, though
Oh okay, i think they look good, i like the colored border in the middle and just color code your boxes for things
but how can i scale/ stretch the image to exactly point at the target, tried it but can't manage to get it working
How can i have these 2 things to match ?
specifically, i would like the size inn the canvas rect transform to be 1080/2400.
i have the following canvas scaler
Calculate the distance between the screen coordinates of the scientist and the text box, then set the scale of the recttransform of your line element to that length. The position of the image should be on the halfway point between the two coordinates, you can get that one through Vector2.Lerp(scientistScreenPos, textBoxScreenPos, 0.5f). As for rotation - that's trigonometry; can't do it off the top of my head, but https://en.wikipedia.org/wiki/Trigonometry should serve you well.
Trigonometry (from Ancient Greek τρίγωνον (trígōnon) 'triangle', and μέτρον (métron) 'measure') is a branch of mathematics concerned with relationships between angles and ratios of lengths. The field emerged in the Hellenistic world during the 3rd century BC from applications of geometry to astronomical studies. The Greeks focused on the calc...
your reference height and width are reversed
Hey all. Beginner here. I am trying to enable glow on mouse over on my main menu buttons. Cannot seem to get it right. Is this the right place to post? or should go to code section?
hello, how do obtain this Pos Y value through script?
oh yes it is!! Thank you.
whew, it doesn't start from 0 but from random negative value.
im using vertical layout group
but when I start the game
the position looks kinda weird
the problem looks like fixed when I disable and enable that canvas, can i know why and how to fix it
How do you determine where to put those bars above the slime. Does each slime have their own bar or do you move bars into place?
how does anyone know why UI graphics disspear when camera isnt focused on it?
Elaborate im not sure what you mean
every UI gameobject on that pic determine by this Component
i havent used scripts to move bars or text
Hey all. I have two materials. One is normal and the other is just glow. When I put it on my play text. It disappears on canvas. What am i doing wrong here?
Sorry to barge in but I am using a Canvas with the Render mode on Screen Space - Camera, so that I can use a Canvas Image with Scroll Rect, and also use a Line Renderer in the same space. I have been able to set up the Sort Ordering to show both the Line & Canvas Image together, which is great!
However, the Line produced by the Line renderer is just floating in the same position on the Game screen, not moving with the base Canvas image when I scroll in it. I set the Line to be a child of the base Image, but no dice. How can I anchor the line to the image?
I unchecked "Use World Space" on the Line Renderer
Problem solved
only thing I dont get is the x position index of the line i'm using, it is incredibly large
I don't get how it's related to the camera space
scale was off, as usual
heh
radial slider
How can I make it so my content area scales based on all the items?
layout groups (vert/ hori), with some flags ticked (I forget off the top of my head) and content size fitters
yeah i got content size filters to work thanks but how can I make the rect scrolls scroll always stay at 0? (im just duplicating the shortcut element)
i found out its not the scroll its the contents position
Make sure the content game object is resizing correctly for the contents
What would the bit be called, where you have to press a key within that area of the slider
Hi everyone 👋 - I am wondering what is the correct way of building a menu system for a game - is it to have a 'scene' for each step in the setup of a game? And is this best to build entirely with UI Builder? Thanks in advance
(I was reviving an old game i made 10 years ago and everything is different now in unity so i'm starting from scratch)
I've linked directly to the UI revelent part of this video, but the whole vid is useful
https://youtu.be/_wxitgdx-UI?si=g8QRpSCSA3BwTrYd&t=1410
i gave a gameobject the button component and still cant click it
Is it in a canvas? Does it have a Graphic component (such as Image) on it as well? Is there an EventSystem in the scene?
what do you mean?
How to make "these" maps, like in malls
There's gotta be something on that on youtube
go on photoshop and do it or any other photo editing software
You need too do it (probaly) youreself
I know that, i just have no idea how to do it
Thats why I'm asking
When you have a idea why dont you make it?
You can do it on https://www.photopea.com/
its like a free photoshop version
Photopea Online Photo Editor lets you edit photos, apply effects, filters, add text, crop or resize pictures. Do Online Photo Editing in your browser for free!
thanks i'll try that
No problem
Oh now i have an idea
I could create a simple 2d image using rectangles with colors, 3d rotate that and then just add text later
that should work but i dont know if it looks good
if it doesnt look good i can make one for you
@pine ginkgo i made a custom logo
Does anyone have an creative ideas on what i could do for physics
like what icon
Right
an atom
literally the first thing that comes up when i google "physics"
This is really good
Hey, I've been stuck on this... for like half an hour already.
Basically, I want the text to start from the bottom, and not from the top.
To my understanding, Vertical Layout Group should fix this.
I tried to replicate exactly what this guy does in the video in about 4:25.
https://www.youtube.com/watch?v=0QPIhCFWkAM
But the text just wont go to the lower left, or anywhere else, no matter what (anchors dont work too)
In this video I will walk you through the setup and implementation of Facepunch.steamworks for Unity. By the end of this video you will be able to start a lobby using steam, and have other friends connect with a lobby UI set up with chat and ready up functionality.
Can some UI guru help me?
I think changing the y pivot to 0 does it
Nope :(
Oh, wait a second. I think yes.
Now I was able to drag the text to the bottom.
Yes, that was it, holy cow
Thanks a lot!
You're welcome. Glad it worked
Is there any way to load a TMP SpriteAsset object from an assetbundle? The ways I have tried don't work because the glyphs don't load with the object probably because the texture and material don't either.
Hello guys. I tried to change the resolution of my canvas by using the canvas scaler. Did i do it right? Will it now display in 6907x140140?
The reason im worried is because as you can see in the scene that my canvas is a lot larger than the actual display, and i have a lot of blue background in my game scene
no, the reference resolution on the canvas scaler doesn't actually change the game resolution
all it does it change the numbers you are working with in your RectTransforms
The actual canvas resolution is determined by the game resolution
If you wish to change the game resolution use this dropdown on the game window
Ok then.
As i see it ialready have the free aspect with my intended resolution on in my game window. So did i do it correctly?
Free Aspect means that it changes with whatever your window size is
open that dropdown and select the actual resolution you want
Hi, I try to change sprites when user location is Japan, because they switch submit with cancel, and I want switch sprites for gamepad, I use
sprite.spriteCharacterTable[0].glyphIndex = 1;
sprite.spriteCharacterTable[1].glyphIndex = 0;
but sometimes it works, sometimes not, and I don't know why 🤔
Did someone also have the problem yet, that an orthographic camera causes game crash? I use it as MiniMap and when enabled, it freezes the game, music is still playing
hey guys, this might be kindof a nooby question but I'm making a multiplayer game and obviously the player has a HUD, I have multiple maps and my hud has to be the same on every map.. but when I change something in the hud on 1 particular map, it doesnt always apply to all the maps.. I'm sure I'm just not using the right workflow, how should I go about making the hud?
Use a prefab
is there a way to keep that snapping functionality when you rotate image or any element tbh Ive got image which needs to be rotated 90 degrees but I cant snap it anymore afterwards so I gotta go make a duplicate which would be already rotated
I have this kind of GUI layout where I navigate to various screens by clicking different buttons. Works well for touchscreens and mouse.
But now I am trying to make it work with keyboard/controller and having a hard time keeping track of which button on which panel is currently highlighed/selected so pressing ENTER key or X button triggers the event.
What's best practices on creating a GUI menu screen system like this that works with PC with keyboard and/or joystick?
Yo, I have 2 scripts attached to a correlating “UI Manager” gameobject for each. It’s a dealership so the first script sets a carSelectedString to the given brand and disables the panel that shows the car brands. My 2nd script takes in that string and uses it to initialize the prefabs for that car brand. The problem I have is the initializing script gameobject is set to off when the scene starts because I want to use “onenable” and “ondisable” functions. But I can’t inherit the selectedBrand string since the gameobject with the first script gets disabled on button press. So I can’t use findgameobject when the 2nd script manager gets enabled since the other ui manager gameobject is disabled
Anyone else have an issue with unitys anchors resetting after ANY input at all? like i move my mouse 1 pixel and it resets. Tried looking it up on google and nothing related to the issue appears
https://www.youtube.com/watch?v=--LB7URk60A&t=2s&ab_channel=GameDevGuide
hey guys, so i was following this tutorial but the "graphic" class at 1:59 isnt recognised by unity 2021.3.19f1
people said to add a canvasRenderer but it still doesnt work
can anyone suggest a solution? Thanks
Unity's Line Renderer Component doesn't work in the UI system... So, let's create one that does...
Interior Mapping Shader - https://www.youtube.com/watch?v=dUjNoIxQXAA
Photo Real Assets - https://www.youtube.com/watch?v=Y538_YYhC1A
Fixing Grid Layouts - https://www.youtube.com/watch?v=CGsEJToeXmA
-----------------------------------------------...
For context, im trying to make a realtime graph for a physics game in unity. It should show a value against time
use a recycler view
something like https://github.com/framg/RecyclerView-for-Unity
what?
The lag spike is from creating 100 elements in a list
that's a lot of GameObjects
recycler view gets around this by not creating that many
it only creates enough to fit on the screen
yes and a recycler view gets around this by only having 20 items period
Have you profiled the game yet
you say this but you also say
i have a scrollview with hundreds of items
so it sounds like you have hundreds of items in the view, not only 20
How does that mean profiling doesn't work?
If you used the profiler and determined that the scrollview itself somehow is the issue, that's the profiler working
I still don't see how that means profiling doesn't work
the point of the profiler is to identify the source of the slowness
if it identifies the source of the slowness as being the scrollview, then it has done its job
ok so I have already suggested a replacement
it's a complete rewrite
and if you want to get to hundreds of elements you're going to HAVE to solve the scaling problem ANYWAY
so your pool of possible solutions already is going to include only different variations of a recycler view
in all this time debating you could have tried this out
This one i linked was just the first implementation to pop up on google
we already know default scrollview isn't going to work when you scale up
you're going to have to rewrite things
but it really shouldn't be that hard to switch
refactoring/rewriting code is a normal and expected process
there's not going to be some magic "run faster" button on ScrollView
Hey everyone.
So I'm using this line of code to update the position of a rect transform in my scene which acts like my cursor. It was working perfectly but for some reason today it's putting the Z position to the plane distance from my canvas multiplied by 100. I have no idea why because I set it to 0 in my script...
The z position you pass in there will be the distance from the camera
So 0 means at the camera's z position