#π²βui-ux
1 messages Β· Page 14 of 1
For the image, what value are you changing? And what are you setting it to?
the image im using the animation window to add an animation to it. Just doesnt seem to do anything. Im not sure what you mean by what value im changing its not a tween animation its a sprite sheet animation.
Right, so the βvalueβ is the sprite field on the image?
The sprite just looks the same and the only difference in the 2 is the position. So.. just use 1 sprite and animate the pos
right but its easier to do with an animation. So youre saying I can't animate an image with the animator window, because its hard to find an answer on this.
You can animate the position..
im aware but id have to set up a tween path with proper speeds
seems like a pain and I would want to be able to animate UI anyway when later a sprite might change in its animation
No you wouldn't π€
This took 5 secs to setup - longer to record than create π
how do you use a camera to render background without it being the base camera? (URP)
Rendering -> Priority in the camera inspector. Not a UI question though
My UI has begun to break in all my games after updating to unity 2022
Any idea how to fix it?
2022.3.4? or lower? It helps to be specific...
202.3.4f1
It's a bug, which was fixed in 2022.3.5
..
Unity says it's at the current version
Why is unity lying to me...
I've no idea where you're looking, but it's available through the hub, where you should be looking..
Don't use that Β―_(γ)_/Β―
Alright
You install new versions through the hub, then set the project to open in whichever version you want it to
Ok
oh i didnt know you could do that, but what would you say to do if I needed to actually make an animation that changes the sprite? Does it let you animate your image that you set up with different sprites? Its hard to find an answer for this so I would appreciate the help.
ty for the help so far btw lol
ask in #πβanimation how to do that.. I've no idea if that's possible to do
I'd do it with code
Any clues as to why this specific font shows up that way unless you zoom in?
How can I set my Canvas up so that I can adjust the opacity of the Inventory Screen object, and its opacity will effect the opacity of all its children?
GOT IT!
Nevermind my question
Canvas Groups exist
Has nobody really had this problem? (OnEndDrag being inconsistent - sometimes not called at all when a drag is ended)
how do you animate UI Images with different sprites? I cant seem to find a clear answer on this
not just tween movement but the sprite actually changes
You can set the sprite as a keyframe in the animator
same way you do it with a sprite renderer
that was supposed to link to the "creating keyframe animation" section
i tried that and it didnt work, ill try again
so I have a little hand cursor that doesnt actually change the sprite it just moves 1 pixel over, for 2 frames and resets. But it wont animate the single pixel move over. (I know I could animate the movement with unity animation properties but I want the movement i specified in the animation)
why cant it simulate when my sprite moves
show what you did
are the two sprites actually any different?
can you show them in the sprite editor?
Are the pivots correct?
they look the same in the dopesheet
yeah pivots are correct
it works normally just not when i put this animation on an image
I would just do screen space camera
heres a clearer example is this not normal behavior?
Hey any thoughts on why this sprite is rendering oddly on the screen? Is it being cut correctly?
No. Slice it horizontal down the middle.
Ok thank you!
Is horizontal still a 9 slice ?
I dont think it matters. I guess so? Just that the center row is 0 pixels wide?
Just slice according to your texture
Thank you! -- is there a particular reason you slice 0 pixels wide, vs how i did it before?
because the curve ends in the middle of the sprite
Ok thank you
@mortal robin hope u dont mind the ping just wanted make sure you saw this. If you dont know its okay i just wanted to check.
The UI image might be cutting off transparent edges of the sprite?
I dunno how sprite renderes work, in regards to pivots. But the UI won't use the pivot you set in that, so they're all just going to be in the same position in UI.
it's not
UI elements have their own pivot, that's what would be expected to be used for alignment
so if I added empty space on the left of the cursor sprite I could simulate the movement i think
When I switch menu screens, all buttons are highlighted and dropdowns are...dropped down. It's like everything is selected all at once. Why?
I just activate and deactivate different screens (such as images with children on the same canvas or different canvas alltogether - same behavior)
you want to change it to whatever it needs to be to make it the desired size in the game world
let's say it's a 64x64 image. If you want the character to be 1x1 in the game world you'll want PPU of 64
are you talking about in editor or in game, bc in editor I think that just happens unfortunately
No I'm talking in game
Hey there people! just wanted to ask if anyone had any idea how to make a UI button do an anmation whenever we mouse hover over it?
i know there is the option to setup button transitions to animations but i basically want them to keep the color tint options on top of having a little animation for the button when you hover over it with the cursor
Probably a IPointerHandler and DoTween?
have the animation tint the color too
yup i tried doing that and it works really great! thanks for the message π
Dotween is really a game changer for ui
It's unlikely anyone here is going to have a solution to a possible bug in 2019.4
If you can't update away from 2019.4, can you update to a later version (the last?) of 2019.4?
I want my render texture to have UI, how can i do that?
Screen Space - Camera canvas
or world canvas
Can you make it interactive though ?
with a custom raycaster you can
"think" isn't good enough bud, go check and make sure
Probably fixed in 2020 and not back ported
how do I make pixel font text align its pixels with my canvas, I know it will have to be a certain size to match the pixel size but how do I know what size to make it? Do most devs just not bother matching the text to the surrounding pixels it does seem pretty hard.
any reason why the shop png isn't showing up in the editor?
it shows up in the game
but for some reason I can't see it
I wanted to add more interactions but I need the image as a reference to know where the board and black border for options
ping me if replies
thx in advance
Show the inspector of InGameUI please
And press T to change to the Rect tool to see the borders of the image
might be the camera press the 2d button wait for it to go to 3d and press shift+f. then return to 2d.
Or just double click the image in the Hierarchy
You should be looking in the game view, not scene view, when you're working with UI
ingame is the same thing as normal. The only componnet in here is the image
and the borders are stretch out and matches
3d? I'm not quite sure what you mean
also this game is entirely 2d so it's not goign from 3d to 2d if that's what you mean
I did double click it in the hierchy and it gives that scene above
really? I feel like I need it to know where to put the text and buttons
So there's no canvas?
Where's the canvas?
okay wtf I'm actually so confused now. I was experimenting with the UI and now the gameplay is affected and my character just clipped through the ground
it's parent
wait leme check
the InGameUI has the canvas
But you said that only had an Image component above
I disable it just in case
yea in the shop gameobject
it only has the image component
Here
Ok show the inspector for the ingameui object
Oh wait yeah
Look at your hierarchy
You hid those objects
(the eyeball)
eyeball?
you mean the checkmark?
I did that intentionally in that pic
but with the box check, it doens't show up
also nvm this I was just being dumb
but it's a mystery how the UI is missing
just adding another gameobject with the same image helps??
yea okay I think I'll just go with the new one
I do not mean that
Look at the left edge of your screenshot
In the hierarchy
The eyeball in the margins
I'm using Unity Editor 2021.1.6f1 and I'm using Text Mesh Pro. I created a text, added a font and polished the text. But every time I save it, it disappears. Help anyone? 
- Why are you using such an old version of the editor? You should upgrade at least to the latest 2021.3 LTS to get the most bug-free experience
- What do you mean by "disappearing" exactly?
did all unity games made before the 2020 version have to fix that manually?
All games that encountered the issue will have had to fix manually or update
and the best way to do that would be checking each frame in Update if dragging was true previous frame and now it isnt, then call OnEndDrag? that would end up calling it twice most of the time then though
how would i fix that?
open your TextMeshPro component in the inspector and look through the properties
font size is one of them
51235
How do I match a fonts pixel size to the games pixel size. It not easy to find anything on this, and its very important to me.
simple
make your own font
ok but fr i know little to nothing about fonts but from what i know you can just use a vector font
yeah no, thats not how a vector font works, also while I could make my own how would that fix the problem? It seems insurmounatable to find all the proper settings that will make my fonts pixels line up with the game. Heres one persons explanation that I have no clue if it would even work. I would be interested to know how consoles like SNES, and NES did their fonts. (ill google that just spitballing a bit here)
ideally should all my canvas have scale to screen size?
If you want the UI to scale to the screen.. yes?
ok ty
What's the perfect resolution to export a Sprite Sheet for a game whose canvas size 4k Portrait?
We tried using 5k x 5k res and it is still blurry π
Sure you're not just zoomed in or something? Because that doesn't sound right
Actually not π
The UI Breaks on IPAD
That scale isn't set at 100, because it can't fit on screen
It won't look good like this
Yeahhh but
and that looks right
I have another issue
The quality one got fixed
But but
AS you can see, the UI arrangement breaks when I go to IPAD
From Iphone
The main centre panel overlaps the top one
If anything, it's actually the other way round π
Yeah I tried everything.
From some Unity Forums, I saw that people say to have different UI Layouts for Vastly different Aspect Ratios
Meaning that I will have to make 2 different layouts for Iphone and Ipad since there is a massive change in resolution.
Yep, it'll be the best way
How can I make UI images be affected by Directional Light and Global Volume?
in URP
but only two images
not the other UI elements
When programmatically creating canvas elements, i need to set the rect transform to specific values, is there a specific order they need to be set in order to work properly, like anchors pivots then position? or pivots anchors then position? does it even matter?
Basically, how can I recreate this programmatically. Because I've tried setting the anchoredPosition and the sizeDelta to match along with the anchors, just the l/t/r/b always seem to never set to what i am passing into it. I give it 3 11 3 11 for l/t/r/b and it sets it to 1.5 -16.5 -4.5 5.5?
I googled
how to set left right bottom top recttransform
I asked ChatGPT and it gave me the same solution but it didn't change anything. Perhaps I messed something up. I'll find out when I wake up later ig
This may not be the exact place to ask this, but I have a question regarding the Pixel Perfect-ness of a UI Canvas marked as "Pixel Perfect" when the Canvas Scaler Scale Factor is set to any integer other than 1.
The Canvas is pixel perfect in that the position of UI objects is always exactly snapped to 1 pixel, but when the Scale Factor of the Canvas Scaler is a different number than 1, let's say 3, it would be expected that the positions would also be scaled such that the ratio remains 1:1. In the case of 3x Scale Factor, this would mean 1 pixel would be counted as a square of 3x3 pixels, and positions would thereby need to be scaled by 3. The image demonstrates this issue, where "subpixel positioning" is allowed where this should not be the case. Am I missing a setting that corrects this? The Scale Factor is set relative to the resolution of the game as the target resolution is 640x360 px, which scales nicely at exactly 2x for 720p and 3x for 1080p.
Changing the Canvas Render Mode to "Screen Space - Camera" has no effect on this issue, and I am not exactly sure why the canvas pixel perfect mode would not take into consideration the canvas scaler scale factor in this way.
So it appears that "Pixel Perfect" mode for the UI Canvas only cares about Screen Pixels and not the size of "pixels" that get scaled by the canvas. Is this by design?
I'm having my own issues with pixel perfect in the UI too..
How would you guys go about showing an object can be interacted with
Plan rn is to have a tooltip show up like in the video when youre nearby
but also a blue glow and blue flames
but i feel like the reminder text rotating like this just seems unprofessional and weird
maybe make it face the camera and not rotate, then?
as if it was 2d
Can anyone help? I want to select a 'resume button' on my 'pause menu' by default but it doesn't apply the highlighted effects until I either select another button and come back to the resume button or unpause and pause again.
It says its selected, which is why I don't understand why its not working.
This is what I want it to look like (this is after unpausing and pausing again)
do you have a default button in the event system and how are you applying the highlighted effect?
when I scale my canvas it mismatches the pixels, everything works fine at base 320/180 but when I got 1080p it misaligns them why does this happens heres what my canvas scaler looks like
theoretically everything is being scaled so i dont see how one object scales differently than the other
I dont mean to sound dramatic but from my perspective unity is broken. Ive doubled checked everything pixel related I know of and have seen online it just wont align.
(just letting people know I am desperate for help on something I might have missed)
is there any way to get rid of the "selected color" from button
i have buttons that dont like turn things on/off and are just clickable many times
so i would prefer having only a normal color, highlighted for when its hovered, and pressed when its clicked
oh i figured it out
making selected color the same as normal color and disabling navigation fixed it
theres a pixelperfect property on the canvas
shouldnt that be the only thing you need to do?
and on all your images set texture type to "point (no filter)"
I wish 
But no ive done that its not the solution to my problem at least
hey , have u tried setting the UI Scale mode to Constant Pixel Size?
anyone know why my UI element's y pos are NaN when I first open the project?
actually all of my UI elements have positions NaN
@finite iris hi were you able to resolve your issue?
curved like Italic?
Why do some Filled images have Fill Amount starting from the beginning on an image and others have in starting from the beginning of a non-transparent part?
For example I have this image, which is still visible with very low values and an image that disappears completely even at 0.034
It seems like it depends on the scale of the sprite image. The second image is 260x29, I've made it 780x87 and now it works like in the first example. How does it work and why?
guys, any of you have a good idea how should i do the UI display on kills seem very rewarding for a zombie game?
im really bad with the UI
When working with UI how do I make a parent fit the size of its children if it doesn't have a layout group? I don't want to use a layout group because I want the children to change its position according to their anchor and pivot presets and layout group IMO doesn't allow such functionality.
You can add empty objects as children in layout group and change position of children of those empty objects
How do I make elements of layout 1 cling to different sides of layout 1? So that if layout 2 (which is parent of layout 1) expands layout 1, children of layout 1 cling to sides of layout 1's GameObject as if they were anchored to the sides?
The whole reason for using layout groups in this case is to expand all things in layout 2 when layout 1 changes in size. There will be many instances of layout 1 under layout 2.
i believe that you want to create a shader, something like this one https://www.youtube.com/watch?v=VQxubpLxEqU
Unity Shader Graph - Vertex Animation of a Goldfish Tutorial
We are going to see how to make this cute little goldfish wobble and wiggle with Shader Graph. This shader will be mostly focused on Vertex Animation.
Goldfish: https://www.blendswap.com/blends/view/90712
Hey I'm making a game, check it out: https://store.steampowered.com/app/176386...
https://discussions.unity.com/t/how-to-create-360-curved-text/214224/2 then something like this
Ok first of all you have to create a Prefab. Create an EmptyGameObject. / Zero the Position and Rotation Add as Child TextMeshPro - Text. / Rotate the Rect Transform around 180 degrees. In the Font Settings set the Alignment to Center and Middle Add the Prefab to the Propertyfield Text Mesh Prefab. this is just a basic Code which you might wa...
but you will have to modify it to ur needs
i dont think there is simple solution for that, you will have to code it out
Nobody can tell what's the best solution for you. Obviously people who have posted to the forum threads and blogs think that their solution is the best one so you'll have to try them out and see how they work for you.
well there is no best solution, as long as you can work it out its good, and if u can find a better one for yourself , use it
i just used google to find those solutions, u should use google aswell and see if u can find a more simple code aswell, training how to use google for what u need is really good, to master the algorithm for your questions to get really good answer is really usefull
anyone know how to put particles on a unity UI? i tried a few weeks ago and the default solution the internet kept saying did not work. anyone got any adivce?
Is there any clever way, within this canvas, to have this box properly fit to the "cooldown bar" over top of this image, even if the screen resizes?
The parent image object is configured like so, for automatic resizing:
and that image is inside of a Horizontal Layout Group with padding and whatnot, so the outline you see in the first pic is the box it has been given to fit to automatically whilst preserving aspect ratio
Or am I pretty much stuck using a script of some kind of manually calculate the X/Y offset and height/width of the bar?
you need to look into Layout Elements
they're the missing other part of the whole layout group thing that you probably never realized is there
no I am using those
Layout Elements are integer values though, not %s
nope
wait is there a way to make em %s?
if you have one element with flexible width of 1 and another with flexible width of 2, you'll get 33.3% and 66.6%
it's about their relative weights
I only have a single element, should work though right?
Though, is there instead a way to do like, flexible padding from Parent -> Child?
you probably need another "empty padding" element
to define the empty space
that kinda feels gross but I guess that works
lotta extra overhead for what is just a single int D:
I just wish I could do a LayoutGroup with % padding
Yeah I tried UI Toolkit but it just was super poorly documented and so much stuff was missing
and it felt pretty buggy as I worked with it
Like Im a web dev and Im quite familiar with FlexBox when it comes to css, and it definitely seemed to be a fair bit "off" with respect to how flexbox behaves normally
haha, one of my projects I maintain effectively is my own custom language I made that is a remake of css (but with my own variables and values cuz it does other stuff)
now I gotta sit and count pixels to get everything lined up @_@;
hrmmm
If I have A -> B -> C, and B's are set to evenly distribute across A as a layout group, and I want a C to completely fill the B without expanding the B, how do I do that?
Cuz right now, the 5 images you see are the "Bs" and they are inside a horizontal layout group "A"
There's a max that A can expand to, but the B's are supposed to have a ratio they follow to based on their images.
But now that I put children that expand to fill up the leftmost B, it caused it to expand out and grow to fill all the remaining space D:
As you can see in the pic there, the leftmost one wasn't supposed to grow out like that, it's supposed to stay same size as the other 4
Oh damn, we still have issues though @mortal robin
Cuz we can have the scenario where the image is fitted to the sides, not top/bottom
Like so
...oh wait, nevermind, simply by being a child of the parent image... I guess the scaling "just works"?
~',.'m a g i c'.,`~
Nice, works like a charm... didnt have to do anything special, just had to line it up and the auto resizing "just works" I guess
how can i fix this (make the text look "better" so its not all squished and is readable)
help pls π
You need to specify what you want to fix. Also make sure you didn't scale parent transform non-uniformely
im sorry but i have no clue what that means
Check transform scale
All UI elements should have their scale set uniformally ... ie: at 1,1,1
thanks guys π @azure flame @low pike
Use the width/ height on the rect transform to change the size of UI
I have deleted the EventSystem i have to canvas how can i turn them back on
because nothing is intractable
re-add an event system..
still
still what?
Hey guys, I can't decide on what my UI should look like - what the style of the game's UI should be. For now, I've been just been using some placeholder UI using the unity standard UI toolkit.... I've just been starring at an empty figma board for like an hour. Do you guys have any resources / pointers to help me figure this out?
I've only really done some flat website UI designs in my past and I know I don't want to use that style, it's just not fitting for my strategy game.
look at some other games for inspiration. Sketch something out, ask friends for feedback
how can i get these images to not waste space with 18:9 aspect ratios? they look fine in all 16:9's, but 18:9 leaves too much space
Thanks
Hey anyone knows if I can find a free animated progress bar like this?
I don't know how I can make one to add in unity and I don't want to pay for assets
If anyone has a tutorial to make one I'll also be happy to make one
I looked everywhere and I can't find anything
Either a vertical layout element, or split the anchors so two are at the top and two are mid way
ill try that, thanks
yeah vertical layout group and use layout elements, including one for the empty space
should be pretty simple. Use a RawImage, with Wrap Mode: Repeat, and then just animate the UV rect in code:
https://gamedev.stackexchange.com/questions/197804/how-do-you-repeat-a-tile-texture-horizontally-vertically-in-a-ui-image
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.UI.RawImage.html#UnityEngine_UI_RawImage_uvRect
I'm trying to get a scroll view to work, but for some reason, when I add a default scroll view from the UI menu, it does not accept any input at all. I'm running the latest version of unity, and I cannot think of anything that could be causing this. I've changed the size of the content and added images inside to make sure there's a space to scroll, but trying to scroll or click drag doesnt do anything. What am I missing here? Again, did not change anything besides changing the size of the content and adding stuff to check its actually scrolling.
What is your favorite font to use in your game's UI?
If its pixel art i like making my own personally.
Any ideas how to control name's width when I stretch InputField, so that together they will always be 100% of parent with Horizontal Layout Group ?
without writing my own script
Make name label and input field a child of a new GameObject that's a child of layout group
Then tick control child size width thing on the layout group
it does not work
I mean, it's the same as if I was just a child of a new GameObject
so it doesn't make sense.
I just leave it at default settings
Depends on what you're including and how much space is needed between each char though
RectTransform scale should be at 1,1,1.
Change size with Height/ Width.
Don't have the font size < 1
The font might have chars that are chunkier than a "normal" font, then, I guess
just up the res a bit, until it works for you
never done it
what's wrong with a coroutine?
complicated doesn't neccessarily mean expensive
test it and profile it
Throw like 100 curved TMP's into a scene and see how it performs
What other colors can I add as skins in my game? :p
don't cross post
use #archived-works-in-progress or #archived-game-design for this sort of question
the question doesn't make much sense and the image shows us nothing
The color police will stop you from using these colors π
I'm still a beginner in Unity
Why did the image transparency not change? I'm trying to do an animation
I tried to imitate this video
https://youtu.be/br9YzpiBeIw?list=PL1aAeF6bPTB79bglSqRSZDjGbUHdUtjhs&t=718
π Support me and DOWNLOAD Unity project: https://www.patreon.com/posts/49141718?s=yt
β΄οΈ Animate your UI using code: https://youtu.be/YqMpVCPX2ls
This tutorial/guide will show you how to create stunning UI animations without writing a single line of code. Recently I showed you how to do that by coding the animation behaviour, but doing that usin...
Wheres your canvas?
Did you add canvas renderer to a regular game object. It also doesnt have a sprite renderer or image component so im confused
Whats that white shape coming from
Do I need thisΨ
It's a picture that I pulled out and put a bone on
nope
I mean yeah you need a canvas to use a canvas group
so just to be clear you should make a canvas, inside the canvas you add UI elements such as Images. (anything under the UI dropdown)
forgot to @
I'm having an issue understanding how Content Size Fitters are supposed to work. I've got a game object w/ a content size fitter and it's vertical fit set to "Preferred Size". I've got two child GameObjects (the header and content area) which each have a Layout Element with both Preferred and Min height set. However, the Content Size fitter always sets the parent game object's height to 0. I'm in prefab editing mode.
What am I doing wrong?
Content size fitter needs content to fit. https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-ContentSizeFitter.html
Yes, there are two sub game objects which both have content in them
The game object with the content size fitter on it is empty though, the CSF doesn't use children size
you need a layout element on the same object
so content size fitter... doesn't fit child objects?
not without a layout element..
(vert/ hori)
OK but as I noted and is visible in my screenshots, my child elements DO have Layout Elements in them.
and then I asked about child elements
that doesn't mean on the child element
In any case, what I want is for my box to expand to contain any children
well forget content size fitters then, if they don't do what I'm trying to do.
They do, you're using them incorrectly and didn't understand what you were told would work Β―_(γ)_/Β―
ok. How do I use them correctly. I've got a CSF on the parent game object. I've got layout elements on the children. What am I missing?
the vert or horizontal layout element on the CSF object, like I've said 3? times π
And I've got a Layout Element on the parent object too - it lets me set a "preferred height" but is unresponsive to any number of children
ver/horizontal layout elements don't have a preferred height
Don't bother with them, they decided to send insults in DM.
If i want to make a circle in UI... but cant use a image because i want to use the circle to transform an image into a circle... do i need to use the mask thingy?
Yes, if you want to show arbitrary image as a circle shape you'll have you use mask
Don't make people guess about the problem. Describe exactly what's the problem or desired behavior.
Problem: The UI that displays properly at 1366x768 does not at 1920x1080. desired thing: to render properly at any resolution. (In fact, you can understand the problem just by looking at the first 2 screenshots I took.)
Already gave you a manual link describing how to setup UI properly for any resolution.
Maybe someone could throw some common issues for ui to not detect mouse at all, I copied my whole canvas into new scene there button sees its being hovered over with exactly same setup but in main scene it does not no errors in console for them to lock up something
Make sure new scene has the EventManager
when you just create canvas for the first time it is created for you
Yea I was missing event system had it deleted cant remember why thanks
Right, EventSystem.
where?
Review my messages to you.
i want the score to be in that blackzone of the background image, but when i make a build and test it on my phone, the background image stretches to fit the phone res and the score is not on the black zone anymore, how to fix it?
There should be a recttransform that fits within the bounds of the blackzone. This recttransform is the parent of the text. The score text should be anchored to stretch to fit within the parent
And the score text should be set to auto size
hey ,im sorry if this sound dum, but for some reason my button isnt interactive
this is the property
and when it get click, it should send a console message
which i didnt recive
Got an event system in the scene?
Is there anything blocking the graphics cast?
ok my bad
i work out why
cause i made that the mouse alway stay at the center
so i couldnt be able to click it
that is my bad
im sorry
Also, side note, don't leave empty Start() , Awake() and Update() methods in your classes, they still have a (tiny) cost
i unlock the mouse and now its working
oh
thx
Any video suggestions on how to make the UI on mobile games more poppy and lively?
I'd suggest looking at the top mobile games and seeing what they do
Yess, I didd. I came across feel also but it seemed a bit overkill for mobile games. I tried using UI Particles plugin which worked pretty nicely but didnt satisfy me. So I tried making my own animations which forced me to make separate animations for each and every element which was extremely time consuming π Someone recommended Dotween so I am yet to try that.
Yep, DOTween is great
Ahh okiee, so the standard version is sufficient right?
Yeah, I've been using DOTween for years, never had a reason to even look at what the Pro does
Okayy thank youu, will learn how to use it then!
My previous company literally only got pro just to support the dev. The standard is great
Ahh that's cool. My company might not invest since I personally had to invest in feel, Particle Images and royalty free music and sfx π
How would one create a UI effect like this one?
where it looks like a low res display or whatever
How to make limited scroll?
Make the contect rect the size of the child elements
be specific with what you don't understand
Why dark blocks doesn't hide properly?
how can I get the power bar in the same position on both screen sizes? ive already changed it to scale with screen size
with proper anchoring and layout of your UI elements
I see alright thanks
So i have over 250 3d objects for character customisation. I have created a shop, but I need to display these objects as icons in the shop. Is it possible to do that without manually having to create a 2d sprite from each object and then upload it?
No matter where I anchor it it's the same. could it be a problem with my code where I'm changing its possition to a specific amount of pixels and thats different per screen?
ballPowerSlider.transform.position = cam.WorldToScreenPoint(ball.transform.position) + new Vector3(116.5f, 0, 0);
i often ran into issues for achors when my parent game objects had fucked up scale/width and etc.
not sure right now
i hate UI π
Absolutely yes if you're setting the position it's because of your code
Why are you setting the position in your code
im trying to make a power slider for a mini golf game and i want it to teleport to the right of the ball when I'm ready to shoot
https://pastebin.com/sahYy5zX
is there a better way I should be doing it?
basically a hud
you could use a world space canvas
alright but how do I make it show above my sprites
place it in front of them
i think u can do this with TextMeshProUGUI
Is it possible to scale children sprites with the parent image's rect transform width and height?
You could set the children to stretch
Look up any tutorial on making scalable UI on Unity and it should cover proper anchoring
Why whenever I open Unity, some UI elements are moved by Unity
It is super annoying
These texts for example
Or this entire Panel
Is this a Unity bug?
I am trying to make a box that encircles UI elements. I used GetWorldCorners, so now I know the area to encircle them in world space, but I'm struggling to get back to screen space
camera's WorldToScreenPoint does not work for me
Why is the settings icon getting squished and how can I fix that
make sure to enable the "preserve aspect" checkbox on the image
ah ok thanks π
How would one go about creating a scrollable panel where elements inside of it can be dragged and dropped into any position? Without strict grid etc.
Do I need to write a custom script to resize content container based on content?
Use a scroll view and the draggable functions
When i drop something outside of content scroll doesn't enable itself since content isnt resizing automatically
Fit content isnt working since it needs a layout group and it would disable the ability to drag elements to any position
I don't understand what you mean
Solved the issues by writing a function that checks all content children and calculates content container size based on their positions and sizes and then executing it whenever something gets dropped. Tho I had problems resizing rect transform with anchors being anything but 0 1, gladly 0 1 works fine since i'm not planning increasing it to the left\top side
im trying to make pages side by side but when i duplicate the image object inside horizontal layout group it squeeze them for one screen width, any ideas ?
You need a content size fitter on the Content GameObject so that it resizes with the children
nah tried all those
disable Control Child Size
then how am i gonna scale the image as screen width for per aspect ratio or resolution ?
The canvas scaler does that
how did you position your image?
i just drag and drop
make sure you use anchored position
you can just drop ui elmenets onto the screen like this
i used this like 2 days ago
so learn how to position ui elements.
you can't explain this right now ?
hold the alt key and choose one of these anchored positions.
then you can fine tune the x and y
@dark marsh UI is sorted by hierarchy. If you want something to be on top it goes to the bottom.
oh okay
yeah, that too, your ui image might be rendered behind the other elements. make sure to position them in the hierarchy as you want like Fogsight said
thanks for the help !
Is there a vid or something I can watch to get the basis of learning ui like menus, inventorys, ability timers and stuff like that ik how to do hp bard but not the other nesacary things
search !learn for ui stuff
π§βπ« Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
Hi all! I have written code for my UI, but it doesn't behave exactly as I intend. Can someone help? Not sure I should ask here. The issue is: my game should show the value of an enemy when it is destroyed. In my game I have 4 different prefabs for enemies, each having a unique point value. I want my game to show the value of the enemy destroyed. My game already succesfully shows and updates the total score. But not the value with which the score increases. Here is a video and my code. Can someone help?
https://gdl.space/ucecokibix.cpp
It's because you did this:
enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Enemy>();
you basically found one random enemy and are using that enemy's point value to show the text
why do you need this at all?
You should just do this:
public void Score(int scoreToAdd)
{
score += scoreToAdd;
scoreText.text = "Score: " + score; //Shows the current score number as part of the score text
scoreIncreaseText.text = "(+ " + scoreToAdd + ")";
}```
there's no need to get a reference to an enemy in this script at all
I don't need it, I just want it. π I've just learned about UI from the Junior Code learning path on Unity Learn. So I'm experimenting with it.
Can you explain why it makes no sense?
how would grabbing a random Enemy reference in Start tell you anything about the particular enemy that died at the moment an enemy dies?
Oh, you mean the code. I thought you meant it made no sense that I even want to show this in my game.
I'm learning Unity and am happy to make mistakes and learn.
how can i set anchors on image so that when the parent changes it stays 1:1
Tick the "preserve aspect ratio" box
thanks
sorry for the ignorant question 
I have this png that is big, i will scale it down so...
If i scale it down in unity will it look worse?
Is scaling it down outside of unity a better idea?
Test it
Hi guys! I have a problem with linerenderers and canvas. I have a canvas set to screenspace camera and some linerenderers drawn by code. The problem is the lines appears above the UI panels. I've tried with sorting groups and changing Z (if I change Z of the lines below -10 they don't get drawn but that's all) and no luck.
it looks like unity scales it down a lot better than an online tool
but no idea why
photoshop seems to do better than online tool but also worse
That sounds like you're trying to curve it when the mesh isn't ready to be manipulated
I assume when it's disabled, because there is no mesh being rendered, you can't curve it yet.
sometimes the scale on an object in my canvas gets set to 0, Im not sure why this happens. It doesnt happen too often but still annoying
Canβt think of anything that changes the scale automatically.. as scale should be left at 1,1,1.
The content size fitter will change the width/ height automatically, and will set them to 0 if thereβs no image or vertical/ horizontal layout element on the same game object
Did you just try to @ everyone lol
im making the scroll rect like this
but the problem is
when i change the screen ratio
it looks like this
so i can't scroll to the bottom of the square
like this
how can i fix this problem
what im I using
yeah.. that's what i told you before too
#π»βcode-beginner message
https://hst.sh/ihotamizom.csharp all related code + profiler trace and what components prefab is made out of im getting micro stutter when instantiating this prefab for the first time afterwards there are no such lag spikes anymore anyone knows how this happens? I need to dummy instantiate effect to warm it up or something before game starts?
Hi, I have a problem with TextMeshPro text, so basically I don't have a 4k monitor or ANYTHING close to it but when I set the resolution in the editor to 4K the text becomes a lot more crisp and nice looking, but when I set the game to free aspect or any other aspect the text becomes blurry again like the picture on the left
Don't use free aspect when dealing with UI, it's impossible to setup your anchors correctly.
Make sure all UI elements have a scale of 1,1,1
Font size for TMP should be > 1
oh, didn't notice, i just tried finding the video
just checked
all the scales are 1 1 1
the font size is 0.6 but that's because I'm using world space mode
the width/ height are tiny
of the canvas or the text?
Put the canvas as a child of an empty game object, with a normal transform.
Set the scale of this transform to 0.002, 0.002, 0.002
Set the scale of the canvas to 1,1,1 (and all the children)
You can then use normal sizes for width/ height
or just set the canvas scale to 0.002
hmmm nope, it looks worse now
because you need to size everything up
the problem is it only looks crisp and good when I set to 4K
yes I did and it looked bad
you put the width/ height to something like 50/50? and the font size to something like 30?
yes
and all the scales are 1,1,1?
for the entire UI hierachy, except the top one set at 0.002?
yes
larger than default
this UI will contain a list of names, that could be sorted, also would have tags/labels.
There's something else going on, the setup I just suggested is what I use for all my world space UI.
What you were already using is far too small, the font is 0.6 on 4 pixels
type your question/ problem in 1 message, don't press enter after each line.
so what should I do?
I'm out of suggestions, I would need to dig around in the setup of the UI to figure it out
thanks for helping Carwash, much appreciated, the text does not look bad I just wish it could look like the upscaled one but it's okay, I'll dig deeper and if I don't find a solution I'll just settle with what I currently have
this is another example from the main menu and as you can see the glow spreads in my native resolution but doesn't and is more crisp when I put it in 4K
this does not make sense since my screen is not 4K
i tried putting it into onenable instead of start to make it so it gets called each time the gameobject gets enabled, but it still doesnt work
OnEnable() is called before Start()
https://docs.unity3d.com/Manual/ExecutionOrder.html
Log out the verts (or whatever makes sense to check) in Awake/ OnEnable/ Start and see if / when they become present
Dont use the 16:9 aspect. Just make your game for popular resolutions. Whats your base resolution of the canvas?
1366 x 768
I want the text to look crisp like it does on 4K but on all resolutions
Thats really big and doesnt scale to 1080
Are you drawing your pixel art in that large of a canvas?
ohhh wait
no sorry here is the base resolution
here is the canvas scaler
it differs from canvas to canvas
this one is the main menu's
Thats a weird resolution, you should make it small and scale it up if you are using pixel art popular resolutions like 320/180 since that scales to 720p, 1080p and 1440p
The canvas scaler basically you want to put your lowest resolution in it and it will scale up to higher popular resolutions
Are you making pixel art?
no
actually the menus I showed are just textmeshpro text elements
I'm using a pixel art font though
the whole game is pixel art, but the big difference between the normal resolution and the 4K res is only the text
I have noticed something, the lesser the value of this scale thing in the editor, the more crisp text is
the scale doesnt matter, its an illusion only for the editor. Your real game doesnt interact with that scale bar at all. If you build and run your game you can see how it will look.
yes I wanted to say that, I tried doing the same thing in the build and it did not work.
another thing I noticed is, the text lights up because of the post processing that's affecting it, but when reducing that inspector scale it glows less
I found it, it's the bloom affecting the text, it looks perfect now but that's only the main menu
hello i want to creat an interaction menu but he is too big how i can low the scaale ?
really too big lol
you don't
this is how canvases work
the big canvas rectangle is representative of your screen
if you put a UI element in the center of the canvas, it will be in the center of the screen
what?
there is the game
Look at the Game window to see what the game will look like
its normal
irrelevant
there ya go π
ohh okay okay i think i see
so all ui element will be see in the canva but other thing will not apear ?
Will not appear where?
(sorry for my bad english btw)
don't get confused by scene view
in the canva
scene view is just to layout your scene
Canvases are for UI elements only
okay okay thanks man
its very hard to learn unity
i learn with chat gpt lol
i don't know if its a good idea
It is not a good idea
If you want the ui to be smaller while editing you can do screen space camera instead of overlay.
Yeah. I've always ignored it
thanks i see
i have to remove scroll rect to make it disappear
but remove scroll rect make this nonsense lol
I have several sanity check questions.
I have a 2d game with a lot of canvas objects, usually one per prefab. Is this okay? Do I like, want a canvas object to group a set of child sprites, or do I want to maintain one for the entire scene? or do I just want one per sprite? Same question for graphic raycasters.
if I add a button component to a sprite, what else do I need to add to make it clickable? I have an event manager in the scene root already.
you put a group of UI under a canvas if the group is going to be updated frequently
the idea is that if something in a Canvas's hierarchy changes, the entire Canvas is marked as dirty, so if there's a particular hierarchy of items that changes often, you should probably put them under a nested Canvas
you put graphic raycasters on canvases that have elements that will be interacted with
you just need to make sure the Image is marked as a raycast target as well, which it should be by default
that makes sense, thanks
if you want more optimization tips, there's a link on that that's pinned in this very channel
during runtime I'm noting that canvases that exist under another canvas's hierarchy get a different inspector view, the event camera field disappears, etc. is it optimising them away?
i'm not sure about that. I've never paid attention to the event camera field
cheers
are you using world space canvases?
yup
i'm afraid I dont have much experience with those, but the concept should be the same
it's probably that the nested canvases are using the same event camera as the parent
that's okay, I'm slowly puzzling my way through how it all works
so it doesnt make sense for it to be exposed
I was hoping that was the case
got it. I've been using sprite renderer components rather than an image component
my image component works as expected for everything
Rule of thumb is if it's going on Canvas, use Images
Not sure if this is the correct place, but!
How does UI work in Unity when it comes to hierarchy? For example, a ContainerPanel(?) that extends Panel(?) keeps track of x amount of items, and makes the appropriate buttons, linking the interactions between the inventory supplied in the constructor, and the button clicks
Is this available? Can I just extend a Panel with a custom Start method, and keep on chaining? Or would that not be intended
There are no classes called Panel or ContainerPanel.
No idea what kind of "linking" you mean.
Hi, I'm trying to make an achievement panel, I've made the panel with images and text, it's on the Canvas, but I want it to spawn off screen and wipe in from the side, wait a few seconds, and wipe back off screen and destroy, I think I'm just missing the rect transform part, I keep getting the coordinates wrong, I'm trying to use a vector three, do I need to convert to screen coords? I think it's using world space
You want to change the position of a UI element?
One which has recttransform?
You need to change the anchoredPosition
Let's say I want to have a base screen that has an X for closing, a title, whatever.
Then I want to "extend" from it, have an inventory screen with special setup
(By linking I mean button1 action = inventory[1].decrement() or something.)
Thank you, do I use a regular vector2 or do I need to do some world to screen conversion, or does anchoredPosition use screen coordinate
anchoredPosition uses the values you set in the RectTransform, you don't need to do any conversions
i know there's a technique to create rounded rectangles for ui, where you slice up a sprite into 9 slices n stuff
but that doesn't work with the sprite renderer
does anyone have a workaround?
can you parent the text object to something else and disable the object it is parented to instead of the tmp object?
What makes you think it doesn't work for SpriteRenderer?
define "didn't work"?
ok so
when i did the thing where i cut it up into 9 slices in the sprite editor, and put it as an image, i could scale it around and it would give me rounded corners
when i put it as a spriterenderer, it's just a circle that's squashed and stretched
like, a normal circle
Did you follow the instructions? https://docs.unity3d.com/Manual/9SliceSprites.html
(after the slicing part)
Did you read this?
When a Spriteβs Draw Mode is set to Sliced, you can choose to change the size using the Size property on the Sprite Renderer or the Rect Transform Tool. You can still scale the Sprite using the Transform properties or the Transform Tool; however, the Transform scales the Sprite without applying the 9-slicing.
for some reason when i adjust my scroll view height, the scrollbar handle just dissapears when starting the game, anyone know a fix??
Show your scrollrect inspector
Because not all games want to show their scrollbar all the time?
makes sense
You're welcome
How could I create grid lines? I'm trying to make a grid for my game that uses a scoring system. It should look like this :
Is ther any good and free solution for writing uis wir html and css?
Ugui doesnβt use html or css
Does anyone have any ida what could be happening here?
I'm trying to render some "Lines" (It's a prefab with an image). Here's my code to render them:
int currentLine = 1;
for (int i = 0; i < lines; i++)
{
GameObject newLine = Instantiate(Line, LineParent, false);
newLine.transform.localPosition = new Vector3(currentX - LineParent.rect.width, 0f, 0f);
Debug.Log(newLine.transform.localPosition.y);
currentX += step;
}
Everything works as expected, except for when the localposition.y reads 0, but in the scene it is not:
The rect transform inspector shows anchoredPosition, not localPosition
thankk you, chaned it to set the anchoredPosition and works perfect!
Hello friends! i could use some help, am not entirely sure this is the correct place to ask for it
Do i post my issue here, wait for someone to message me, or find a better place to post it guys?
Pretty much impossible to say without knowing what the issue is about
If it's related to UI (UGUI) ask here, if it's the new UI toolkit then #π§°βui-toolkit .. if it's neither, look through #πβfind-a-channel (this is useful reading https://dontasktoask.com/)
The Unity Documentation appears to be outdated for 2022 versions on this matter:
Does anyone have a strategy they can recommend for an art pipeline that targets 4k and scales down nicely to 1080p? I was considering using mipmaps but I don't like the blurriness you get when you scale down
Wrong channel, ask in #π οΈβprobuilder
hey, a while ago I probably did something that I don't know, and now my UI is broken, the buttons are not clickable anymore, but I have an event system in the scene, and it, and the button itself is enabled, the button component is enabled, the Interactable checkbox is checked, and the text on the button has Raycast Target checked on Extra Settings, I already searched, watched YouTube videos, everything is fine for me, but the buttons are still unclickable, what do I do?
No idea how the UI works with the new input system, but you can include both in the project. Player Settings
it's on Both
but it is still not working
I also tried making a new button incase the ones that I had were the problem, but the new one is also not clickable
Check list
- Active Event System loaded
- Canvas has
Graphic Raycastercomponent - Nothing is blocking the graphics cast hitting the buttons
- All
Canvas Groupsin the hierarchy, from the button up, are allowing interaction - The button image has the
Raycast Targetfield ticked
Use the Event System to see what your mouse is hitting
by the way, in the "First Selected" on the Event System, should it have something?
only if you want it as something
also, my event system has only this
at runtime?
yes
and does it have these?
it doesn't have Base Input
That's only there at runtime
it didn't get added by default, I added it manually, and there is no change
do I need to change something in the component?
nope
Delete and remake the event system? Probably won't make a difference.. try it anyway
still the same
I created a new scene, and it's working on that one, I will just move everything
That will confirm whether or not it's the UI setup that's the problem
I moved everything, and it seems that I have something that's breaking the buttons
I will just recreate everything in another scene, carefully this time
At runtime, if you swap to the scene view.. and click the button - what gets selected?
the button
click it multiple times and does anything not to do with the button get selected?
the button is the only thing selected, there is nothing on top of it
These kinds of issues are so frustrating
yeah, just forget about it, I will remake everything on another scene, thanks for trying to help
Can someone help me create the UI for my game cuz I have no idea how to
like link a yt vid or smth
Learn ways to improve your understanding of how to design UI in Unity!
URP Examples: https://github.com/Unity-Technologies/UniversalRenderingExamples
Understanding Color: https://www.youtube.com/watch?v=Qj1FK8n7WgY
Designing A Loading Screen: https://www.youtube.com/watch?v=iXWFTgFNRdM
Dynamic Depth of Field: https://www.youtube.com/watch?v=7...
tysm
you don't need a tutorial to make UI, all you need is to look at another game's UI and make something similar, also making a good looking UI will take a long time, so take your time, and slowly work your way, it's simple
im looking at fnaf security breaches UI but I have no idea how unity UI works
You need a tutorial to make UI.. so you know how to do things
i'd say it's better u make functional UI before visually pleasing UI
define the layout (how your UI is positioned and what interactions it has)
Thats what im trying to do
then u can focus on making it all look pretty
got a sketch or general idea?
and have you determined what interactions u want ur ui to achieve?
can you provide a ss?
so basically play and options buttons?
and more
what more is there?
player name? is that something locally defined?
Im new to game development so idk what you mean
does the player define the name in the game or do they have to create an account or something, to then have their username retrieved
The player defines their name ingame
are you planning to use multiplayer or not?
no
then it's fairly simple :>
neat
I can help you in call if you prefer
I dont really like calling
then should I dm u?
yeah
aight
thanks
Hey, after loading a scene I have these UI elements that aren't correctly laid out (no proper spacing).
If I disable/enable the vertical layout group they are contained in, they are properly laid out. They are not added dynamically, everything is in the scene from the start.
Does anyone know why this happens and how to resolve it?
It looks exactly as if it's using the configured padding, but in negative (-50 instead of 50)
ss the inspector before/after
play with different resolutions in the game view window
indeed if I resize the game window it also redoes the layout
Never use 'free aspect' when developing or testing UI
it's set to 16:9
is canvas set to fit screen size?
yep
Set the Canvas Scalar to scale with screen size -> set a reference resolution -> move the slider to where you want it for scale with height/ width
before after is nothing special (it just redid the layout clearly)
it's set to that
I'm thinking the issue might be something like that
cuz I think the spacing is between the anchor points no?
I think it's why it gets smushed like that
I don't know any actual solution, but maybe increasing the spacing might be a good workaround
Make sure the images have 'preserve aspect' ticked
Then enable these 4
Just checking Control Child Size -> Height seems to make the difference between proper initialization or not in my case
that sounds like one of the weird quirks of the UI system
I'll write a bug report
good luck
hey, is there a way to make UI/canvas stay scale or like match with the screen resoultion
i tried changing it,but it arnt working out
@uneven ferry βοΈ
ok
Hey guys i have input field for my game and was wonderiing how can i get an input field to accept both inters and decimal values?
bc right now it can only accept one or the other
Question. I am getting weird warping of a world space canvas when I rotate it. It is a child object(but of normal GameObjects, aka Transforms not RectTransforms). I am rotating the parent Transform, but it seems to happen on the RectTransform also.
It looks like the canvas is beings Rotated and stretched.
How do I fix this?
And of course I figure it out after writing out my problem. The root object was a SuperTextMesh which for somereason was causing this effect, if I change the root to a normal gameObject it is fine.
Having a brainfart. I know there are things like IPointerClickHandler and stuff like that but is there any handler interface for receiving/losing focus?
I just need help with math. So I have an image, and I want the image to start at a size of 0, and when you go inside the green zone, the size of the image will increase the closer you get to the black rectangle in the middle
Anyone know how to stop a ui element from being added to the UI navigation selectable? Text is even showing up and selectable by the event system.
Can i see the text objects that are working with the event system?
I was under the impression only buttons are navigatable with the event system.
Buttons can have text child objects though
That's what I thought as well, but form some reason they are showing up as a navigational element, will send example when I'm at my desk.
I have two canvases and I'd like to block one with another (ie you cant interact with anything on the other while it is displayed)
One Canvas is on the "Interface" layer, with its interactive elements having a Graphic Raycaster that have a blocking mask set to "Interface"
Over this I display another canvas set to the "Overlay" layer,
it has a fullscreen image with raycast target ON, and a Graphic Raycaster set to Everything, and a Canvas Group whose BlockRaycasts are ON
Both canvases are set to "Screenspace - Camera" and are rendered to two different cameras, the "Interface" layer is rendered to a "Text Camera" and the other to an "Overlay Camera". The Text Camera is under the Overlay Camera in the stack order on my URP camera and they are both set to their respective volume and culling masks (Overlay on Overlay, Interface on Interface).
This second canvas is meant to make it so that when it displays, the stuff on "Interface" doesnt receive any input, but if I make the fullscreen image half opacity and mouse over buttons on the Interface layer, they get highlighted and can be interacted with.
What am I doing wrong?
I meant the inspector
I think that i did something wrong with my scroll rect but idk what. my panel doesnt expand and when it does it expands both ways instead of just downwards. So at the moment it doesnt scroll
when i add new object it goes up like this
when i set vertical fit to min it goes up
I'm trying to create a UI element like this. That can grow and shrink automatically based on how much text there is inside it (showing number of coins)
I've attached the sprite setup I'm using as well. I cannot get this to work. I've watched so many videos and read the auto-layout docs and it's just not working.
The closest I've gotten is with the following setup. Which does auto-grow for text. But will not shrink when there is little amount of text.
If I could just figure out how to get this min width down, it would work! But I have no idea where this minimum width is coming from.
any help would be much appreciated
Hi, can I check if the coin image is a tmp sprite asset?
Or is it part of the background
Oh, I see you have it almost set up..
I think you can try adding layout element on the text
And set the min
On the actual text mesh pro game object?
I just tried that. Still no luck. The text just wont reduce beyond the seemingly arbitrary width it is now
Is your background image sliced?
Just to be clear, is the issue that the background image isn't shirking further beyond a specific width?
@sterile wedge yes, it is sliced. In the original message I attached a screenshot showing the slicing
Yep. I expect it to reduce down so that there isn't much space around the text if there's only a character or two
But it won't shrink down beyond a certain point
Thank you for your time btw.
Don't know if this will help, but maybe try reducing the text margins under the extra settings in the tmp component
Sorry I just pop in and out
Hey :> I'm trying to make this cool slider where the gradient fill would look smooth with a mask and I'm wondering, how do you make it so that a UI element doesn't scale at all with its parent? Cuz my fill scales with my mask, and it gives... unwanted results. Overall, is there a way to disable this completely?
Click that and pick anything that isn't stretch(blue color)
still behaves weirdly
I recorded it wait
so yeah, either way it doesn't behave like I wanted it to...
Hey, how do you render a World Space Canvas over the entire game? I thought world space canvas meant it would render on top of everything in the scene (models/vfx/etc), but seems like it only places it in physical space. I've looked at documentation/tutorials/threads but can't seem to figure out why it won't render on top.
I've tried setting the Layer and Sorting Layer to UI but it still won't render in the camera. I set the CameraUI to "see" only the UI layer.
Do I need some kind of special script/shader to render reticles over the entire world (but beneath canvas)?
nvm figured it out. Had to create a separate camera that follows the main one. Same standard settings, it just needs to be moving in world space. Previously it was static (sitting in one spot like the UI) so it was off-screen
Using ISelectHandler, how would I tell if I'm being selected by a gamepad or not?
does anyone know why the content is not expanding? 
needs a ContentSizeFitter
what should i set it to? i want items to go down
set what to
if you want the size expansion to go down you need to set the pivot to the top
right now your pivot is in the middle
so it's expanding both ways
like this? or is it the blue circle?
nothing visually changes when i change it other than the pos but it worked thx
why is pos x saying 408 tho
shouldnt it be 0
you set the pivot to the right side
I would have expected a pivot of (0.5, 1) for this setup
hey guys, I'm new with unity, I'm trying to develop a mobile game and everything was going great but things started going downhill when I tried to make it compatible with all the mobile platforms (hence different resolution) ... can someone please help? thanks in advance
I managed to fix the problem with background, UI images, UI textes and UI button, but I can't make it work for the loading bar
this is how it looks on "game window" (I know it looks bad, it's just a prototype)
this is how it looks on "game window" (I know it looks bad, it's just a prototype)
And this is how it is when I'm in simulator view
is there a way to delete or edit this bar?
if you use anchors it'll keep their ratio/size proportional to the screen size . . .
hang on
so I don't need any kind of script?
nope, not sure why/what you have a script for . . .
ok
let me try
let's say I want to keep the ratio/size proportional to screen size of the background
I just need to set anchor to this one
and it works fine
the problem manifests when I try to do this with this loading bar:
it doesn't keep the ratio/size proportional to screen size of the loading bar and it's filling
the script is to anchor things UI things in the same position after the scale
when i build the game it comes in fullscreen 
you're using a separate canvas for the ui. is the canvas scalar setup the same. i have no idea what the script is doing or why it's there, so i don't know what it's affecting . . .
U were right, the script wasn't doing anything lol... u mean that I need to have only 1 canvas?
I removed the script and everything works fine... but the panel inside the loading bar is still scaling differently than the loading bar itself
after some more research I found out that it's like if my purple panel is trying to keep the same distance from the borders of the screen, which is fine, until the space left by the the loading bar is different from the one occupied by the panel ('cause the loading bar is keeping the same distance of the screen borders as well)... is there any way to anchor the purple panel to the loading bar (like anchoring an image to another one) or another way of fixing this? thanks
the panel inside the loading bar should stretch on both axes with the loading bar . . .
I'll record the screen and show you
is the purple bar the fill area GameObject?
no
it's "panel"
i don't see a panel GameObject in your scene hierarchy . . .
i'm not sure which object you're talking about. from the pics, the purple bar should be the fill area of the loading bar, right?
it's inside of "fill area"
but there's another object
@golden cave https://drive.google.com/file/d/1geo0yK2E37c74uk9v6jcGHhYKsS6yljp/view?usp=sharing here's a video of the situation
did you adjust the values: Left, Right, Top, Bottom, of the LoadingBar anchor after you set it to stretch?
mh... no?
what do I need to adjust them to?
there's no way i (we) can tell since it's your images and setup. just set the anchors where you want the loading bar to be, then zero out all the values . . .
yeah, but what if I need different values?
you shouldn't, the anchors are a percentage. it'll always be the same percentage of the parent image that it stretches along with . . .
I don't get it
let's say that to make it look normal I have those stats on the "FillArea" object (the purple panel)
and it looks perfect in "game" mode
then I change it to simulator mode (with a Samsung Galaxy Z fold2 in portrait mode) and this is what I see
which means I need those stats to make it look regular
it doesn't change them automatically, how can I do that?
because you have hard-coded values for the position. Left and Right will always be set to 189 pixels away from the anchor . . .
you need to align the anchors of X to the inside of the black bar then reset the Left/Right values to 0 . . .
DUDE I LOVE YOU
I LITERALLY LOVE YOU
OMG
it's 4am and I've been struggling on this for 4h straight
it works
please marry me
don't ask me, ask my daddy . . .
I definately will
hello, im building MainMenu and Pause Menu, so far it works good but!
when i press pause, it opens pause ui, then if i go to options menu, and close pause menu, open it again, it opens in last menu i've been, this case options
how to make it go always on that first pause ui instead remembering last chosen?
Hey, what would be a good way to not get overlapping text with textmeshpro?
So I'm having a wierd issue where I made my UI elements a prefab and the buttons no longer work. It gives me this error, however I do have the reference set in the inspector.
You probably need to assign the pauseMenuWindow variable of the UIPauseMenuController script in the inspector.```
Everything worked before I made it into a prefab.
seems pretty clear - you have unassigned variables that you need to assign in the inspector
That's what it says but they are assigned, that's why I am confused.
THere's some copy of that script where they are not assigned
Ok there is only one copy, now the prefab itself doesn't have anything assigned but the copy that is in my scene does
then here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
public class UIPauseMenuController : MonoBehaviour
{
[SerializeField] GameObject pauseMenuWindow;
[SerializeField] GameObject settingsMenuWindow;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnPause()
{
if (pauseMenuWindow.activeInHierarchy == false)
{
pauseMenuWindow.SetActive(true);
Time.timeScale = 0f;
}
else
{
pauseMenuWindow.SetActive(false);
Time.timeScale = 1f;
}
}
public void PauseMenuResumeButton_OnClick()
{
pauseMenuWindow.SetActive(false);
Time.timeScale = 1f;
}
public void PauseMenuSettingsButton_OnClick()
{
settingsMenuWindow.SetActive(true);
}
public void PauseMenuMainMenuButton_OnClick()
{
SceneManager.LoadScene("MainMenuScene");
}
public void PauseMenuQuitButton_OnClick()
{
Application.Quit();
}
}
I want to make the image(left) to make it pixel perfect like the sprite(right). Ive set the image to native size. Why is the image so much smaller ?
Your canvas reference pixel per unit is the same as your sprites?
If not make then equal then youll have to click native size again
yes, the caret can be changed in TMP_InputField
it has some public fields for caret
because it's set to its native size
In case someone needs this, only took me 2 hours to get to this point:
If you want to show a inputfield only after a key is pressed, here is a way to do it:
public void Open(char start_value)
{
gameObject.SetActive(true);
input.text = start_value.ToString();
EventSystem.current.SetSelectedGameObject(gameObject);
input.selectionAnchorPosition = 1;
input.selectionFocusPosition = 1;
}
start_value is the keypress.
Can be gotten from, for instance, Keyboard.current.onTextInput += OnTextInput
Actually, scratch that, it's unreliable, too π¦
Is it not possible to keep a text field focused?
Hi all! Is it possible to prevent streching when trying to assign sprites to an Image that have different sizes and aspect ratios?
Check the preserve aspect box
Thank you! Didnt see it at first because no sprite was assigned in editor
#archived-code-advanced message
got my own answer
Hey, am i allowed to post screenshots and ask for help here?
That is why you were told to come here and post screenshots..
Okay, yeah- so my Unity tab is still loading up. but i'm having trouble figuring out what to do after it loads up for a start button.
"Unity tab" isn't a thing, this term makes no sense
I suggest going to !learn searching for UI and doing the UI lessons
π§βπ« Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
okay.
i have a tmp input field and when i hit backspace the first time, the rect transform values are changing a bit. any idea why or how to stop that?
How do i make "Area" expand to the same size as the objects inside it? do i need to put a vertical layout group inside of Area?
Content Size Fitter. Didn't we solve this yesterday?
Hey, I have come here today to ask you all for help. π
Does anyone here understand RectTransform? Like, really understand? Grok them, even?
Please teach me, sensei. π
I'd like to know, for a "window" that I'm rendering:
- the center of its title bar (or rather - I'd like to place it so the center of its title bar is under the current pointer position in PointerEventData)
- the center of its title bar WHEN ROTATED +/- 90Β° around Z
- optional: offset it from the edges of the screen so that it no longer overlaps the edges.
- optional: the above, but if rotated +/- 90Β° around Z
Sample video shows my dockable window, but I'm struggling with:
- docking it centered to the Y where the mouse left the screen
- restoring (un-rotating) it under the mouse, e.g. with the mouse cursor at the center of the title bar.
- possibly moving it back into the screen on double-click (which I use to minimize/maximize already)
The window is a vertical layout group containing 3 elements: Title, bar, a search bar (always hidden in video), and the content area (also hides on docking/minimizing).
Second pic shows what the anchor currently looks like for it. (the anchor is at the top left of the canvas)
Third picture shows the anchor of the title bar.
...
Any input or suggestions greatly appreciated, I'm really confused by now, even though I'm very close and just need to fix up my "FinalizePosition" method that gets called in OnEndDrag.
My problem is not with rotations of transforms, it's with expressing screen coordinates in UI space, and vice versa π
ye i put a vertical layout group in area and it works... but sounds wrong since is not really doing anything
what if you put a layout element on the child objects
I'm not in the headspace to help right now but I think what you've got here looks pretty cool so far π
Thanks π And yeah, these are really a mind wracking "second 90% of the problem". π
I noticed the font in my game is a bit choppy/missing AA.
Any thoughts on this? Using TMPro.
After many hacks, I found a workable status quo by placing the Pivot of the window at the center of the title bar.
Needs a little bit of polish but is totally usable now.
Hi there! Quick question, if you have a scene with a lot of UI that gets displayed throughout the game, what's common practice for having the elements displayed in the scene view (before playing the game) βfor example,Β should they start in-active in the game, or start active and hide them on start? Any thoughts would be helpful here!
Thank you
i would check how you are scaling the elements , that's worked for me in the past.
Hide them in Awake, but Start is also appropriate.
Ok thank you
Scaling for them is just done via the actual font size, not the scaling in Unity.
I want to ask to guide me. It is more about world space canvas. Long time ago I was creating canvas via sizes like width x height -> 1024x1024 and then scaled it down to fit my 3D environment. But now I am thinking was it the scales like 0.001 or 0.003 looks quite weird. And why I did not just reduce the width and height by that amount and leave scale alone. Performance wise I believe there is no real difference, right? But workflow which is better workflow, have world canvas at high numbers representing resolutions and reduce with scale. Or reduce the scale immediately for all worldspace canvases?
I believe I did this because of world space fonts were not scaling well, aka if your set Height x width to 0.01024 x 0.01024 the fonts sizee messes up and getss choppy
and it is better to have one canvas with multiple images in world space or have canvas for each image if they are not connected and static.
hello, i have two buttons on screen that move object left and right and i use the Event Trigger component to fire off PointerDown and PointerUp events to detect when the button is being held and released
the issue i have is that i want to be able to drag the cursor between the buttons and them activate respectively
my only option is to use PointerEnter and PointerExit events or is there a simpler solution for this situation?
All of a sudden my textmeshpro text disappears when its over gameobjects (in the game view), any idea what could have caused this? Canvas is set to scale with screen size and render mode is screen space - overlay
