#📲┃ui-ux
1 messages · Page 18 of 1
Top is Figma, bottom is Unity + TextMeshPro. The kerning is wrong in the Unity text. What the heck. Any idea how to fix this?
Does anybody know how to make a kind of "Mask" to make other objects invisible under by Slider's full rectangle
so the Move Interval text shouldn't be visible at all
Hey so I am using the new input system and I can't get the controller to work correctly.
The issue I have is , the first Selected button is in this perma selected state and if I scroll down all the butons just seem to go in this selected state but the mouse works fine
is there a differerence between highlight and selected? It seems the mouse highlights but the controller selects
If you have multiple controller types going on, maybe disable the other when it's not actively being used
Ya I can do that but that does not solve the issue I have.
Can the controller do the highlight state or is that just a mouse thing ?
It's probably the eventsystem taking input from both devices is what I'm guessing
And yeah, you can scroll through UI elements usually with the event system for general control types without any setup
Alright and there is no state difference between highlight and selected?
Where can i get fonts to use in my games that are free?
Google fonts
Archive of freely downloadable fonts. Browse by alphabetical listing, by style, by author or by popularity.
I don't see a single buy button on the google fonts page
I just click and it downloads
same with Dafonts
I am using fonts from Google currenlty
Alright but on dafont sometimes i do see a license file
then skip those 🤣
lol
🧠
BIG BRAIN!!!
TMP has fields on the component to change the letter/ word kerning
Yes, but those are global settings. The problem is that the way it applies kernin is wrong. With the word "Text", the "e" should tuck under the "T", but TMP doesn't do that. It looks at the bouding box of the "T" as the kerning size, which is just wrong
Yes, but those are global settings.
No they're not.
Don't think I've ever seen a font in Unity with that level of attention to detail
Isn't Te and fi etc. glyphs of their own in some fonts? That might work
Which settings are you referring to?
That's interesting, I didn't know that. So maybe this is a font specific problem?
It happens with other fonts too
This doesn't fix the problem, the "e" is too far from the "T", regardless of the letter spacing
Hey there guys! i have an issue with setting up a tooltip ui element to show and hide when the mouse is hovering over buttons
basically i have a script that animates and shows the tooltipUI for buttons on mouseHover enter and exit and my issue is that when i hover over the buttons the tooltip appears and keeps flickering uncontrollably, idk what i'm doing wrong i tried changing the script around but i really can't seem to find where the issue is, anyone can help me with this? :((((
here's the script for the buttons, all buttons have this script with a onPointerEnter/Exit and all they do is if the mouse is hovering over the button it sets the toolTip.SetActive to true or false
My guess is maybe the raycast is hitting the tooltip partially which is also accepting raycasts
otherwise the scale method is somehow interfering
Yeah i was guessing that the scale is doing something like maybe the button size increases to the point it touches the tooltip and interacts with it somehow but i don't know how :(((
Also i got a fix for it (not really a fix) but when i remove the HideToolTip() function from the OnPointerExit the tooltip does not go away anymore but the flicker stops
So maybe it's something that keeps making the button show and hide the tooltipUI constantly but idk what is causing it :(((
Have you made sure you disabled raycasts on the tooltip object?
Not really, how can i do that?
Do all ui elements have raycasts on them by default?
There's a raycast target boolean on the UI objects usually
and canvas groups have a blocks raycasts boolean which mean it accepts raycasts if true
Oh i think i know which one, you mean the raycast toggle on the inspector on certain ui objects right?
So just toggle it off?
Yeah, try that
I will try that thanks for the advice bud! Maybe it's just the tooltip raycast hitting the buttons like you said or the buttons hitting the tooltip when scaling!
Best to try debugging the event system and checking each frame what the mouse pointer is over if the problem persists.
@soft sail hey bud, your advice was correct i actually forgot to toggle the raycast target of the tooltip ui off so it was registering in the onPointerEnter/Exit :DDD
thanks for the help :)))
Where do people get hired as a game UI designer? Cause I'm trying to freelance UI
Join various freelance sites like Upwork. Otherwise, just search job postings online or on studio websites directly. Finding a job in game development is not easy.
Hey folks, trying to figure out the best way to handle user interface. Currently the problem is minor in that it's inconvenient to modify UI/work on it.
The problem is that some UI elements need to be hidden, or alpha set to 0 to fade in, etc. I'm not really sure of a good way to go about it to make developing easier? If that makes sense?
I guess what I'm trying to ask is like.
What is a good way to move forward in terms of UI organization? Should I Instate UI elements/sub menu? Should I do something else? Im not really sure?
im new to this server, and just wanted to get some feedback!
If editing and working on UI is the issue, it's easier to have it in scene and just toggle the canvas on/off as needed.
You can even write a small custom script to create a hotkey that toggles the canvas of whatever object you have selected. Drastically makes it easier than clicking the enable box.
The main problem I'm running into is we have Canvas's that are Alpha'd 0 and or Disabled Gameobjects. (Or Alpha 1 / Enabled) I always tend to forget to revert them. Its just kinda clunky/messy is all and I'm unsure of a good way to handle default values.
Decide how you want to handle UI that isn't visible and go through the pain of making your game uniform with that rule.
For example, we only turn off the canvas or if it's a canvas group, turn off the alpha. In the case of a group we have a custom Canvas group component that we call SetAsEnabled() on.
This allows us to do things like turn off the interactive property of the group. So you don't have to worry about doing that from whatever is telling the group to hide itself.
Alright thanks
Hello, I found that someone had a question exactly the same as mine, but I couldn't find an answer in the community. Any ideas? Since I need several types of sizes, I have to do things like what you see in image two. I don't know if there is a way to use tiles and thus create my UI boards in the sizes I want
I mean, instead of having to create each of the images. There is no way to use Tiles but on Canvas? Or would it be inefficient?
Hi, I'm making my very first UI component and am a lot more experienced on the coding side of things. is my canvas and panel supposed to be this size and shape by default? I was following a tutorial and it resembled the shape and size of a monitor by default. I'm not sure how to adjust this.
It's not the size of your PC, it's the actual size of your game view.
got it, thank you
So that you don't have decimals or the numbers change all the time, I recommend setting an aspect ratio as I already had.
Hey, idk is it good channel, but I have a question regarding canvas. I want to place background image in Canvas(so it doesn't move) but is there a way to move it behind all the other sprites?
you need to be specific about what you mean by "sprite". A sprite in Unity is an image asset. They can be displayed in the game either via a SpriteRenderer which is a world space object or via UI Image which is a UI element.
I want sprites with SpriteRenderer to be drawn at forefront
and the image that is in Canvas to be behind them
You will need to set your canvas to Screen Space - Camera mode or World Space mode
In screen space - camera, just make sure the Plane Distance of the canvas is further from the camera than the SpriteRenderer
Thanks
Hey but if I try to do it with World Space, then it is not visible, independently of Order in Layer being 100 or -100
Don't use world space
If you want world space you might as well just make it a SpriteRenderer
Hello, is it possible to have child of Vertical Layout Group be in different height?
I tried to add Content Size Fitter to the child but, unity complain that it should be the vertical layout group that control the size. But I can't find any setting that can set individual height in the Vertical Layout Group.
I think I misunderstand what Content Size Fitter supposed to do.
Content Size Fitter will resize the rect to be the size of the content on this game object (eg an image)
Put a Layout Element on the object you want to be bigger and set its size
yes yes perfect!! thank you very much.
potentially an options menu or icon to allow players to change settings
really clean i love it!
the only suggestion i could give you is that the leaderboard text looks like a unique button that the user could press
i would make it more of a 'title' then a button representation
apart from that looks great
If I wanted to display a cost of something, along with how much of the currency you have.
What would be a good way to display that information?
Cost (Currency)
Cost/Currency
Currency/Cost
etc?
Thank you! I never thought that the banner could look like a button, I'll take that into consideration
honestly for most they probably wont see it that way
just popped to mind, only minor feedback tho
great job<3
Thank you again!
I've got a dialogue box that I want to work in both landscape and portrait mode, but I'm not sure how to do that, any tips?
hello
anyone knows why am i not able to interact with UI Buttons, im using cinemachine free look camera, i think that might be the reason, but dont know how to fix it
u want me to screen share? idk where would i upload a video
you can upload a video to discord
its only like 25mb limit
The video is gonna be like 10 seconds long, if it's 25MB you've done something wrong
Use shareX to record, and if it IS too large.. then use handbrake.fr to convert and compress
also one of the reasons ui buttons dont work is because of no graphics raycaster, do u have that on ur canvas?
Are you using the new input system ?
I haven't used the new input system yet, I know it needs a different setup than the old one though.
You could set to using "both" in Project Settings -> Player.. but that's a quick / dirty fix and you're prob better off finding a tutorial that shows how to set this up correctly
it was already set on both
d'oh
somebody said to run game click event system and check in bottom of inspector what my click is hitting
but for me it seems its not hitting anything
I'm 99% sure it's because of the new input system and you've not set something up correctly/ at all
i made new clean first person project
doesnt work again
and it doesnt even use new input, and it doesnt ask me to install it
but now in event system it atleast shows something
and... What happens?
Is your code running? Any exceptions being thrown?
How do you know the code is running?
Update not running means your scrip[t isn't attached to anything or the object is deactivated or the script disabled
or you didn't put Update in the right place, or spelled it wrong
The order of your methods doesn't affect how the code runs
I might be missing something simple here but why is the orange sprite visible through the green one even if its behind it?
UI render order is based on the hierarchy order
I have a scroll view populated by Buttons. It works fine, you can press the buttons but also drag to scroll up/down. The problem is these Buttons also have another component on them that implement the OnDrag events. This makes it so that you can drag on the buttons to scroll. Is there any way to disable the OnDrag events without disabling the component?
Ok I could change that but the card has a flipping mechanic and if it flips it should show the orange one and if it flips back only the green one again
You'll have to either:
- change the sort order when flipping
- do it with a shader
- not do this in UI, instead use sprite renderers
Or some other way I haven't thought of
I have an inputfield (TMP) that calls two functions whenever the value is changed Filter() and CheckLength() to ensure input is the proper format. When I change the value of the the input field via script it causes a stackoverflow. I feel I am missing something, how cna i avoid the stackoverflow?
Sounds likely that you are changing the value in one of these functions, and also one of them is assigned as the OnValueChanged callback or whatever
so you change the value - it calls the function which changes the value, which calls the function again, until you get a StackOverflow
yeah that seems right... but why isnt there any error when manually typing into the input field... shouldnt the same error occur?
The typical workaround is to set the text like so:
https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TMP_InputField.html#TMPro_TMP_InputField_SetTextWithoutNotify_System_String_
not sure without seeing your code
and the callbacks that are set up
yeah i think this should work
i will try, thanks!
it did in fact work :)
Hey, Im trying to find out why my inventory ui isnt being registered by the events system is there something im missing?
Its got the graphics raycaster and all the drag and drop event interface scripts in it but for some reason it wont even register my clics
Is there a way to import a video as a UI element? I've created a short 2D keyframe animation that has transparency in blender and want to use the clip during scene transitions.
fixed this it was the canvas group
i needed to turn on "blocks raycastss"
i needed to TURN ON BLOCKS RAYCAST for my MOUSE RAYCAST TO REACH THE ITEM
HOW DOES THAT MAKE SENSE

Because if your image doesn't block raycasts, it just lets them through
Hahaha yeah I thought the same thing. It's not that intuitive but it makes sense.
hey
so i have NPCconversation UI (opens up when i press E to talk while nearby an npc)
I have inventory UI (opens up when i press "i" anywhere on the map ofc)
- So if i press "ESC" mouse cursor will show, both on NPCconversation UI and inventory UI, but
with inventory UI i wont be able to interact, but with NPCconversation UI i will be able to interact.
NPCconversation UI doesnt work at basic NPC interaction, it will only work if:
Info 1.
and Info 2.
are active
Then, IF NPCconversation UI is completely disabled from scene, i will have normal function of inventory UI (pressing "i" and inventory opens as well as mouse cursor and i can interact),
- IF im talking to NPC (NPCconversation UI is open), and at the same time i open up inventory UI, i will be able to interact with both UI with no flaws.
1 more thing if i put NPCconversation UI sort order from max to 0 (under inventory UI sort order)
only thing that changes is that inventory UI mouse cursor wont show on opening inventory.
.
so i guess whats going on here is, inventory UI wont work if NPCconversation UI is not open, and <<<<
NPCconversation UI wont work if inventory UI is not open
i really dont know how to handle this pause menu
most of it is functional now but i feel like there's like way to many different types of buttons
looks fine to me
How do you stop Unity importing a sprite at at ludicrously low resolution? It's taking a 980x181 png banner and smashing it to 64x16. Google has been no help. All stuff like turning it to RGBA 32 bit is polish the 64x16 turd. I've not had this problem before and I can't see why unity hates this image so much
try setting the Texture Type to Sprite. RIght now it's Default
Tried that. Does nothing. It imports at 64x12 and stays there
All the usual "make sprites gud" hints on youtube or google assume that the image hasn't been stomped into the dirt
Like Pixels Per Unit do nothing if there is only 768 of them
Here's what it looks like on disk
That's what in the asset folder. For some reason Unity wipes its arse with it before showing it in edior/engine.
Import as sprite
Texture filtering to Point
Compression to None
How do you import as a sprite? I've just dumped images into the asset folders and converted them to sprites and never had this issue.
Import just imports the image
You set the texture type to Sprite in the inspector
BTW make sure you're actually using a UI Image and not a SpriteRenderer or something else
Show the inspector of that object in the scene
yeah and it's lying
This is a different filename, no?
Unity takes that image and shoves it up its arse
I've made diffent versions. It does the same thing
what's the actual size of the image? can you show? @zealous dove
Set ppu to 1?
It's not just this image. Unity is kicking the crap out of any image I put in it
Oh wait
That info message looks quite suspicious
Check the build settings window
for what?
Max texture size
Weird, does it fix things?
WTF changed that? I
Maybe by accident? Little brother? Cat?
Guys. I have a series of custom Selectable objects I'm instancing by code, and I have a single button elswhere in my scene. How to prevent the button click from deselecting my Selectable instances?
Trying to make a simple text based scrollable menu (selectable text and events)
I found this tutorial but is this overkill?
https://www.youtube.com/watch?v=l2_rHUffkJw
This tutorial covers how to create a Unity UI SrollView that will auto scroll to the selected item within the list to keep the selection within the viewable mask of the ScrollView.
Example from a game, it has to loop around etc.
Same as tutorial but is tutorial too much?
AudioManagerScript: https://paste.mod.gg/cgwrljgljjtv/0
A tool for sharing your source code with the world!
GameManagerScript: https://paste.mod.gg/bytvlzgqjwit/0
A tool for sharing your source code with the world!
Thank you
Hello. I cant detect clicks on my empty gameobjects.
I tried with tags, and == name. Its a 2d game so i made sure Z value is 0. I gave it a high value for "order in layer" I tried with a custom sorting layer. I tried to give it a higher value layer in the top of the inspector under layer. I tried with and without is trigger. I tried giving it a rigidbody for no reason. I tried separating the scripts, and make one for the triggers only with tags, and tried another one with == name. However this is not advised for my script. I checked Layer collision matrix. All is checkmarked.
I have written this functionality in so many different ways. This time i coded everything inside the same onmousedown function, however only the VA and BA onmousedown are registered and im utterly confused.
Setup: All my main objects VA/BA have the script on with the correct public variables dragged into the inspector. I tried giving the script to the empty gameobjects as well for no reason.
Please help. This is for my exam
A tool for sharing your source code with the world!
hi i have maybe a dumb question but can i take every single composent of this picture with unity if yes how?
Can you "take" it? Wdym?
i want take any composant as a individual sprite it is possible?
without using photoshop
Unity is a game engine not image manipulation software
Are you trying to rip off an asset or something
nah i just found that free asset on google and i cant use it
Is there someone proficient here that could help me out? I've gotten pretty good at UI layout but I'm getting stuck on this issue. Below is a diagram of what I'm trying to do with the basic hierarchy. Essentially I'd like the HUD elements to remain close to the middle since I'm developing a racing game and can't have it too far from center view, but I also don't want it to be the minimum of a 1:1 ratio (only if necessary). So I'm looking for a min width that can expand up to a certain max and then not surpass. I've tried a layout element, content fitter, aspect fitter, and other method to no avail. Any help is appreciated.
If it's free why can't you use it
Hi I am not sure if this is the right place to ask. I am testing or about to test the HDRP when I discovered the Render pipeline menus missing in my menu.
I dont know so
bump
Horizontal layout group with layout elements
Can I ask questions about TMP here?
I have an issue where the text is showing up if I have it in a hierarchy but not when im instantiating an object with it, the only issue is that the text isnt visible as its outline is visible in Scene view while the instantiated object is selected
- Which flavor of TMP are you using? UI or non UI?
- If it's the UI flavor are you instantiating it inside a canvas?
not sure how to check my current setup since I tried copying it to an earlier TMP object that did show something, but I was using non UI TMP before. I'll try adding a canvas before as a parent
If you're using the UI form, it needs to be in a Canvas
and if not?
then it doesn't
because the problem persists if I put it in a canvas
I dont know TMP well so I'm trying to find everything that a newb could miss
I set the Z pos of the object to be -0.14 since that was the Z pos of the one on top which works
I put it on the layer that every other active part is (the grid in the background isnt part of that)
I set the Sorting layer to that of the player aswell, I just want to know why its not showing anything
You have to instantiate the correct TMP to the correct place.
So if it's UI TMP, then you need to use that TMP UI component and instantiate it as a child of a canvas.
If it's not UI, then instante the non-UI TMP not on a canvas.
Also, have you imported the TMP essentials ? You get a popup the first time you have TMP in a scene
I've used TMP before so I'm sure I have the essentials, I was just moving the TMP object to the canvas so that might be it
If it's not a UI TMP - > this will probably put it behind your game
I mean it worked on the non instantiated prefab (which also has no canvas, which is why im so confused)
We're poking around in the dark here, show a video
That's a non-UI TMP on a canvas and set to Z pos -0.14.. it's behind the game background
See how it has a MeshRenderer component
No
how does this render though?
And the Z pos matters
Can't tell you from the information provided
first is negative Z, second is positive Z, not on a canvas and wont render
The X/Y pos of the one not showing is also probably off screen too
you can see from scene view that its directly over the other text, theres enough space there to show it
atleast I think what its showing is related to its deviance from the parents position
Canvas space != scene space
this means its position is at -956x and -539y from the center of the canvas, which could easily put it off screen
which object is that?
I'm building atm which , for some reason, is slowing input in Discord.. this msg was typed/ sent just seconds after the last vidso I hadn't seen it
ohh ok
Do a test, instantiate the TMP that can't be seen .. then hide the grass background
If we can see it, then it's behind the grass
If we can't, then it's a rendering problem on the TMP
then its a rendering problem on the TMP (I know this doesnt say much, but I instantiated a second indicator and disabled the Grid object)
Is a material assigned?
yea, it has the same name as the Font
at this point, I'd just remake a new one
right mouse click -> 3d -> tmp
I disabled everything except for player(with camera) and Dummy(which holds the TMPs) and its not showing
If you put it in the scene at edit time .. does it show
edit time?
oh it doesnt for once
2d game isnt an issue for 3d tmp?
since unity is basically 3d animway?
nope
yeah ok
does this change anything?
that it doesnt, but it did before with the previous version of the prefab
when did you last relaunch Unity?
like an hour ago?
was this an issue before that?
yeah
I had to restart my PC because it was lagging and basically my GPU crashed on unity (I need to clean my system sometime)
go in an empty scene and create a new mesh TMP
the mesh TMP shows text in the new 2d Scene
though I'm pretty far on the scene im working in, so restarting should be a last resort
It's just a test, not heading to a suggestion of restarting
open both scenes (just drag your scene into the hierarchy now) -> if this new TMP still works -> drag it into your scene
it works when I drag the prefab into the scene, but not if I instantiate it via script
have you googled "unity TMP doesn't show when instantiated?"
there arent alot of solutions, and most of them seem to tackle different issues.
For example someone on reddit writes that the Textmesh logo appears but not the text, in my project we have the outlines atleast
someone on the forum seems to have had issues with the z axis, which I've tested for both positive and negative
someone on stackoverflow said that they had just not configured the prefab correctly, but my values are all the same
For example someone on reddit writes that the Textmesh logo appears but not the text, in my project we have the outlines atleast
This probably just means they didn't try selecting it and/ or didn't mention this info
I really dont have the time to look into fixing this so I'll leave it for now, but just so I have something to maybe hold onto - Can you somehow fix TMP in a scene? like tell it to repair it, or add TMP anew? I think thats missing since now every TMP that I add, even in edit, doesnt show text
I have an in-game computer screen in my scene - am I best using TMP(UI) on a Canvas for the text on that screen? Or TMP with a Mesh Renderer? Or something else please?
World space canvas with UI elements
Or a screen space camera canvas and a render texture on a quad mesh
Thanks @mortal robin, I currently have it set up as World space canvas with UI elements. I'm trying to change the text to another Material Preset, but no other materials are showing up in the drop-down other than the font's default material. Any idea why that might be, please?
Did you create any others?
Yeah a few just to be sure. Duplicated from the font's default.
You can always drag and drop from the project window. The Dropdown is not the best
Won't let me do that either, I must be going wrong somewhere, but can't figure it out.
What exactly are you trying to drag and where are you trying to drag it?
The Atlas Material from inside my font asset
I'm trying to select it (or drag it in to) the TMP object's Preset Material drop-down
I'm not actually that familiar with Material Presets. Have you gone through this? https://learn.unity.com/tutorial/textmesh-pro-working-with-material-presets#
Yeah I was following that when I ran in to the problem actually! 😄
Hey, does anyone use any UI libraries? Has anyone contacted coherent and knows how much their gameface costs?
Having the UI in HTML seems quite amazing haha
If I have a bunch of UGUI TMP text and sprite logos in a horizontal line, is there any way in the editor to multi-select them all then centre them (so the whole group is effectively centred as one line of text/logos, not so each item is centred)
Best I've got is to multi-select then drag the box over all of them until its pivot icon is over the centre of the screen.
But that assumes that the right-most bounds of the right-most text element exactly matches the end of the text (which it probably won't with different length words)
Thanks for your help earlier @mortal robin. It turns out the issue was naming conventions. The font material has to start with the name of the font, otherwise it won't recognise it for the drop down. Silly really 🙂
I have a text box full of replies based on what is said. I have it auto size with the horizontal layout group and such. However it expands from the center as the reply text grows and if big enough goes off screen because it is so close to the right of the screen. How would I go about locking growth to the right but still expanding to the left as the response text grows?
Make sure the anchor is on the left
I want to have a UI where the Y size of the rect scales with the amount of items in them. So if a screen is wide screen, more text will fit, so less lines are written.
This also should be scrollable.|
No matter how I combine scrollables with the vertical layout groups the worse it gets. Can someone point me into the right direction?\
I have a text mesh pro element that holds a large chunk of text. formatted as follows
<u>Header</u>
Body text (10k+ characters, no underlines)
when the body text is <~10k characters (9,390 in one case) there is no issure
but when the body text is >16k characters (maybe like 30k?) I get index out of range pointing to DrawUnderlineMesh... if i remove the underline from the header, it can handle all 30k characters with no error
IndexOutOfRangeException: Index was outside the bounds of the array.
TMPro.TMP_Text.DrawUnderlineMesh
in this thread it says i need to make a change to TMPro_UGUI_Private.cs but i dont know where to find this script
Thanks. I had not looked for that... It is a lot simpler than what Chat GBT was telling me to do lol.
Okay, another question. I have some text that I have an animation to scale it up and down for being selected. However, I see that the longer the text, the more it grows which would eventually end up going out of my dialogue background with enough text. How could I have it only grow to a max size even with increased text?
Hey all, I'm just wondering how we're supposed to generally work around uneven UI panels when creating borders for sliced UI objects?
I can't quite make it so that this thing doesn't skew somewhere when set to slice.
(Same problem applies to these oddly shaped buttons with their faint zig-zag pattern)
You can't, I don't think 9-slicing is relevant to such shapes, especially with backgrounds like those
Okay! So the best course of action is probably to make them to-size?
Yeah, or you'd have to do something complicated and make the meshes yourself, which isn't for the faint-hearted
Oh wow coherent charges 5500 per game per seat for using their UI library
Thats so much more than I would have thought haha
Are there any other ways which are not to fiddly to use html/js?
how come they charge that much? Do they have to provide a huge support to make it work so it only makes sense for them to make it for huge game studios?
How to batch together UI elements that are in a different hierarchy level?
They are atlased already
I have these two elements on my canvas and everytime i open my project it moves them just slightly out of screen. This has been happening for 2 months now consistently so its not just a one time thing. How can i fix it?
Wouldn't it be enough to just tick the "preserve aspect" on the image component?
This would make it so that the border lines for example will become thicker or thinner as we resize, unless I'm misunderstanding what you mean.
I figured I'd just have to make them the exact size I need them on-screen in order to have all the elements be consistent at this point
Test it, I don't believe that will happen. It just stops the image from being stretched in any direction
Hey there! can anybdoy help me out? i can't seem to find the proper size for the default icons for my project
i have tried all sizes that are recommended (152x152, putting it at original res and letting unity format it...etc) but all the time it ends up resulting in a blurry icon when i build the project, what size do i need to make my icons for it not to be blurry?
Hi, I have a sidescrolling platformer where a missile is launched in the air above the screen and I want a UI warning Icon to have the same X as the missile, so it's UI on screen but if the missile is off past the bounds of the camera boundaries keep the warning icon on the side still on screen, not sure how to do that, I tried WorldToScreenPoint, but my main camera moves, screwing that up
Does anyone know why my Text UI is blurry? This only happens in the Game window and not in the Editor window
I have a Pixel perfect camera with the NES resolution, but I don't think that should be affecting it since the pixels are supposed to be one color
This is how it looks like in the Editor Window
Ok I found out how, if you have the same problem : Use Legacy text, make Font import Character as Unicode, create an Editable copy and change filter mode to Point
Hey, I am trying to fix this issue with UI not resizing properly.
Everything is set to "stretch" except those 4 boxes which are set to top-left, top-right, bottom-left, bottom-right.
Is there a better way? Is this normal that if I decide to resize the whole box that I have to resize everything else inside manually each time?
Do I need to use a layout group to fix this issue?
https://gyazo.com/af0921fae37f5c3a3a89dd3c8faa5db7
Issue with grid layout is that I need to specify the size, I want those boxes to always take ~25% of the area when resized.
Can someone help me with this problem please?
uhh, so yk how theres an "i" and an "ı" in turkish ? well when i set the text to upper by code it seems to confuse them in some way so that in upper case i get a "I" instead of a "İ" what even is going on
basically i just couldnt manage to get a "İ" in any way
any ideas on whats/what could be going on ?
nvm i got it
guys my resolution on game its bad what can i do?
Unzoom the game window
Where can i change that?
@fading cloak click your pixel texture in 'Project' and it will show in 'Inspector'
Is there possible to align items horizontally in the scroll view and not vertically when I instantiate them?
Use a HorizontalLayoutGroup in it instead of vertical
Where can I find that?
UI -> Scroll View all i got
Wdym? It's a component just like VerticalLayoutGroup is
Yes I'm saying replace the vertical layout group that comes as part of that with HorizontalLayoutGroup
So how do I anchor a gameObject? I just created an empty gameobject and I don't have the option
My goal is to anchor a gameobject with a canvas in overlay mode
Anyone can help with that?
Only UI objects with Recttransform have anchors
Create the canvas then create your empty object as a child of the canvas
Hi, not sure how to word this, but I have a level where you walk back and forth and a camera is following the player. At the end of the level a missile is fired into the air for the player to stop as it falls, the missile has a random X value when it comes back down. ]I want a UI warning icon to be the same X value as the missile object. If the missile is offscreen I want the warning icon to be at the edge of the screen to indicate the player has to move in that direction to find where the missile is falling, but when the missile X is on camera the icon to be the same X as the missile. I tried making the icon X be the missile's world to screen point, but it's not working because the camera moves, not sure what to do
World to screen point sounds correct. Which part are you struggling with? Is it the edge of the screen part when the missile is offscreen?
The world to screen point doesnt work because my camera moves, it follows the player, the x position wont work right
Wouldn't you just need to keep updating the world to screen point?
Can you show some code? Particularly on where you call this world to screen point
{
if (nuke == null)
{
nuke = FindObjectOfType<Nuke>();
}
else
{
nukePos = new Vector2(nuke.gameObject.transform.position.x, nuke.gameObject.transform.position.y);
if (nukePos.y > 5.6f)
{
if (image.enabled == false)
{
image.enabled = true;
}
nukeViewPos = cam.WorldToViewportPoint(nukePos);
//nukeScreenPos = cam.ViewportToScreenPoint(nukeViewPos);
iconX = nukeViewPos.x;
//iconX = Mathf.Clamp(nukeScreenPos.x, 0, cam.pixelWidth);
rt.anchoredPosition = new Vector2(iconX, iconY);
}```
I was trying different things
this Update method is in the UI object
WorldToScreenPoint didn't work anyway so I tried this
hey I just implemented retro computer font but it is being shaded like this?
Atlas resolution is too low and/or too tightly packed so they are bleeding into each other.
am i misunderstanding something about masking?
is that needed for ui? I will try in a bit. On ther docs it just says hides everything outside the display area i dont see any mention of a mask component
but I will try that in a bit
thanks
Is there something I'm missing with the Vertical Layout Group component that makes child elements not evenly sized (specifically using Text and Buttons.)
There are tons of reasons for this, e.g.
- the use of layout elements on the children
- disabling "control child size" and/or "force child expand" on the layout group
Im having an issue with my UI and pixelation. So as you can see in the pictures, the one that isv ery pixelated is what it looks like in the game view and also in the actual game. The one that looks good is it in my scene view (It looks a little different color wise because its being rendered with my post processing camera but if I try to render it with that same camera in the game view, it still looks pixelated.) Any idea why its being so pixelated in the game view?
Any fast way to make these 3 buttons on the side have a 'fanned out' formation, like you're holding a hand of cards for example? Red lines are the appropriate orientation
I know i can just manually do it, and I probably will, but just wondering if anyone knows of a cool component that helps with this. Didn't really want to get into splines just for this though.
I'm using a vertical layout group now so thought maybe there's something similar that fits things on a curve for you.
Beginner to Unity here. How can I use anchors to ensure that UI objects work on all resolutions and screen sizes?
Start by reading this article!
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html
Thanks! I was actually in the middle of reading that - just finished it now. An issue that I'm having is when I create a layout, let's say on the Samsung Fold device preset which has a comparitively large screen/resolution, and when I switch to a smaller device, there is simply not enough space to hold all the UI objects, without overlapping.
Is there a way to say - if the screen is too short to contain all these objects, start by reducing the height of the input field first, then when that reaches a minimum height of 200, move to the button, and start decreasing that height etc.
yes you'd have to use auto layout - i.e. LayoutElement components and LayoutGroup components
This isn't making much sense to me and I feel like there isn't really an answer to my exact question in there. I'm happy to do it with code as well
LayoutElement has stuff like Preferred and Minimum sizes
Ok, that's useful to know, thank you. Quick question - the Unity height and width values. Do these scale with screen size? I'm guessing that's why the Canvas object has to be set to Scale with screen size
@mortal robin Also am I correct in thinking that I have to add the LayoutElement component to every UI element in the Canvas? Just checking 🙂
Please ping me on reply 🙂
You need to add the layout element to every element that you want these fine grained layout controls for, yes
Ok, thank you.
hello!
im making a simple styled username input field but im having trouble with the scaling.
i made an image with a white boarder in aseprite but it doesnt scale like the deafult button/input background
i believe i have to set the image type to sliced but it doesnt look i can specify a border anywhere
You need to 9 slice it https://docs.unity3d.com/Manual/9SliceSprites.html
also based on this screenshot it looks like you just dragged the sprite into the scene. That won't make a UI element
that's going to make a SpriteRenderer, which is NOT for UI
make a UI Image component if you want this to be a UI border thing
its a part of a text input, not jus dragged into the scene
sorry for the confusion
thank you
show screenshots of those objects inspectors. Based on your hierarchy it doesn't look like it's part of the canvas at all
alright well, follow the 9 slicing instructions linked above to get it a border
i also found out i have to install the 2d sprite manager package
because thats something i didnt have previously :p
thank you!
also another thing is
how do i make world text be affected by light? like anything else does
right now it jus shines like a lamp due to bloom
i want it to be a dark and barely visible until the user hovers over it to see what it is
i have code to handle the hovering thing i jus want it to look dark
Are you trying to use a SpriteRenderer in UI?
You need to use a UI Image for UI. SpriteRenderer is for game world objects
background is still not showing 😦
Hierarchy order determines render order for UI
how can I choose the hierarchy order please
By dragging the objects around in the hierarchy?
but the bg is in the back 😦 Thanks for your help! don't what I did but it is now working
Why'd you delete your messages lol
I sent my teams logo in the pic haha
hey
In the animator in my current animation i seems like i can only change the posX but its called "position"
Damn, I am already suffering for 5 days straight. How to create outline for UI buttons (those are just squares or rectangles). Unity default outline is bad because my buttons have alpha 0.7.
Hi. I'm sort of struggling to understand prefabs. It seems that they are a sort of template? However, when I drag one (imported from the Unity Store) into the Scene view, it's just an empty box. I've got UI prefabs (buttons, icons, etc.) but I'm not sure how to use them. Could someone direct me to a link other than Unity's own? I'm not understanding the Unity docs in terms of the more basic elements. TIA!
wdym "empty box"?
Double click a prefab in the project folder to open the prefab view
from there you can see its whole hierarchy and click on any of the GmaeObjects in side to see what components they have
When you drag a prefab into the scene, the whole thing will be copied into the scene, with all of its hierarchy, components, etc.
If it's a UI prefab, it needs to be put inside a canvas
maybe that's where you're going wrong?
Yes the prefab I double-clicked has only one GameObject, but dragging it into the canvas does nothing
show screenshots
This is what I see when I drag the prefab into the Canvas. Are there any other screenshots you need?
Yeah, I just dragged it in, like I would with any other objects.
yes the hierarchy and inspectors
Of both the prefab and scene view?
of everything yes
ok now show it when it's in the scene
That's this
with inspector and hierarchy and all
it's not inside the canvas
That white box is the canvas
it's not a child of the canvas
hey im having an issue with my restart button, for some reason the button isnt letting the user click it... any ideas?
Can't click on buttons when the cursor is locked
Hi i need help with navigation. I want to press a left and right button and then when i press it,
icons on the top to change its state and move to the left and right side.
Can anyone assist me with this? Thanks
Hey, I'm still trying to figure out this icon thing, I'll have to draw it out @sterile wedge or anyone else that can help
I want this warning icon to track the missile's x position
so you can move and find where it's falling
what do you guys think?
^bump
ooh that looks cool
hey, does anyone know if it's possible to scale the content/children of a scroll view with the screen size?
Set the anchor to scale with screen size of a raw image but the size of the image isn't scaling to my screen size?
You have to set all the left right top bottom values to 0 if you want it to fill
how to make a UI object appear above cursor? 
What type is that of the cursor
what "what type"?
Understood
Is the cursor also a UI object
cant find any cursor setting anywhere than these
Ah, you use the player setting cursor
just the default mouse cursor ye
I'm not too sure of that since there's really no optional settings for it there
I'd assume there's a way to access it from a script and change sorting, but may still be hard to sort depending on how your UI is set up.
if you can't figure it out then making the cursor via canvas would be the next best option which then can be easily sorted
can someone help with this? it seems my side menu does not scale with the device's resolution. placing a content size fitter on the parent that my side menu is in would ruin the other elements that is include within the parent.
pardon if some of my grammar didnt made any sense lol
You need to anchor your UI elements properly
i see
thanks for the help
i finally found out the source of the problem
one of my canvases has the wrong anchor preset lol
Show your setup for the 9slicing
I'd have the lines a bit closer to the blackbits, but that looks about right
You should be using a consistent size throughout your UI designs
So it could be that your res for this is too big yeah
so i asked a question in unity talk got told to come here and basically my question was how i can have a image on my canvas repeat so its clouds and i want them to be constantly moving and i want it to just repeat them is this possible i found how to have it so you can extend it but no way to have it so when you move it
i found how to do this
but thats not really what i want
i want it to basically loop but just constantly be moving
I checked and my scaling of that is the same as my background. My background is set to fit the height of the canvas, so thats shrinking to fit.
Well, depends how you want to do it. You can probably instantiate and move them through update, or perhaps make it into a large texture which you scroll the UVs of a quad to simulate the clouds moving
theres no way to have it so when you move it it just goes to the other side to restart kind of
you can do that too, but if there's clouds in the scene rendering then those would have to snap out of place
Unless you set a reference resolution on the canvas scalar, your canvas is just the resolution of the screen.
If I scale it down ~25% it looks correct, but then the stretch to fit container doesn't apply and I have to manually set my left/top/right/bottom
scale should be kept at 1,1,1 for all UI , otherwise you can end up with weird things happening
probably other unity tools to scroll it for you, but it'll probably do that under the hood of it all
Export the image again from photoshop at the correct size
I do have a canvas scaler, but it was set much smaller than the resolution we designed the menu at. I think increasing that will fix it
Great!
Yeah that did it! Thanks!
@low sluice this is my event system rn
and my hierarchy
top layer contains all the buttons that are pressable
its order in the layer is 0, everything else is below that
i didn't mean ping me in this channel. post the details about your issue including your issue so that someone who knows about ui stuff can help you
how would i do that then
i have some buttons in the canvas editor that are on the highest layer but when i run the game i still can't press them
if anyone knows how to fix this please tell me
which one
You seem to already have an idea with what you have. Move the gameobject overtime then reset the positioning when it's at the end of the scene.
so basically what it should do is when it moves past a area it goes back to the start but only the bit that went past it
so for example ———> when the > goes past the area then it would be >—- and then ->— etc
its a really bad explanation
Sounds fine. Just compare positions each frame so you know when to reset.
and that will move the part that is outside the area to the other side
First time working with UI as I've never really needed to outside of GUILayout. This setup seems to work fine but is it possible to scale the container so it can hold everything inside of it?
Scrolling works fine but it wont scroll all the way down because container doesn't reach all the way down to button 4
Adding a content size fitter seems to work but it gives a warning about grid layout group
I dislike grid layoutgroups but I usually do a mix of horizontal and vert groups using content size fitters and layout element components
The Grid layout group is crap
wouldnt that reset the whole image though
a better example of what i want would be this the first image is normal then when it starts going off the edge the part thats over the edge would go over to the left side and start appearing there
Like I said, if you want to do it the correct way you'd scroll the texture and let it wrap around the background.
otherwise you're doing positional comparison logic
yeah so how would i do the first one
https://www.youtube.com/watch?v=xblN8J-9VuI
I'd go with a shader and that looks pretty promising
In this video I will show you how you can create scrolling texture in Unity using shader graph.
🥰 SUBSCRIBE: https://bit.ly/2Zj7D9y
Link Google Play Store
👉 https://play.google.com/store/apps/details?id=com.codeplan
► SOCIAL MEDIAS
🐦 Twitter: https://twitter.com/codeplanstudio
📷 Instagram: https://www.instagram.com/codeplanstudio
👉 Website h...
doesnt seem to work
i followed the tutorial and its just black
Video looks fine but looks like they're using built-in so make sure you're targeting URP in the graph settings (assuming you are using URP)
so i found another way to do it my only problem now is the image is behind my other ones how do i have it go above other images
sorting layers
k thanks
So I have this UI for a resource
I want it to be segmented like that and the current sprite work looks like this
Because the max number os resources we can have can be upgraded, I was planning to make it so that when it is upgraded another segment is added
But Im not sure how to handle the edges
I have it repeat the sprite atm but that causes an overlap of borders when the sprite repeats itself
Do u guys have any recommendations?
9-slicing
and u can change the sprite to be thinner. if you 9-slice it then it will look the same no matter how long you make the image in your scene
I have some button prefabs, on a menu panel, when I setup the button to use colortinting everything works as expected, but when I try to generate the default animations for it, and record some scale / offset and underlying image changes in the generated normal/selected animations the buttons don't animate change in anyway. If I highlight one of the buttons in the hierarhy and open the animator window I can see the animation parameters alternate normal/selected when I cycle through my options but the animations don't play.
Are there any common knowledge things I can verify? I have a another project where I have this setup and it works, and I can't pinpoint what I'm doing wrong this time. I already deleted the animator and set up / generated the animations from scratch and I'm in the same spot.
(compared to my other project, I had default transitions, while the other project had all set to fixed transition time: 0. I'm also confused, about how to use the animations. Say if a selected button is supposed to light up an raise/offset a little. Should this be animated in the "Selected" animation? Or should the button animations just be single frames and the animation should happen in the transition? (that's what people seem to be doing in tutorials but this doesn't work for me)
oh, it's my pause menu, is it possible that if I pause my game using timeScale = 0 it will affect the ui button animations?
yeah, that was it. So how do I animate my pause menu buttons?
Can probably look into unity's animator and make some clips w/ keyframes that play when you click
oh, close, on the animator there was a setting to use unscaled time!
im confused on how to start making a GUI for my inventory can someone help me?
What part of it is confusing? And entire visually represented Inventory system is a large amount of work.
Can anyone tell me how to change the color of the top part? The unsafe area
I want this warning icon to track the missile's x position so you can move and find where it's falling, I've tried WorldToScreenPoint but it's all messed up because the camera moves, not sure what to do
I've got this basic side menu of the Unity Store. How can I change the handle object (the little rectangle on the right-hand-side, it's a separate GameObject) to be an image instead of the rectangle it is now? For example I want to change it to a Hamburger-menu icon.
That is the prefab above. Please ping if you reply!
you could just add a child Image object to the handle object. I'm assuming the handle is a button
does it not have an image component? just change the image
(it should have an image component because you can see it)
It appears to be just a prefab, I'm new to unity so still struggling to fully grasp this stuff.
Yes I was going to do that but I was wondering if the button itself could have an image so as to not have to render/overlay stuff (not that it'd matter, just trying to get into good habits)
open the prefab then
yeah a good habit would be to change the button's image instead of overlaying another image on top of the button
also this may not even be a button
but it definitely has an image component you can change
How do I make ti so that the UI placement will be fixed no matetr the screen size
I am trying to use scale with screen size on the canvas scaler
But its messing up a lot of calculations for some moving UI elements
Properly anchor your UI elements
Within the prefab view, how can I edit the image of the handle object? Is it the Material component?
Wanted to share this new UI tool with Unity support https://rive.app/game-ui
"Image" component
i dont think there even is such a thing called material component
Probably means Material field on the Image component
Yeah sorry I was thinking from memory - thanks both!
I want an image to show up when the cursor is on top of a button. How do I do this?
Why is it so hard to setup an autoresizing inputfield?
You can add a script to the button that uses the IPointerEnterHandler and IPointerExitHander interface.
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Selectable.OnPointerEnter.html
https://docs.unity3d.com/2018.3/Documentation/ScriptReference/UI.Selectable.OnPointerExit.html
Inside the code block, you can set the visibility of the image.
example
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.
public class ExampleClass : MonoBehaviour, IPointerExitHandler// required interface when using the OnPointerExit method.
{
public image _Image;
public void OnPointerExit(PointerEventData eventData)
{
_Image.SetActive(false); // For the enter implementation you can set it to true.
}
}
Have you checked out this thread?
https://forum.unity.com/threads/how-to-auto-resize-inputfield-according-to-text-inside.297812/
Look at bkachmar's comment, I used this set it up for myself a while back.
that's what I did yes
What happens when you type into the field?
it does work as I want (just without a caret)
Ohh, I see. When you're typing, if in the editor you check if the caret is still present. Is it there.
try to do the setup, youll immediately see the problems
for some reason, inputfields are not friendly with fitters and layoutgroups
Do you have an example image of the issue you're having? So i can better understand what you mean.
Alright thanks 
hey guys, im trying to make a shader graph for my ui in unity hdrp.it looks like this in game view but normal in scene view, why is this? can i fix it?
i made the material opaque with alpha clipping, now it doesn't have that giant rend thing rendering but there is this weird artifact that.... you have to see for yourself
Shadergraph doesn't really support UI (unless you use the new UI graph type in 2023.2). I have some workaround info here which could also be useful, but aimed more at URP - https://www.cyanilux.com/faq/#sg-ui
is there a way to add EXTERNAL outline to text mesh pro text?
Hi, I've been trying to achieve a solid workflow for working on a pixel perfect game in Unity using the 2D Pixel Perfect package. Recently I've been trying to make UI snap to the pixel grid, like it does with sprites. Except it seems like it scales the UI canvas up, making the snapping be sub pixel.
Here are the camera settings
Here's the Canvas settings
And while integral numbers do match up to the pixel grid, UI elements can be snapped to sub-pixel positions while the position isn't using integral numbers.
Normal behaviour:
Unwanted steps between pixel :
What seems to happen is that the Current Pixel Ratio value in the Pixel Perfect Camera component indicates how many steps are possible between two integral positions. I'd like for the UI to snap to the pixel grid regardless of this pixel ratio, but I've been unable to find a solution.
Yes I could make a script that snaps the position before the end of frame but this seems like a bandaid solution, and would make movement inconsistent during animation.
tl;dr: When using the Pixel Perfect Camera component with Pixel Snapping unabled, UI can still snap in-between pixels if the Current Pixel Ratio isn't 1:1.
Does anyone have ideas on how to make it work properly?
bump
Hey guys, im currently working on localization for my project and I need some help with it. I linked my translation table from google, the table is finished already and everything is working fine when I change stuff through code. The problem are my buttons and texts (tmp). I know i can start tracking them but that would create a new key and as I said the table is already finished and it would be a pain to redo everything. Is there a way other then custom coding to link a key to the text input?
quick question noob question- what is the best /recommended way to have animations play Onhover for the buttons on a main menu?
Specifically IN the button- so it will be a still image until onHover then it will animate - either a GIF or video file
How do I stop my TMP_Dropdown from being squished like this?
Increasing the size of the Dropdown's child object Template doesn't work for me.
Also please ping me if you reply, thanks!
Other than coding? Not if you're not using a 3rd party localization asset. Thankfully there are good tools out there to do that.
Turn your gif into an animation, and enable the animator on hover, disable it on exit. Be careful about using animators in UI though, as they will constantly recalculate your canvas every frame. Usually we have a sub-canvas or a whole other canvas dedicated to elements that will refresh regularly, to avoid the rest of the elements to be recalculated when they don't need to be.
How does the hierarchy of the dropdown look?
Thanks for replying.
Thank you ! I will give that a go.
No worries
Is there a way to turn off Anti-Aliasing for text only? Since I have it turned on on my camera, so everything looks better, but the text just looks worse/blurry
how to add to the text mesh pro component EXTERNAL outline?
Does underlay not do what you want?
can i use a scroll view with vertical layout group bottom to top or is that not possible
does ayone know how could i scale on runtime an image only by the top edge?
something like this
from the one in the left to the one in the right
hey, how can i fix this?
i have encountred an issue like this before but that was because the mouse was locked, which isnt the issue here
How do I draw a black rect with white text with 50% opacity? I can only do white. Texture2D.blackTexture gives me 100% opacity.
hey everyone! what's the best way for making a slider that decreased from both directions, kinda like a timer thing?
Image set to Filled type. Make 2 of them, put them end to end with opposite directions set
I assume "this" means that the gun still fires when you're dead. This isn't a UI issue, this is a logic issue .. you shouldn't be taking player input for the game when they're dead.
I have a top bar with resources that increment or decrement constantly. What is the recommended way to constantly write and render these values without allocating GC? Is UI toolkit better for this or should I still stick with canvas?
what is a "top bar"?
Are you talking about text?
TextMeshPro offers this function for updating text: https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.0/api/TMPro.TMP_Text.html#TMPro_TMP_Text_SetText_System_Char___
As long as you keep reusing the same char[] you can contually update the text without any GC allocation
ok I mean... your question is about text really
doens't matter on the screen where it is
So it does not need to redraw the bg etc. on text update?
idk what you mean by "redraw the bg etc"
Are you asking about drawing performance, or allocation for strings for example?
Everything that is not the text itself, background, borders
that's a totally separate question
generally if you're worried about that, that has to do with how you arrange your canvases
generally I believe any UI change redraws the whole canvas, but don't quote me on that.
Meaning separating things into smaller individual canvases may be desireable
Yeah I know you shoudn't update your entire canvas to update it, but I wonder if that behaviour has changed in ui toolkit
But your original question was about text updating and GC, which I answered above
not sure, #🧰┃ui-toolkit has its own channel
Ey, quick doubt here; can I like, hide a part of an image in the UI and only show a part of it? I am specifically talking about a World Space canvas
Like do a mask on the engine itself instead of adding 20 edited copies of the same image as an asset
You can add masks or you can force ordering, yes
What I found is an addon that allows for masking, but I was wondering if I can do basic cutoff without that; since I just want to do very basic stuff
Well, depends how technical this needs to be, but if you did want to do shader work you can assign different alpha values to be cut
probably easier just to do different images of different alpha values
I think masking would be your best bet though
Does anyone know how to make layout groups render correctly?
This is what I'm trying currently:
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform) transform);
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform) transform);
gameObject.SetActive(false);
gameObject.SetActive(true);
In the past I've had decent luck with this
But I recall there might be a better way to do it
I can't even make sense of what this one is doing...
But there must be a way to make it actually do the layout
It works in edit mode after all
Ahh, I see what's going on here lol... God I hate Unity so much
Ah the reasons I switched to UI Toolkit early and decided to endure that pain instead
UGUI layout is a curse I wouldn't wish on anyone
Ugh, yeah... this is so insanely stupid
Basically what's going on is the container is being reduce to zero height
So it's now reinterpreting the anchors + offsets so that all the children are pushed out the bottom on the container
You can't actually use UI Toolkit yet though can you?
I thought only in editor
You have been able to use it at runtime for a while; it just doesn't support worldspace and you can't use custom shaders amongst another few things
can you get worldspace by rendering it to a render texture though?
Same thing, right?
Same thing except you have an intermediary texture, you would have to route events if you needed them, and due to the intermediate texture it's rendering at a fixed resolution
UITK has mesh-based curved edges and stuff and uses TextCore, when they actually implement worldspace properly you'll be able to zoom right in and it'll scale infinitely
Yeah niice
I mean, obviously a better concept, I was just worried I'd hit limitations I couldn't work around
I guess I should try it... lack of shader support is a bit scary
Yeah, it's definitely a concern; shaders would bottleneck me on many projects
worldspace is something I barely care about 😄
Yeah, I mean... i don't until the artists want to put a UI on a diegetic screen or something
At least you can combine UGUI and UITK
Yeah?
so if you really need something you can just fall back to the shit way
not literally combine, just in the same project have two systems
They are completely different systems 😄
Sure... but that doesnt' mean that you can't do it
You could certainly use UITK layout to drive UGUI, but I'd rather suffer UGUI than try to make that a nice workflow haha
oh well, guess I'll look into changing when I redo the UI
there goes two weeks of UI work though
It is insane to me that I'm losing child positioning because a parent is resizing though
I hope the person who made UGUI can't sleep at night
nested layout groups are a curse
nothing calculates in the right order with UGUI, I really never understood how complex layout was ever meant to work without dumb hacks
It's not nested layout groups
it's just an object beneath a layout group
this is in a layout group
this is in the scene
The values are simply changing
for no reason
Show the layout group?
The inspectors on the right are a level below the layout group
this is the layout group (in blue)
it's laying out correctly in play mode too, it's just that the relatively positioned children of the description are getting displaced
Description object itself:
Really just specifies a height
Since the rest is ignored
OH FFS
it was overridden in the scene
even though it was disabled
Yeaaaah that was my next suspect
I love how UGUI layout can create its own overrides just by dirtying itself
you don't even have to do anything to just have an override bust your stuff 😄
Yeah, I have all the objects disabled in the scene
But because I had removed a vertical layout group some changes were made
I must have left it enabled at some point
I guess they never tried this software before releasing it
well, they certainly never went back and fixed it
for whatever reason UGUI just stagnated and was never iterated on
Very aware. I'm acutally surprised a solution didn't pop up on the asset store in that time.
There are some alternatives, none of them caught on
I want to make a slider with two handles. It will let the user input a range. The left handle should never be allowed to go past the right handle, and vice-versa.
My idea is to just use two overlapping sliders (one with its background hidden), and to set the each slider's value in response to a change event if it's bout to go out of bounds.
although, on second thought, I'm not sure how I would do controller input on such a double-headed slider...
maybe I should just display two separate sliders and then do the clamping
Hey folks, do you have an idea how to cut out several parts of a UI image.
so far I have created a mask and added an image child object.
The image component was rewritten so that the mask cuts out part of the child object. I can't get any further at this point. Thanks for your help.
you'd have to be less vague and perhaps provide a picture example of what you are trying to do
oh, I hope this makes it clearer what I'm trying to achieve. I would like to write a method to cut rectangles from my panel. I just don't know how to achieve this... via a mask, shader or something else..
i have an problem in unity ui, in my sprite i use i have an transparent surrounding, but instead of still "rendering" those pixels it just discards them and scales the image as a whole, in 2d sprites this doesnt happen
should be like this
- i cant offset the position
When I Patch/Run on my Google Pixel 6a the whole UI is distorted (Screenshot #1) but in the editor Game view it looks fine (Screenshot #2).
Any idea why that is?
This is my parent UI GameObject's Canvas settings
And this the settings of the actual UI (which fails to show up properly on my Google Pixel)
Ok the problem was me using Screen Space - Overlay instead of Camera
Trying my damndest to create a proper scrollview, but i'mm getting this behaviour instead
any clues on what could cause this?
i think its the elasticity of the view, also maybe disable horizontal scrolling
i have a question tho..
so, i have this character :
and i wanna add this ring around it (in 3d space) but this is a 2D game..
so it ends up being like this...
i tried converting the Characters UI to 3D as spheres but in the game view, the char. totally disappears
any ideas ???
it looks fine in 3D space.. ? whats the matter ?
Your container recttransform is smaller than its contents
anyone ? 
Noted, I thought that didn't matter
Is there a way to programatically fix that?
The input reminders are created at runtime via iterating thru the input action map so I don't want to resize the container if I add a new input
How to resize a UI rect to match two worldspace corners(bottom left and topright)? Canvas is screenspace
Use the content size fitter component
These pictures would be way more helpful if you explained what kind of components these things are rendered with
By default, an Image with no sprite is anti-aliased. If I make an Image with width 8, length 100, and rotate it 45 degrees in Z, I end up with a smooth line.
But is there a way to remove the anti-aliasing? I'm making a retro sprite game, and having it look jagged when rotated and scaled would be ideal.
What I'm trying to achieve is making runtime lines and polygons in the UI for a mini-game, and need to control the shapes and dimensions in script, so I can't draw the sprites beforehand.
I have the scripts that will generate the lines connecting any two points, and a script for managing groups of lines to make connected polygons, but the anti-aliased look doesn't fit the rest of the game.
wdym... ? well the 2d ones are images and the 3D is a sphere i threw a material on... the ring is also an image
but the spheres wouldnt render for somereason, they are there in the editor view but not the gameview
the character is mainly only consisted of 2 (for now) circles big and small
hey i did some list of craftable items with scrolball but idk why i cant move it, when i try its just goes back to old place anyone can help me?
ok ty
Yeah because you're mixing up UI and game world objects which live in entirely different coordinate spaces. What I meant was Meshrenderer, SpriteRenderer, UI Image etc
hey guys, been a while since i asked someting, and i wanted to release V1.0.0 so i made a build, but i ran straight into this problem on startup. apparently Sprites do not scale with the canvas resolution, only UI. is there a way to fix this? i looked up on the internet but i could not find anything. Left img = 1080p and right img = 1440p
That's right, you're supposed to make UI out of UI elements
SpriteRenderers have a fixed size in the game world like any game world object
Hiya, I have a small UI/coding question. How would I implement a UI element with several (size N) buttons, where the press of the button will set a certain value, and then implement a button that uses said value to perform an action? Considering that the N buttons are instantiated in-game.
Guys, doesn't anyone know why a text mesh is not rendered on the player's camera? I filled in all the blanks like the font material, etc but it still doesn't work and doesn't render, I'm open to questions 🙂
it might not be positioned properly
Are you talking about TextMesh? The legacy 3D text object?
add click listeners for the buttons from the code that spawns them (and be careful not to fall into the lambda variable capture pitfall)
yes,i think
thx 🙂 Someone in the coding chat was able to help me out with this 🙂
UI images.. and for the mesh its a mesh renderrer
idk if i should post it here or where else, but im having a problem with masking and animations, so i have a animation and its inside of a mask but when there is just a small bit inside the mask you can see the whole animation even tho the rest of the animation is outside the mask, im sorry but im bad at explaining stuff
first image is good, second its outside of the mask, 1 small scroll difference
you can create a script with a public variable that stores the value and you can set its value by adding the variable setter as a listener of the button OnClick unityevent
Example:
ButtonValueManager.cs:
using UnityEngine;
public class ButtonValueManager : MonoBehaviour
{
public string storedValue { get; private set; }
public void UpdateStoredValue(string val)
{
storedValue = val;
}
}
MySubmitButton.cs:
using UnityEngine;
public class MySubmitButton : MonoBehaviour
{
public ButtonValueManager manager;
public void HandleValue()
{
// Handle the value
}
}
this mesh text is rendered but not in the camera of the player,its in the world as a gameobject the hud
you didn't answer the question
what component is this
TextMesh (not TMP)
Right so that's a 3D world space text element
it's not a UI element
if you're trying to use it in UI, you're using the wrong thing
Ohh oka
Hey folks, does anyone know how I can achieve this ?
i understand but i need the word "Destiny" to mask with sprite masks, thats not possible with UI is it?
UI has its own mask
I'm using the new input system and use ui canvas/panels/buttons. The actions are mostly "automatic" for me, I just add buttons and they work. but I'd like to close my submenus using those event system's cancel event. (I have a player controller with a player input where I process input, but I'm disabling that when the player is dead) where can I process a OnCancel in my menus?
In your image, do you want the 3 squares to be "see through"? If you don't need them to move the simplest way (for me) would be to just make a png with 3 transparent squares.
iknow, only filling is possible but i need this to fill it and thats not possible with UI is it
only as sprite mask
this forum post https://forum.unity.com/threads/how-to-get-oncancel-or-other-ui-callbacks-called.893581/#post-5896931 suggests I need a monobehaviour implementing ICancelHandler . Do I need this monobehaviour on the event system or any ui object?
I tried both (a monobehaviour on the event system game object) and adding this to my menus which are the canvas object children) and must be doing something wrong because the Debug.Log I have in the OnCancel handler is never shown.
I ended up with a solution similar to a post down that thread, but instead of instantiating the InputSystenUIInputModule I get it from the EventSystem.current.GetComponent<...>()
hey huba.buba. Additional parts should be cut out. The order and position should vary
I think you'll need a shader for this. When I asked chat gpt it gave me a simple example so that might be a starting point for you. But I don't know what you actually want, meaning is this somehow part of your ui (what's visible through the holes, other ui? or the game background? Do you want those "holes" to be absolute or do you want other ui elements to possibly cover the holes?
I would like to have a panel that shows an image. Above this there should be a full-surface black panel in which a rectangular area always becomes transparent via positioning data (for example via a mouse click at a certain point).
other UI elements should remain visible. The transparency should only apply to the black panel
I'm struggling to understand what you actually want to achieve. If this will be potentially covered with other UI elements how will you click ? Is this UI or the actual game? If you click and a rectangle reveals maybe have a grid of black rectangles and disable them on click? Just brainstorming. If you really need a "reverse mask" to reveal what's beneath, go with the shader approach as I don't think there's anything in unity standard UI elements to accomplish that.
Guys, is there a way to change this so that a digit is not equal to a line? I want everything to be on the same line, and I would also like the hud to focus more for each digit (that is, it adjusts depending on its digits).
eg: ammo:----100000-- ❌
ammo: ---100000---✅
can anyone help me with this? my camera isnt showing my canvas text even though it is at the top of the sorting layer
hello, i got a problem, my image is just overlapping the mask
here is a vid
don't mind the vid in the corner, i was listening to music
also don't mind the errors those are alr fixed
this is my mask settings/ scroll rect settings
this is the size
idk if this is relevant but here is the settings of the object i keep my upgrades at
The vid isn't loading for me for some reason but to use masks, doesn't the Image component need to be active and the colour's alpha bigger than 0?
image was active, i disabled it for testing, forgot to activate again
And it still doesn't work?
colour alpha is cause its a background
nope
here settings of the animation
maby that could help
I can't watch the video so I dunno of any context
Is the image a child of the scroll menu?
weird, well the thing is, when i scroll it works but when 1 pixel of the animation appears it overlaps the mask like it isn't there
yes
Ohh it's related to anims okkay
What if you try completely removing the animator component then
And undo if it doesn't change anything
Also are other objects like default Image primitives masked or is it just this one object?
nope still bugged
other objects work as normal
the image under the animation is not overlapping while its i the same gameobject
And the 2 scripts attached..? Have you tried disabling those
not yet
They may be setting some properties in it maybe
i can't disable them and they are nessesairy otherwise its usseless
But then again to nail the possible causes down even further you should do that
Why can't they be disabled? Has some other script flagged them as Required or something
i created a copy and without script and still bugged
And now you have an object without the scripts, remove the animator from it
well 1 makes rewards and detect when the animation ends but other one i decided to move and hopefully it doesn't break
If it still doesn't work, compare it to a default Image primitive and see for any diff
doesn't work, alr
Damn, any difference between the working Image and this obj?
omg thank you so much
Got it working?
it was cause i used a material 💀
yep
thx for your time, i apriciate it or however you spell that word
Yeah np sir
ah alr, il take that with me for the future
hey huba.buba, thanks for your answer. It is a part of the game in which the background should become visible as the game progresses. In the end, only positioning data for the rectangle has to be transferred (not necessarily via a click). An inverted mask was also my first idea, but I couldn't implement it. I'll try to implement it like you said with a shader instead. Thanks for the help
My game is controller only, using new input system. I SOMETIMES run into an issue where looks like my ui even system looses track of the selected element, I show a panel with 3 buttons and sometimes I can navigate through them and sometimes I hit down on the controller and the last button looses focus as if there's some other invisible button getting selected. Anyone ever ran into this? Is there a common cause I can check, any recommended way to debug this?
I don't know if that's a but, but I think it happens when I start my game with a menu prefab open. If I just have the scene open it works fine, but an open prefab will confuse the ui event system / navigation somehow.
im back, and i simply want to extend the bounds of my image to the screen, making it swim in darkness. if not possible, just tell me how i can make an reversed mask.
unity 2017.2
Hi I posted earlier in Unity talk but I got no responses and I realized this question is probably beter suited here anyway, Im tring to make a battle menu for my game, and I cannot get the buttons to appear in the game view (the button is big bc I wanted to make extra certain I saw it if it was there) I have used text mesh buttons before but I genuinely must be forgetting something very simple
any advice?
I can provide more details or screenshots if need be, I genuinely just don’t know how to troubleshoot this
guys,this is my bullet hud and its wrong,anyone knows how to solve it?
how to make this part not clickable?
i just need a button with text under it, but only the button should be clickable
Just disable "Raycast target" on it
thanks!
Hello, im very new to unity and i have a problem on my canvas
the outline appears on the actual game for some reason
does anyone have an idea? maybe this is a layer problem
i need a bit of help with some UI
my "lobby" is spawning 1500 pos z when the prefab is at pos z 0
https://www.youtube.com/watch?v=XtQMytORBmM&t=1118s i was following this tutorial and im at aroud 29:00
GMTK is powered by Patreon - https://www.patreon.com/GameMakersToolkit
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then give you some goals to learn ...
this is the "lobby" spawning at 1500 pos z
and the content is at pos z 0 aswell
here's a video footage if it would help, thank you
I don't see anything unusual here.
You have gizmos enabled is that what's confusing you?
What's gizmos?
The canvases outline is showing on the actual game
You can see it in the middle, top and right
Its like a thin line
Should i point it out
Yes that's the canvas gizmo, expected to be visible when gizmos are enabled
Oh I see
Thank you
https://youtu.be/F85YVqd0TIM?si=6JFEYCCKWbtVd1Bo&t=475
does anyone know how could i do this in unity with the images? what type of file should they be?
Devlog video about "Homegrown", a casual farming game I'm creating using my own engine.
Play my previous game "Equilinox":
https://store.steampowered.com/app/853550/Equilinox/
Support the channel on Patreon and get access to the game & code for Homegrown, the city-builder, and Equilinox:
https://www.patreon.com/thinmatrix
UI database website:...
splice the images up through the sprite editor
it'll make them into an atlas
as for changing individual colors, you can just change the vertex coloring through the UI color
otherwise make your own vertex/fragment shader but if you've only one color for your elements then unity's UI shader should be fine
I have very small 8px by 8px "pips" in my settings menu. I noticed that they don't align with the pixel grid of my monitor, resulting in varying pip sizes
in this case, the second pip is too wide
Perhaps I should round each pip's position to the nearest whole number? They're being arranged by a HorizonalLayoutGroup right now
I believe this is what Pixel Perfect is for on the Canvas
I don't know by what sorcery it aims to accomplish its goals
i have this options menu in my start menu of the game but i also have an options button in my pause menu IN the game itself. how can i transfer the values from this options menu to the one in game
or maybe the transfer the whole menu object with DontDestroyOnLoad to the game
whats the recommended way to make something like this?
https://www.youtube.com/watch?v=3dAgZPTsfuA
the OP says they used the vector image support module and imported the SVGs that way, does this mean I could make animated svgs in another app (e.g. adobe animate) and import them in to make persona5 UI?
A little experiment I made, I want to see if I can make one of the stylized menus of Persona 5 in unity, Sophia shop from Striker looks the easiest to try to imitate so I choose that one.
I'm too lazy to find and animate a character model, So I just put a cube there instead
I want UI that can curve and stuff whilst still being dynamic
No, the vector graphics package doesn't support animations. Or at least it didn't last time I checked a few years ago
Basically, you wouldn't store the Options inside the UI itself, but instead they would be their own Object that any Options UI can read/write from.
Your actual Options could be a static class that you initialize/load when your game is booting and save when it's quitting, that way you can access your Options from any Scene without the need of Singletons or Inspector References
so if i for example turn off my music, the next time i open my game the music would be turned off?
or the options transfer between just scenes and not different times i open the game
Very very bare pseudo code
static class Options
{
public static float m_Volume;
public static void Load()
{
// load values from some file or apply default values if no file exists
}
public static void Save()
{
// save values to file
}
}
class OptionsUI : MonoBehaviour
{
private void Awake()
{
Options.Load();
// apply the Volume value to some slider
// if the value of that slider changes, write it to the Volume value
}
}
Loading the Options should ofc not be done within the UI, and Volume shouldn't be public either but instead use functions to read/modify and raise events, but I think the basic idea is clear. Decoupling.
Yes, you would store the Option values in the FileSystem of your device (PC, Mobile, whatever) so they would persist between play sessions
im kinda familiar with writing classes in c# but not in unity, can i put the class in the same script as the Options script?
also ive no idea how to operate with files on the computer
Which class are you talking about precisely?
Files are fun, and easy!!
Use the System.IO namespace and the File.Read/File.Write APIs 🙂
(There's WriteLines, WriteBytes etc).
Also, JsonUtility is a nice one, many people say it's bad but they're just using it wrong 😂
the Options class
Most of the times, each class should go into it's own file. That's especially true for MonoBehaviours and ScriptableObjects.
For a simple Options system, you should have
- OptionsUI -> MonoBehaviour.
- Options -> Static Class
- OptionsData -> Class or Struct with the System.Serializable attribute.
OptionsData would be the thing that holds the actual values and gets saved to disk, if it's Serializable you can easily save and load it by using JSON.
Options would be a wrapper around that OptionsData, responsible for reading/writing from/to that OptionsData as well as saving/loading it.
(Saving/Loading could also be done by a standalone System, probably preferred, but the Options class could abstract that responsibility away so you as developer wouldn't need to mess with different systems to save a single thing)
And the UI class would just talk with the Options class to receive and modify the OptionsData values
Optionally, you can use PlayerPrefs
whats that
An API that Unity provides to save simple Data like Integers, Floats, Strings or Booleans, check it out in the Documentation, it's pretty easy to use but also kinda limited
May be "good enough" to get started with persistence though
well im making this for a school project so i think i'd be more impressive if i were to make a custom save & load system
should this be in a different script than my Options script?