#๐ฒโui-ux
1 messages ยท Page 30 of 1
Idk specifically about onKeyPress type events, but in theory you should be able to start a timer when the button is pressed, and then end it & use the current value for the jump when released
Not 100% sure on how it works with touch input, but I would generally use IPointerDown and IPointerUp for if I were doing that with mouse input, so idk if that would work for touch input? There's probably an alternative version for each with the touch module if not
nvm I just fucekd the image up
Good day everyone im trying to make a 3D INGAME control panel, How can i improve the Visual Of the control panel. i.e Which options can i manipulate or is it possible to add images as the UI of the ingame control panel
im using textmesh for context
make the image not fill the parent slider
im not sure if im in the right channel but the button only shows in my editor and not in the game scene. why is this?
How are the anchors for your button set up?
UI is sorted by order in hierarchy, lowest is on top.
i fixed it by moving my UI elements to the center of the canvas and scaling them up
Your logo was lower and covering the button.
If you look closely at your screenshot the button was actually showing - really tiny in the bottom left
I have a panel that I put my own custom shader on, and in the scene viewer it looks fine, but in the simulator it shows it as just plain red, any ideas?
Is it possible to use buttons with a screenspace - camera canvas? My buttons only seem to work with screenspace - overlay, however I can't have my post-processing or transparency then
yes, buttons work in all three canvas modes
Huh okay, thanks. My buttons just seem to be broken
oh no they are working, they just seem to have hitboxes that arent in the correct spots
It seems the hitboxes are staying stationary and not moving with the camera
Hitboxes aren't a thing in Unity, clarify what you actually mean
the area where you click/mouse over for the button to register is offset to a different location
right.. but did you put a component on it to achieve that?
Because the UI uses graphics casting for hit detection.. you don't add anything to it. An image component with the 'raycast target' bool ticked will detected pointer interaction.. the "hitbox" can't be in a different location by default - unless you're doing something additional
I added the button component to an image to create the button and when I hover over the image it doesnt register, but if I hover in the area above the image, it detects it
you're gonna have to show the setup
sounds like you've got something offset that's invisible
These 4 buttons are the ones with the weird detection. I have one selected to show the bounds of it
inspedctor looks like this
show the inspector for all three (EquipmentButton, Background, Foreground) and INCLUDE the RectTransform
The weird behaviour is specifically with the camera it seems as moving the camera causes the offset to shift
I doubt this has an affect on the issue.. but how come you've got the Z pos at something other than 0?
I dont know... I dont recall ever touching that
set it to 0 and it still has the issue though
Check the hierarchy up from EquipmentButton - is everything at a scale of 1,1,1 ; any rotation changes? ; Z pos changes?
Looks like only these need checking - PopupMenu -> HUD2.0 -> Canvas
canvas may be - lemme see
Yeah, that's fine - it does it all automatically, because it's scaling to fit within the frustrum of the camera
ah ok
and the distance from the camera set by 'Plane Distance'
did zeroing this out make a difference?
unfortunately no
see at the bottom of the inspector, there's a little bar ? has like three lines crossing it
the little preview one?
Click it to pop it open.
Select the 'event system' game object and lock the inspector.
Run the game, as you move the mouse cursor around, the info in that section updates, you can see if/ what the cursor is hovering over
yep
and also check these three at run time, see if the transform values change
I somehow just managed to lose the three bar preview window thing. Is there a way to bring it back?
oh nvm
found it
it's always there, you just click the bar for it to toggle hidden/ show.. and you can drag it to make it smaller/ larger
well it was there and now its gone
it used to be inline with preview
oh i see
dock preview to inspector
That looks different to what I'm used to - are you using U6 ?
I don't think URP makes a diff to this bit
its really strange as if the camera points slightly up or down, the detection is thrown off, but if its perfectly lined up with the original scene view, it works perfectly
Oh, the preview isn't there for me either in 2022
oh wait, are you using the new input system ?
uhhh let me check I've been working on this with others but they're all away for the holidays
project settings -> player -> other settings -> part way down under 'Active Input Handling*'
you have both enabled so could be using the new one in game not old
I dunno if that makes a difference here, I've not used the new one with UI
this the new one?
yep
I've no idea if that has the info panel that the event system on the old input system has
doesnt seem to
I'm afraid I'm out of ideas
thanks anyway haha, its a very bizarre issue
My suspicion is that its something going with the various cameras since moving the camera drastically changes the location
have you got multiple cameras?
yup
maybe they're not rotating together, either at all or fully?
the canvas is rendering to an overlay camera and the main camera has some cinemachine stuff going on
as a test, move the canvas to the main camera
well it hides behind all the objects in the scene which is a bit difficult, but looking at the skybox allows me to see it. Doesnt seem to solve the issue though
you can just change the plane distance to a low number
I havent seen a plane distance option anywhere
oh nevermind
duh
xD
okay its still having the issue
if I look up or down it throws it off. If I turn and look around it works fine though
yeah default is 0.3 and 1000 .. doesn't feel like this is going to help
yeah definetly not
maybe lower the plane distance on the canvas to 10
as a test at least, I'm not aware of what knock on affects it may have for your game
thaqt seems to have made it more innacurrate
but on the horizontal
like now theyre offset to the left
almost an entire button to the left
so if you put it back to 100 and change the near clipping plane on the camera to 90 or even 100, what does that do ?
its a little offset
but less?
though now its almost as if its offsetting along a diagonal?
๐
hooo boy this is a hell of an offset now xD
I looked up and to the left a bit and the offset went down and to the right
whereas when I looked up just a little, it went down and to the left
oh wait
I think I have an idea
I just went 3D view
something tells me the issue might be the rotation of cameras
xD
so the UI camera isn't being rotated?
No the UI camera was rotated 180 degrees in relation to the main cam
I know what caused that
currently our player has a bit of a problem where the controls invert if you rotate the player to face any direction other than y=0
its weird as in-game turning is fine and everything, but if the player is facing any direction other than y=0 prior pressing start, the controls are all messed up
so the Ui camera had been rotated to match the main camera prior to being made a child of it
or at least to make placing the UI easier since its inverted in the scene viewer for some reason
scene
game
its very dumb whatever is going on with the cameras
now unfortunately setting the rotation to 0 didnt seem to fix it
it only made it so that if you look up, the offset also goes up and to the left
rather than down and to the right
so now it's a child of the main camera and rotated to match (0,0,0)?
yeah
well it was already child before
but now its 0,0,0 on the rotation
if I leave it at this level the detection is in line with button
looking up just slightly causes it to move here though
when it's like this or even further out of alignment, what do the frustrums for the cameras look like in the scene view?
okay the diagonal nonsense is resolved but theyre still offsetting vertically
which I suspect is due to the fov
nope
the selected camera here hasn't rotated with the other one - this would / could account for the offset
that didnt solve it
if the UI camera isn't rotating with the main cam 1:1, it looks like that would cause issues
plane distance doesnt seem to change it
my next thought is its probably the cinemachine causing it
I don't see how, but investigate
If I disable it, the camera freaks out, but if I press escape to access the buttons, it snaps into place locked the correct y rotation/level for the buttons to be perfectly aligned
its having a fun time it seems
this is with it enabled
gameview looks fine though, despite the offset still
I would say it hasn't been disabled if it's doing that
oh thats with it enabled again, my bad. Shouldve worded that better
Though that seems unrelated to the current issue
Okay so little update
had to adjust a few things and it still is broken
but this is the current state of it
if I look forwards/eye level its perfect
if I look directly up as far as the camera allows it does offsets to here
and if I look down as far as it allows it offsets down here
so theres still some horizontal motion it seems but only once the camera has tilted further up or down i guess
interesting update #2:
moving a UI asset along the Y axis in scene causes it to move diagonally
so what is getting "offset" here, exactly?
I'm having trouble understanding what's going on
the area where you can mouseover/select a button with the cursor
it seems to completely disconnect from the buttons themselves
So you have a main camera that's rendering the game world, and you have a second camera that a "Screen Space - Camera" canvas is following
yup
and I presume you've configured their culling masks so that they don't render the same things
yup
How does it look if you set the main camera to also render the UI?
I would expect to see a second copy of the interface that matches the places you can click
You may need to move the canvas closer so that it doesn't just wind up behind the wall
(the default camera distance is 100 meters, for some reason)
I dont seem able to get it to render on both
the canvas is specifically telling it to render to the overlay camera
and when I try to make it visible on the main camera whilst its doing that, it just doesnt show
my main suspicion is that the cinemachinefreelook camera one of the other team members set up to handle some other stuff, is interferring with it in some manner
since its whats controlling the rotation and vertical movement of the main camera
Due to the rotation caused by that camera, the canvas is ever so slightly rotated, which makes it so that when you move a UI element up or down, it moves along the Z axis closer or further away from the camera
If I switch it to render on the main camera though, nothing changes other than the intensity of the bloom on the UI
rotation shouldn't move anything closer/further away
are the transforms for the cameras at 1,1,1 for scale?
thats not me moving the ui. Thats it just on run
the Cam pos I mean
and yes I think so?
ah - I thought to two gifs were connected
yeah, that's fine
this part here is whats causing the x rotation on the main camera
which is whats causing the canvas in the scene to be on this angle
and if you move the UI up and down along that line, the z axis then would change
as you're getting closer or further away
though that cant be right as moving down, made it bigger, but that should move it away making it smaller
its really bizarre
though actually that shouldnt change the scale at all come to think of it, since its always the same distance away from the camera
just the camera itself is angled
and other objects in the scene dont move along the z axis when moving up
its just the UI stuff
oh my god
I figured out what was causing the z axis thing
my gizmo was set to global not local

doesnt solve the issue with the ingame offset button raycasts unfortunately
this makes me pretty suspicoius, given that your game view doesn't look like an magnitude 10 earthquake is hitting
if I disable the cinemachine brain or I disable the camera that's spazzing out, it actually does look like that is happening xD
you disable the camera that's moving around rapidly?
and that cause the screen to start shaking?
Enabled
Disabled
and if you press WASD at any point during the earthquake, the camera freezes in place until you let go
and if you press escape, it snaps to a normal angle where you can interact with the buttons perfectly
It sounds to me like you have multiple things trying to control the position of your camera
If the camera gets repositioned at the right moment in the update cycle, it could be in one place while handling UI input and then in another place during the final render
This would cause the offset
Oh, you know..
you have your cinemachine cameras parented to your main camera
That sounds catastrophic
this is the camera thats freaking out
The cinemachine camera is moving itself
since it's causing the main camera to move
wait wait wait, so the guy that set up the cinemachine, made the camera that moves a child of the maincamera?
Sure looks like it to me
You know, if you don't want the UI to be post-processed, why not just use a "Screen Space - Overlay" canvas?
Or do you want some post-processing; just different post-processing from the rest of the scene?
okay that fixed the spazzing camera but not the offset.
And yeah I'm specifically using screen-space camera for post-processing and shaders
You should also check that the canvas has the correct camera referenced
(it probably does)
one important thing is that the UI camera is not going to have the same FOV as the main camera. I wonder if that could mess up input
you'd need to manually copy the FOV over after Cinemachine is done setting camera properties
all...3?
I'm talking about the two Camera components here -- not the FOVs set on the cinemachine cameras
(or is "Enemy Scanner" a third camera?)
Does this still happen when you hit escape?
nope
that was only when it was spazzing
in order to get it to work perfectly, I have to have the camera at a specific angle
which is what those 3 earlier screenshots with the magentas crosses were
this angle specifically
if I look up, they offset up and to the left. If I look down, they offset downwards
its as if the raycast areas are miles back along the z-axis for some reason, so the slightest angle shift, causes them to misalign
but that doesnt explain the shift to the left
Perspective explains that. Things that are closer to you will move further away from the center of your view
e.g.
yeah
I feel like you have something messing with the UI camera or the canvas. It might not be apparent at the end of the frame
it definitely does feel that way
egregious example: screw up the rotation very early in Update, then fix it super late in LateUpdate
I've had to track down errors that are only visible halfway through the update loop
I would make absolutely sure that you are not manipulating the UI camera or the canvas at all
It might be enlightening to record the transform.position values of the buttons at a few points during execution, and then to draw them on the screen with something in Gizmos at the end of the frame
I know the programmer who set up the cinemachine camera was trying to make a lock-on to target enemies so I wonder if that script is somehow causing it
I'm unfortunately not code-savvy
That could involve rotating a camera (or a cinemachine camera) at an unusual moment, I suppose
Actually, you could get away with just slapping this component on the UI buttons:
public class PositionTest : MonoBehaviour {
void Start() {
StartCoroutine(EndOfFrame());
}
void Update() {
Gizmos.DrawRay(Camera.main.transform.position, transform.position, Color.red);
}
void LateUpdate() {
Gizmos.DrawRay(Camera.main.transform.position, transform.position, Color.green);
}
IEnumerator EndOfFrame() {
while (true) {
yield return new WaitForEndOfFrame();
Gizmos.DrawRay(Camera.main.transform.position, transform.position, Color.blue);
}
}
}
You'll want to look at the rays that are drawn in the scene view
See if one of them gets out of sync with the others in a way that matches your problem
Note that the game view must be visible for WaitForEndOfFrame to work
if you just have the scene view open, the coroutine will not resume
One thing I'm curious about is if Cinemachine has to do anything special to make a "Screen Space - Camera" canvas move at the correct time
the canvas isn't actually following the main camera -- it's following the UI camera
how would I go about adding this?
I tried to copy and paste it into a script named PositionTest but its throwing errors regarding DrawRay
let me try it out myself..
heres a better view
the green dotted lines are from a script I found earlier to visualise the raycast padding
so thats where the buttons would be
or at least should be
Much more like I'd expect
The red and green lines are noticeably disconnected.
very much so
the blue and green seem to be connected though
huh this is interesting
interestingly, though, the red line starts at the actual position of the camera in the scene view
You'll lose the blue lines if you don't have the game view up, btw
when I have the game focused, theres no blue lines
though I do notice from time to time they appear when tabbing back in and theyre where the red are
ooo, now hang on a minute -- when I look up or down, the line doesn't match properly
(including after I matched the camera FOVs
at least its replicatable xD
oh xD
hopefully you'll get more useful results now
If the only thing moving the main camera is Cinemachine, you should see a small offset between the two lines if the camera was moving around in that frame
it intrigues me that the greenlines are spawning over by the wall, as that was where the camera was freaking out earlier, and the greenlines are also freaking out a bit
That is very weird. Something is flinging the camera all the way over there
Much closer to what I'd expect (but still slightly weird)
The camera is in the position you'd expect in Update
Then it flings way over into the wall by LateUpdate
and then, by the end of the frame, it's located where you see it in the scene view
better angle
I'd like to see the actual orientation of the camera during LateUpdate, too. I would expect that to match the displacement you're seeing
Transform cam = Camera.main.transform;
Debug.DrawRay(cam.position, cam.right, Color.red);
Debug.DrawRay(cam.position, cam.up, Color.green);
Debug.DrawRay(cam.position, cam.forward, Color.blue);
Add this to the end of the LateUpdate method in that PositionTest class.
This will draw the right/up/forward directions of the camera as red/green/blue lines
(and yes, DrawRay this time!)
the theory here is that your camera is getting displaced at just the right moment to screw up UI input
(this will draw the lines many times, since you have many copies of PositionTest on your buttons, but who cares)
I'm getting suspicious of this "lock on camera" ๐
How was this done?
god I wish I knew xD Thing was a mess and broke back in May, then got replaced with something else in the meantime, and its only now being worked on again
from the looks of it
there was a target canvas that placed a dot/crosshair on an enemy
originally if you press the middle mouse button, the camera would select an enemy and snap to orbit mode focused on the enemy, but broke and ended up offsett- oh
then it got replaced later with beat-em up style targeting thing where it would target the nearest enemy and sort of magnetise you to them
these sorts of sub-frame errors are really annoying to figure out, since the scene looks correct at the end of each frame
perhaps the system also turns off when you hit escape?
what I suspect is likely going on, is that beatem-up magnetism thing I mentioned that replaced it, is always updating trying to check for the nearest enemy, causing it to move
If it's directly moving the camera, then it won't play nice with Cinemachine
I wonder if there's always an "off by one frame" error with "Screen Space - Camera" canvases...
Hi, I need help
To make a "special" rendering, I send what the camera records to a rendertexture and show it in a RawImage on a canvas
but now this canvas does not allow me to interact with another one in which I do want to put the interface of the game
I already tried to disable the "Raycast Target" of the elements of the "Main" canvas but it still doesn't work
this is just an egregious example because the camera is getting moved and rotated dramatically
iirc the original target lock moved the camera, the current one just moves the player not the camera
Add a Canvas Group and uncheck "Blocks Raycasts"
the group will affect all graphics on its object or on any child object
Although, Iโm pretty sure you just need to uncheck Raycast Target on the relevant graphicsโฆ
huh
so remember earlier when I mentioned pressing wasd or escape stopped the spazzing during the earthquake?
escape snaps it to the player/camera location. WASD snaps it to the spawn location it seems
Do you have a crucifix handy
hahahaha
thats what I was thinking 2 hours ago
damn things possessed
I'll have to inform the coder that he's managed to code a demon
Let my try
I'd have to look at the code to say anything more concrete, but you've definitely got code trying to move the camera around
thanks
you okay if I dm it to you?
Yeah, if you want to share a large chunk of code. I don't know how you'd narrow it down easily
I guess I'd look for scripts that include a LateUpdate method, but it could also just be happening in Update
sent you the camcontroller script
hmm, that's a bit scary: the target lock works by directly setting your mouseX and mouseY fields
oh joy
Cinemachine makes dark souls-style target locking pretty easy, by the way
You can ask it to keep both the player and the enemy on screen
Yeah I sent the guy multiple tutorial videos regarding it and he just ignores them
he's a very "I can do it myself" kind of guy
I wound up modifying Cinemachine a bit so that I could deocclude with the follow target, not the look-at target
and then the Cinemachine devs implemented that in the next update :p
oh wow
last one I ended up sending him was this one https://youtu.be/J1bJZ6e5oEU?si=2GWq2JAk5epNfuSl
Hi and welcome!
Here we are with the last video of the first Lo-Fi Series.
It is the longest of the series and we will see a bunch of nice things:
- add a new animation state blend tree to enable a "standing" (weapon equipped) state;
- add a new sub-state for strafe animations;
- handle transitions through all these states in the script;
- ...
I've gotten very fed up with the camera the past like 8 months
the fact the camera is likely the cause of my UI troubles is beyond maddening
theres been times where I've genuinely just wanted to start over with a brand new camera and third person controller as I feel like it would be easier to work with xD
hello i know this is not code relavant i dont know why when i drag my image healthbar it import first HealthBar_0 instead of HealthBar i tried preserve aspect and set native size but that doesnt work any idea?
When you import multiple sprites, each sprite gets a numeric suffix by default
HealthBar itself is not a Sprite
it's a regular texture
The sprite importer produces Sprite assets from that texture
they're stored as sub-assets of the original texture
i used image not sprite importer
unrelated concepts
Image is a component that can display a sprite
Click on "HealthBar" in your project window to see the importer settings
It looks like you want to switch it from "Multiple" to "Single", so that you get one sprite that includes all ten hearts
You can then switch the Image component's "Image Type" from "Simple" to "Filled"
Put it in horizontal mode and adjust the fill to make the hearts appear or disappear
cant find them in interspector
Screenshot the entire editor window after selecting the texture asset.
That is not the "HealthBar" asset in your Project window.
Select that.
You need to change how you import the sprites first.
yeah you want to click on the small line of hearts, not the individual hearts
i selected it in project window
Okay, now look at the inspector.
man sorry i didnt see that
It's easy to miss
You can now switch it from "Multiple" to "Single". That will import the entire image as one big sprite
Note that if you want a single heart, then you shouldn't do that
i will probably need them singel but there must be some way
Some way to do what?
If you want a single heart, you already have that
(well, you have it ten times)
since you've imported ten identical-looking sprites from that image
You can create many Image components, each of which displays a single heart
no i want line of hearts but i want access each one
and i need it as one component
Why does it need to be exactly one component?
its health bar and each with 3 lives and health will increase or decrees
Single sprite mode, and make multiple image components using it
keep it single but create one image with this sprite and then change from simple image mode to filled
then by changing between 0 and 1 the hearts will be visible and not visible
i am sure the hearts are seperate by an even amount
so as you have ten hearts, 0.1 should show one heart and 0.2 would show two... and 1 would show all, make sure to set fill method to horizontal and fill origin to the left or right as you want.
Hey, i wanna make my canvas worldspace like this, to a screenspace overlay, like with a smooth transition, is this possible ? (transition vice versa)
hmm..you could use a world-space canvas and position it in front of the camera yourself
I don't think there's anything special about a "Screen Space - Camera" canvas vs. a "World" canvas, beyond how the former gets put in front of the camera
oh, right, and the latter also gets sized based on your screen, of course
Oh u mean just move the canvas worldspace in front of camera that sees the scene?
Yeah.
One option would be to add a "dummy" canvas that doesn't have anything on it
you'd just use it as a point of reference
put that on "Screen Space - Camera" and set the camera distance to something small (the default is 100 meters)
It'll get scaled to fit on your screen properly
i've never used screen space camera, but if i turn this on, i have to pass the camera as well tho
oh nice
Yeah, it renders the camera as part of the world (unlike "Screen Space - Overlay")
it positions the canvas in front of the camera
You could just switch between that and World, but then there be no transition
Hey all, hopefully quick question. Making a pixel art game and I've got everything looking crisp, except my UI coordinates do not conform to my reference resolution. Like I have a super ultrawide monitor, and viewport is accurate, the UI is waaaay off on the edge of the screen. I mean technically the UI elements are positioned correctly within their bounds, but those bounds match the actual resolution, not my reference resolution.
It comes down to your canvas scaler and how you anchored your UI elements
I recommend reading this if you haven't yet to learn how UI anchoring works: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html#anchors
Well since the project is pixel art I went with a pixel perfect UI and set my scaler to constant pixel size. I anchored my elements a minimum of 10 screen units from the edges. Like if I wanted something in the upper left of the screen, my pivot is 0, 1, and my X,Y is 10, -10. So I take it the anchoring is where I am going wrong?
Yes anchoring is where you're going wrong
Could I maybe create a rect transform GO under Canvas and parent everything to that, and then use a script to set the size of the parent to match the reference resolution?
What are you trying to accomplish here
There is generally no reason to write any code for your layout
You just need to set up the anchoring and pivots etc properly.
So my reference resolution is 640, 360. My actualy target resolution is 1920 x 1080, but I am using a scale of 3. I want the UI elements to conform to the result.
I want the UI elements to conform to the result.
This is meaningless
you need to be more specific
i.e. show your UI and explain where you want everything to end up
The canvas scaler will do this automatically if you set it to "Scale with Screen Size"
Constant pixel size basically means "don't do any scaling at all"
Keep in my screen is super ultrawide
I want the UI elements within the starfield area there, aka what I consider my reference resolution
So then what do you mean by "my target resolution is 1920 x 1080"? Your ultrawide resolution is not that
The entire screen seems to be a starfield area
Which ui elements are we talking about, and where should they end up?
they are in the far upper left corner (solid black) area, they are little health bars. they should end up within the starfield area.
You need to anchor them to the center of the screen then
Not the left side
I would parent them to the starfield image and then anchor them normally
Otherwise, the UI elements will fly off the screen if the resolution changes
any idea why this button looks stretched like this even when native size?
ok i fixed it.... but idk how?
also the image persisted even after deleting it
my unity is hallucinating
thius can happen if you've done scaling onm the canvas
generally you shouldn't scale canvases or UI elements, only use the RectTransform to size them
from personal experience the mask component is probably the most broken buggy mess in this entire engine
I managed to get it to work when I had the same issue and iirc it just magically started working
keep fiddling with it and good luck
Oh. Great
Unity has to modify your materials when you use masks
This can cause problems if you're trying to set properties on the original material, instead of the new instance that Unity created
I'll need to see the inspector for the Image object, as well as its material, if you've assigned one
oh, there it is
Something is definitely wrong here -- "Show Mask Graphic" is unchecked, but you can still see the white image
You should see the preview material's name change when the mask is turned on -- it's that "Stencil Id:1, Op:Replace, ..."mess
not sure what I did to fix it I was messing around with the import settings, specifically Format, I set it to R 8 then back to automatic and somehow that fixed it
Update:
- The spazzing green lines were the result of a line of code in the player controller. It seems to be the remnants of a headbob effect the programmers had implemented at one point. No clue why it was there
- I ended up building an entirely new playercontroller following that tutorial I posted here the other day. My buttons now detect mouseover in the correct location with that one, I just need to get the camera to lock/pause when pressing escape now. I also have a lock-on sort of working too which is nice
Does Unity 6 support Decals? or is there a new workflow for using bullet holes in gameObjects
Can only access Decals via legacy shaders and its giving my game issues due to unity shader scripts.
That's not UI related, and it depends on your pipeline. But generally speaking, yes they're supported.
URP for example: https://docs.unity3d.com/6000.0/Documentation/Manual/urp/renderer-feature-decal.html
Hi everyone! Unity newbie here ๐ I was wondering if someone could help me with an issue I'm getting on my UI.
I've put up a simple UI mockup on a canvas for a 3D game (VR) but the effects behind it are somehow showing through the UI making it hard to read the text, I have already checked if it was an alpha issue but everything seemed okay (?). Has anyone here encountered similar issues?
Screenshot attached to show what is happening. The second image is just to show the placement of effect and canvas.
Help pls
I discovered that it wasn't that I couldn't interact with the buttons.
is that the physical area does not match the visual area
I know what is happening, it is using the total coordinates of the cursor but it is not adapting them to the second canvas
but I don't know how to fix it
The most robust solution here is to write your own custom subclass of Raycaster that translates the location your pointer is in the RenderTexture into the appropriate position on the camera that is rendering the RT
But the gist of the concept is here: https://discussions.unity.com/t/raycasting-and-render-texture/65069
I must be missing something. This setup for masking on the UI is not currently working.
My hierarchy is:
Canvas
- image , behind everything dead center
- image , with mask component
-circle image to cut through mask
fixed it
doesnt the mask only work on the images that are a child of the mask object?
you have a mask on this object but no children
"circle to cut through mask" is a child of the mask parent
"masking bg" is the full screen black gameobject that has the mask component on it
whats the mask on "start - behind" for?
try turning show mask graphic off
there is no mask on the game object "start-behind" that is behind the masking bg
oh nvm your screenshot is really confusing ๐
why do you have 2 hierarchies
yea i was trying to show both on same screen shot so i locked inpector tabs
i dont normally have my editor like that
Let my try
thanks
"masking bg" has no sprite assigned. I don't know what the behavior is in that case.
additionally, the graphic on the "circle to cut through mask" object will render on top of the "start-behind" image
this is a UI channel.. regard making UI in your game, delete this question and ask in #๐ปโunity-talk with some actual useful information so people can help and not guess
Hi! I'm making touch controls for a mobile game. Is there any way how I can make panel(for camera movement) behind buttons still be interactable?(for example - im holding jump button but still able to move camera)
@subtle pilot i mean that i want to shoot and move camera with one finger, but if i hold shoot button and move my finger - its of course not moving camera. because button's raycast blocks panel
Oh you mean like traditional shooter games, where you are moving your FOV as you click other buttons?
yeah
I havenโt done mobile development but iโm pretty sure youโd use the input system or touch controls
im already finished with controls - it works, its just that problem
that buttons block camera movement
So to be clear, youโre able to control your FOV and use the buttons, just not simultaneously?
yes
Use one joystick for movement and another for controlling your FOV (typically an invisible one on the entire right side of the device)
Which will be in the input system package
you didn't understand me
controlling fov and everything else work lol
I did, you said yes to what I said
how adding another joystick will help me? lol
You need to use the input system
For movement, youโd write a script that will rotate the camera on the X and Y axis depending on the joystick motion
just with the input system
i already did that
im telling you again
that it works
just if not pressing buttons
btw, joystick for camera movement are very and very inconvenient
better use drag event in script
Have you tried On-Screen stick prefab?
Do you even know what that is?
im telling you another time - that the problem is not that it globally doesn't work
the problem is that i can't hold button and move it simultaneously
Well iโm giving you the answer to what you are asking. I was making sure I understood you and I gave you the solution for that
Perhaps show your code?
how showing the code will help you giving me an answer with raycasts
its just drag event
Because I gave you all the UI based approaches and you are still saying itโs not working, which rules out your code.
if i press that button - it just presses this button, but not interacting with the panel(i can't rotate camera if finger is pressing this button because it blocks everything that's behind this button because it has Raycast Target enabled)
You can try disabling the raycast target for the buttonโs background while still detecting clicks on the button
i can try
lemme try it
nah
That doesnโt tell me much. Howโd you approach disabling raycasting while still being able to press the button?
public void OnPointerDown(PointerEventData eventData)
{
gameObject.GetComponent<RawImage>().raycastTarget = false;
}
Why are you using code to disable it rather than just unchecking the tick in inspector?
What button? You are disabling it on the RawImage, which wonโt affect your buttonโs interactability.
i made a custom button script
Ok so disable raycasting on the image component in the inspector. No need to use code at all for this.
btw, disabling it will affect my button interactability :)
because since button doesnt have any objects without raycast target enabled - it of course ignores it :)
No it will not, RawImage and button are two separate components.
At this point, youโre wasting my time. Are you trying to receive help or just argue?
u dont even know unity good enough if you think that button doesn't rely on Raycast Target of any other component
Raycasting enabled on an image blocks touch input to the receiving end of a UI. And an FYI, iโve developed an entire game, with a lot of UI, so I sure know what iโm talking about. But hey, you do your development since you donโt want to listen.
Button isn't the actual thing you can click on. It just responds to events caused by clicking on something else.
(similarly, a Button does not have any text -- you just frequently parent a text component to your button)
So you want to be able to press and hold on a jump button, then move your finger around to provide a movement input?
True but assuming he had another component on the same object with the button or a background, disabling raycasting would allow input on the button itself
yep! i already fixed it tho
by adding EventTrigger component
huh, what would that give you?
and passing panel's function OnPointerDown and Up
that just lets you set up UnityEvent callbacks for all of the UI events
oh, I see; that's not the problem I thought you were trying to solve
on all buttons...
that'll make it so that pressing on the button with a cursor (nothing other than a cursor, mind you) runs those methods
it works on phone
lol
I suppose that touch input winds up causing the Pointer* events
Does anyone know of any editor extension for improved UI workflow in Unity? For example, alignment line snapping relative to other UI objects, and grid based snapping.
You are supposed to use a bunch of layout groups + layout element components for that kind of thing. Placing ui objects based on absolute positioning, visually by moving them with the mouse does not work out in practically all situations.
I have a horizontal layout group, how can I align the yellow icon to the far right of the horizontal container? (without expanding the attack item to full width)
Is there also a way to enable visualization of the layout groups, similar to web dev tools?
Just enable gizmos in scene view
You can combine multiple layout groups in a hierarchy and use the alignment/control settings in those. Alternatively you can layout without any groups by using the pivot/anchor/size/position on the RectTransform. A third option is to combine both methods by using the LayoutElement componentโs ignore-toggle for some objects (like your button). If you are looking for a flex-based layout, like in webdev, you should be using UI Toolkit. Neither (Canvas or Toolkit) can solve all your problems elegantly.
Hey everyone!
Iโm having trouble adding outlines to pixel art fonts in TextMeshPro. Here's what I've done so far:
- Switched the Atlas Population Mode to Dynamic.
- Increased Padding in tmp font asset during creation
- Ensured Iโm using the TextMeshPro/Distance Field rather than bitmap on the font material
After these changes, the Outline property now appears in the material settings, but adjusting the Outline Thickness or Outline Color has no visible effect on the text. Does anyone know how to get outlines working for pixel art fonts in TMP? any tips would be really useful :(((
Does anyone perhaps have some good advice on making ui assets / where i can find some free ui assets?
What kind of assets? Technically you dont need any, but the range of what you might want or need is infinite.
An extra object with a LayoutElement that accepts flexible width would work. It'd eat all of the extra space.
do you guys have any resources on how to make UI really pop? i feel like my UI feels kinda crap and static lmao
Interpolation/tweening. If you're using UI toolkit you can use the transition property
i'm not using the toolkit unfortuantely. I do have some animations between panels but it still feels kinda ass, i want that zenless zone zero level of UI sauce
Hold on lemme research
i appreciate it ๐ i was gonna do my own reseaerch but i wanted to know if anyone heere had some hidden gem resources for stuff like that
Research other games, pay attention to what they do.
There's also the game Ui db site: https://www.gameuidatabase.com/
i am gonna do that soon, but i meant more like actual technical unity methods in terms of animation and stuff
A lot of animation to add juice is just basic tweens
i also want to know if there's like a comprehensive way to add easy navigation for controller lmao
cus my game is mainly gonna be controller oriented
why's that funny? ๐ค
UGUI has the navigation stuff, which is for controller movement around UI
You heard of the fullstop? ๐
i'm using the default event system, but when i disable and enable stuff, i just find it hard to track what i should go to next and stuff
Oh sorry, I mean't research ZZZ UI. Anyway, it seems that whenever a menu is opened, they have a fade in effect. They also have a yellow/orange flash on items. I presume that is the source of the juice.
yeah, im gonna have a look at some more game UIs like carwash recommended
going to do some research into this
I like UI toolkit a lot since you can write CSS style effects more easily.
might consider using it for main menu stuff, but i thought it was lacking in some other respects
In what way? Lack of shader support?
im not sure, i haven't really had a look
i just know that it wasnt recommended for most users
unity logs themselves recommend default unity Ui stuff lmao
Fair enough. Just be aware that you'll have to write all the effects yourself.
yeah i don't mind spending some time for that
i think its better than laerning a whole new workflow at least
hallo i am trying to make a store scrolling system where everyhting outside of the scroll area is not visible problem is i have a another mask (for showing all players the same view no matter what display size their using) so the store mask is not working if the game content mask is enabled is there a way to make it work out?
frame mask on
frame mask off
have you tried it without the game content mask?
@split finch yes it works
but i need the game content mask and the store mask
then you should probably try a different masking operator
try this
worked for me once
well now that i think about it
it is a diffrent mask component
ui mask
content mask
there you go
yea but its still doesnt work
on Sprite Mask component, there is a toggle named โCustom Rangeโ. If you toggle on, you can adjust the affected layer. This means you can prevent the layer of UI Canvas be affected by Sprite Mask.
Otherwise, if you toggle off, it affects all layers.
try that
np
check out https://www.gameuidatabase.com
Oh dammit
beat to the punch
that's what I get for not reading further back
thank you though
i was more asking in terms of unity programming stuff in that question, though. I also am struggling with like transitioning selected objects when i enable and disable panels
Your scene doesn't have an Event System
wym
There is no Event System in your scene
You need an Event System if you want UI to be interactable
To fix it - put an Event System in your scene.
GameObject -> UI -> Event System
buttons arent clickable even tho they are scripted
While the game is running, keep the event system selected in the hierarchy window
At the bottom of the inspector you will see a preview window for it
it will tell you what object(s) you are mousing over
it might be you have an object blocking your UI
anyone else having a huge pain with Unity resetting the Pos Y of rect transforms on Play in the editor?????????
Literally doing nothing but hitting play and Unity decides it knows better than me and places shit at 0
I have to make a fucking workaround that repositions the element in the Start method
Ah I see it's a bug that they claim was fixed in 2022.3.4 and has since resurfaced AGAIN
it does not randomly set the position of objects, no. perhaps there is some more context here?
does this thing have a parent?
please could you help me with setting up a main menu
Hi! In mobile games, is it better to use a regular font or a condensed one? And about the weights, should I include multiple weights (medium, semibold, bold) or one would be enough?
theres a bunch of videos that can help you https://www.youtube.com/watch?v=zc8ac_qUXQY
Learn how to make a main menu using Unity!
โ https://www.assetstore.unity3d.com/#!/content/84126?aid=1101lPGj
โ Developer Forum: http://forum.brackeys.com/
โค๏ธ Donate: https://www.paypal.com/donate/?hosted_button_id=VCMM2PLRRX8GU
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
โบ Join Discord: https://disco...
Thank you
probably a dumb question, but can UI toolkit and Unity UI be used interchangeably? Like, menus and stuff like that would be in toolkit, and HUD elements like health and whatever can be done with unity UI?
You can use both in the same project for different purposes but you canโt use them interchangeably. They have very different architecture and design philosophy.
yeah, thats what i meant. Im just weighing my options because i want dynamic and fluid feeling UI with shaders and stuff to make it feel interesting, but I can't do that with toolkit. Toolkit seems to use a lot of CSS-esque stuff which i am also familiar with, though.
Toolkit is very much a 2D metaphor, with canvas UI you can do a lot more in terms of actual 3D effects and any ideas that grow out of a mesh/object/shader way of thinking
okay, in which case i'll probably stick with Canvas UI, thank you! Do you have any tips on how to deal with controller navigation while switching between canvases/ panels /canvas groups? in terms of selection and stuff.
Layout your ui in a way that the automatic navigation doesnโt get confused and use a state machine to control the panels, design everything in a โmodalโ way, not in a โwindowโ way.
like a state machine that does stuff based which panel is open?
If you want really smooth gamepad ui, skip the ui navigation you get from canvas objects and implement all your game pad controls manually
how would i do that? gamepad UI and mouse selection should work interchangeably like it does with the default event system stuff
You use a state machine to ensure only the things are active/interactive that belong to the state
This is a fantasy, in most cases gamepad and mouse ui are incompatible, one of them will be clunky if you try to unify them.
damn
im doing a fighting game so the primary control scheme is gamepad, i should probably optimize for that rather than mouse
canvas ui gives you a crude way to unify them, but itโs not really what you expect from a gamepad ui
Probably
I need the keyboard in order to send chat messages, and that would mean hovering over the chat thing with the mouse
but i guess i could do it the way other games do it
where like enter opens the chatb ox
which would ignore the mouse entirely
mouse and gamepad can exist and act concurrently, you just need to do some extra work to make the gamepad inputs nice. Just dont expect it to be automatic like mouse ui.
okay, thank you! i think i will need to put more time into comprehensive UI navigation stuff
cus right now if i click off a button, the event system has selected as null and then im just fucked in terms of controller navigation
I would not spend much time on making rarely used menus overly gamepad friendly and leave those to the select & activate that you get automatically. Focus on stuff that will be accessed a lot during regular play and make that snappy and direct. A radial menu can get you very far (see baldurs gate 3)
I have a input field that has a caret that is significantly too large even at smallest size you can set in inspector, and the only real solution I have found is to just massively increase width and height and then decrease scale, but that's kind of inconvenient as it's width and height is being controlled by something else. Is there something built-in to handle this, or do I just need a script to set the scale of the caret specifically down and maybe change it's pivot/anchor.
I've never seen a problem with the size of the caret. Are you doing something unusual like scaling UI elements instead of setting their size perhaps?
I don't think so? The full hierarchy path to the weird caret is a world canvas (13.5673, 7.9249) -> (5, 3.159722) -> stretch (.35 left, .35 top, .37 right, .33 bottom) -> scroll view stretch (0 left, 0.51 top, 0 right, -1.192093 bottom) -> stretch (all 0) -> content of scroll view w/ vertical layout group (0.1 left, 0 pos y, 0.1 right, 2 height) -> parent of my input field (4.08 width (set by layout), 0.3 height) -> input field (stretch all 0) -> text area (stretch all 0) -> caret (stretch all 0). The scale of literally everything relevant is (1, 1, 1)
I believe it's because of my small width and height values, but thats because its in world space, and that was the amount needed to have it's relative size to non-canvas objects be correct
so if I want to increase the width and height then I have to literally scale up everything which just seems annoying (not hard, could be done quickly, but I dont want to) and unless im doing it wrong (I just saw people online saying it fixed it for them) its not fixing itself for me
What's the resolution of the world space canvas set to?
If thats width and height (13.5673, 7.9249), if it's canvas scaler its 1 dynamic pixel per unit and 100 reference pixels per unit. nothing says resolution explicitly and i've never had weird canvas stuff before so not exactly sure which thing is which on it, just have settings that usually work.
Might take a while for response cause late and im getting itred, might sleep. If I might need to give more replies later, should a thread be made?
If thats width and height (13.5673, 7.9249),
So your canvas is nearly 14 pixels by nearly 8 pixels
That's an extremely low resolution, and probably what's causing the issues.
I'm having a little confusion about uGUI. So let's say I have an Image (Panel) as a window that has a content size fitter and vertical layout group on it. Then as children I have multiple "Content Rows", each with Horizontal layout groups on them. And within them they have content such as text and images. The rows should expand to match the needed dimensions of their content, and the panel to fit the size of all its rows. Automatically. Is there no quick way to do this? It doesn't seem like uGUI can do that at all without manually putting in width & height
UGUI performs only a forward layout pass and cannot infer a root level fitter size from objects that have themselves be derived from a fitter, you need to trigger the fitter re-layouts manually if you want to nest them, often one additional layout pass per nested fitter
Ok
Best practice is to not rely on fitters on complex layouts
Also you need to make sure that the layout groups do not override the fitter (thatโs what the warning in the inspector is about)
Yeah I haven't put a content size fitter on anything but the panel. I guess I'll just have to go through and manually size some things. Luckily the content is not dynamic so I don't have to worry about that
Thanks again for the help
I'm about at wits end with UI anchored positions from world positions. Just setting a UI element's position seems to work fine at different resolutions, canvas scales, and it's independent of anchors, nesting and whatever other nonsense anchoredPosition takes into consideration.
Why does anchoredPosition suck so much? And what is wrong with using someUi.position when it appears to work just fine under a range of different resolutions/scales?
It also depends heavily on your canvas render mode
setting world position works well only for screen space - camera and world space canvases
I can't get WorldToScreenPoint to work for a SS canvas. Setting the UI anchored pos is way out, but when setting the transform pos it sticks to the object like white on rice whilst changing the window size and canvas resolution at the same time. Doesn't miss a beat. I just don't get it.
Even when you manage to get the anchored pos to match the world pos of the object, as soon as you change the canvas scale/resolution/screen size it's all out of whack again.
SS Overlay or SS Camera?
The values for anchored pos are based on the reference resolution and scaler settings, not actual screen space pixel coordinates
Perhaps you're looking for this? https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RectTransformUtility.PixelAdjustPoint.html
that converts from screen space points to "canvas space" basically
Have anybody encountered a problem where TextMeshProUGUI just... refuses to update for no reason?
In my dialogue system, the current displayed phrase is running through a coroutine that prints out the text into the UI letter-by letter, and at the very end it copies the phrase into a "history log" TMP object like so:
historyBox.text=(historyBox.text + (charName == "..." ? currentText : charName+": "+currentText)+"\n\n");
When I run the dialogue for the first time after the playmode begins, everything outputs as it should. But, if I re-run the dialogue again after it wraps up (the gameObject of the dialogue UI get's disabled to hide it from the view) - historyBox remains completely empty and doesn't receive any text.
I have a similar problem with TMP field that displays the name of the speaker, only it behaves in a completely opposite manner - it ignores the setting of the text the first time it's called, but cooperates without an issue after that (So the name remains empty during the first phrase, but displays fine for the rest of the dialogue. I hacked this issue by simply making the coroutine set the name with each char being printed out...)
No, never had that problem. Most likely your code is the issue
What debugging steps have you taken?
Also - not directly related - but rather than appending strings to the text, it's usually better to just set the full text at the start and use this for the typewriter effect:
https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TMP_Text.html#TMPro_TMP_Text_maxVisibleCharacters
this will ensure the text is laid out properly from the start and doesn't re-layout as it "types"
Oh, that's neat, thanks!
Hm, ok, I've found what was the issue with the history log (it was turning off in addition to the main UI), but changing the coroutine to change the visible characters count and set text only once returned the same bug like what was with the name field - first phrase is always empty. =_=
The code is
IEnumerator PrintText(string speech,string charName)
{
DisableInput();
nameLabel.text=charName;
playerSkipping = false;
float delaytext = 0.02f * GameManager.GetGameSettings().GetFloatSetting("textSpeed",1);
textBox.text = speech;
textBox.maxVisibleCharacters = 0;
for (int i = 0; i < speech.Length + 1; i++)
{
if(nameLabel.text == String.Empty)
nameLabel.text=charName;
if (playerSkipping)
{
i = speech.Length;
playerSkipping = false;
}
textBox.maxVisibleCharacters = i;
yield return new WaitForSecondsRealtime(delaytext);
}
string text = (historyBox.text + (charName == "..." ? speech : charName+": "+speech)+"\n\n");
historyBox.text=text;
if (!selectingChoices)
EnableInput();
}
and in the game I can see that the textmeshpro's output is empty:
Text passes just fine to the history log, and the control buttons remain disabled for an appropriate time, so it's not a case of the coroutine itself receiving an empty string.
I could add another if (textBox.text == String.Empty) textBox.text = speech; statement in the loop section, but it feels like a hack around the issue rather than a solution to the issue.
You need to start adding logs
Clearly something unexpected is happening in terms of when and where this code is running
and with what parameters
It happens only on the first phrase, and code-wise it executes no different than every other phrase. Like I said, the expected text still adds just fine to the second TMP after the forloop is done, so the string passed into the function is not empty, IDK what else is there to log.
Putting a breakpoint on the textBox.text = speech; only confirms it - everything seems fine, but the text's still isn't there.
The thing about the debugger is you are only seeing one run through the method
Logs have an advantage that you can see the whole sequence of events
In this case I would use logs to debug because my worry is this coroutine is running multiple times
And with different parameters etc
Doubtful. It is being called from only one place in the code (this function), and if the function would be called several times, it would mess up the dialogue flow (skipping phrases, etc), but this doesn't happen.
public void NextLine()
{
if (!dialogueContainer) return;
gameObject.SetActive(true);
string line = dialogueContainer.ContinueStory();
if(line == String.Empty)
line = dialogueContainer.ContinueStory();
if (line == "[END]")
{
EndDialogue();
return;
}
if (line == "[CHOOSE]")
{
nameLabel.text=("You");
textBox.text=("");
return;
}
string charName = "...";
string text = line;
if (line.Contains(":"))
{
charName = line.Split(":")[0];
if (characterPortraits.Count >0 && characterPortraits.ContainsKey(charName.ToLower()))
{
foreach (KeyValuePair<string,PortraitController> characterPortrait in characterPortraits)
characterPortrait.Value.Speaking(characterPortrait.Key == charName.ToLower());
}
text = line.Substring(charName.Length+1);
}
StopCoroutine("PrintText");
StartCoroutine(PrintText(text.Trim(),charName.Trim()));
}
Why not just add some logs here to make sure?
Well, ok...
textBox.text = speech;
Debug.Log(speech);
Debug.Log(textBox.text);
Both output the string. The textbox, however, is still empty.
that means some other code is modifying it
Hm... Strange... if I add yield return null just before these lines, the text always sets properly. It's as if something else sets the textbox's text right after the routine first started, but the only two lines of code that set the textbox outside the coroutine are in Awake() and a function responsible for laying out the choice buttons (which certainly isn't being triggered since it generates neither buttons nor null exception errors).
you don't have an Animator for example do you?
Nope
I would say it's probably one of those other lines of code you don't suspect then.. no matter how improbably that seems..
Awake should be called only once, when the object is loaded into the scene, correct? And for the line in the buttons function... It isn't designed to run quietly, it will either show buttons or throw an exception for "no choice options" (and it will do that before reaching the line of code responsible for clearing out the textbox).
Delete the text component and then call NextLine. Something will throw an exception (:
I can't seem to math today. Can somebody help me out? I've got a slider gauge that is radial 180 degrees, but using a radial slider of 180 doesn't look right for whatever reason. But if I use 360 degrees it looks great...however lol. I can only use values of 0.5 to 1. So I need to convert my 0 to 1 value to a value between 0.5 and 1. (i.e. if my initial value is 0.5 then my slider needs to be 0.75) So what's the equation?
Use a remap function in general
But in this case isn't it just divide by 2 and add .5?
er Yes lol. Also it seems like Unity has a remap function...somewhere? https://docs.unity3d.com/Packages/com.unity.mathematics@1.2/api/Unity.Mathematics.math.remap.html
Yes in Unity.Mathematics
Well all the same, thank you!
I am showing a black quad over the entire canvas, but there's a single pixel line at the top of the screen where you can see through to the game behind. This happens even if I set Top to a negative number, why would this be?
Why when I'm rendering Canvas through SS-Overlay it is normal, but when I try to do it with SS-Camera it's broken?
pics: 1 - ss-overlay ; 2 - ss-camera ; 3 - canvas settings ; 4 - camera settings
I'm trying to add 3d elements to my HUD, and that's why I need SS-Camera
The issue is not in that screenshot. Itโs likely in a parent of it.
Your overlay-mode scale is non-uniform. Is this canvas a child of a mother scaled transform?
No, but I have panel as a child so i could separate different UI categories (like HUD, Escape menu etc.)
How could I change my overlay-mode?
You are not showing something useful here
I was referring to your screenshots taken in overlay mode
that's all I have
You could check the transform of โplayerโ
Oh, I see now. Changing Scale X to 1 normalizes hud, thank you!
hey guys I'm in need of some help!
I have a panel, the light blue one, that has an invisible child panel with a vertical layout group that the title.txt and file content texts are a part of, also as children are an invisible panel containing the close button and the darker panel to the right
what I'm trying to accomplish is that the main panel dynamically takes on the size required to fit the invisible panel that has the title and content but I'm completely at a loss on how to do that, I can't put a layout group because that would mess up the layout with the panel on top and to the right
thanks for your time ๐
I don't see how a layout group would mess up the layout.
Can you show the problem it causes?
Also, I should clarify that there's not really such a thing as an "invisible panel". The "Panel" object is just an Image
getting bit of UI scaling issue if on QHD Screen, if I try to adjust it to that size it then destorys the other resolutions that worked for example standart 16:9 or 4k
when i copy and paste a ui button it goes to the right, how do i make it so it will go down
such things are controlled by layout groups
Use a vertical layout group if you want them to be laid out vertically
thanks it works now
Question when making a UI at what screen size should you aim to work with? Do you want to just start off at 1080p or is there specific resolutions that are best to work with
That's completely up to you and your target hardware
E.g. if making a mobile game you might want to work in a portrait resolution.
kay was asking since with computers I didnt know if you work with whats common or work small then scale up
probably best to use the aspect ratio of your own monitor as the reference resolution
but certainly test with other common resolutions when you want to publish
I'm using OnPointerEnter and OnPointerExit to highlight UI images on a Screen Space Camera Canvas. It mostly works fine except when the camera is moving, then it keeps registering enter and exit events even when the mouse doesn't move. Does anyone know how to fix this?
what would you like it to do
when the camera is moving is the cursor locked or something?
You could just disable the event system while the camera is moving, for example
No, the the cursor is always unlocked. I want to be able to interact with the UI elements even when the camera is moving. It works just fine with a Screen Space Overlay canvas, but not with Screen Space camera.
Then I don't understand what the issue is. Sounds like registering enter and exit events while the camera is moving is what you want
The UI elements are just some hotbar slots fixed to the bottom of the screen. They do not move at all, even when the camera moves. I want the colour of the hotbar slots to change when hovered over, and go back to normal when not hovering. Very simple, basic game UI, right?
In the OnPointerEnter method, I set isHovering = true. In OnPointerExit, isHovering=false. I set the colour of the hotbar slot based on if isHovering is true or false. It works perfectly with Screen Space Overlay.
But then I change the canvas to Screen space camera. I hover my mouse over the hotbar slot. isHovering gets set to true and the image changes colour. I keep my mouse in the same exact position (over the hotbar slot), and I start to move my player around, and the cinemachine camera follows the player. The mouse stays still, I don't move it at all, it stays in the exact same position inside the hotbar slot the whole time. The expected behaviour is that isHovering stays as true, because the mouse has not exited the UI element, right? But what happens is that isHovering keeps flickering on and off.
hmmm that is interesting. I think maybe it's due to the the update order for the canvas moving with the parent object or something?
What do you want to use Screen Space Camera for? Something with postprocessing?
Hmm, my canvas is a root object though.
Yeah, just to apply post-processing
could you do it with an overlay camera that doesn't move?
Not sure what you mean. A screen space overlay canvas?
Screen Space Camera canvas, but rendering on a separate camera that doesn't move
and isn't attached to the player at all
Make that camera an overlay camera so it draws on top of your normal camera
via camera stacking
so it's like you get an Overlay Canvas but since it's drawn on a camera you can apply postprocessing to it
Ah I see. Yeah I could do that I guess, but it would effect performance a little and it seems kind of crazy considering hovering over UI buttons is like the most basic functionality for a UI canvas.
Hey! I'm trying to have a rendererTexture from a secondary camera react to mouse events. The second camera is created with a significant offset from the entire "main play" area to not have other elements leak into the RenderTexture. Any clues on how I could have the mouse react as expected despite the rendered UI being from a different camera with a huuge offset from a seperate scene?
I'm trying to have minigames in my game opened as in a smaller window, they gotta be interactable though. I wanted a system where each minigame is a seperate scene, rendered into a dedicated Renderer texture on demand by a seperate camera. It's all fun and games with keyboard/controller input, but mouse input is just not there... mostly because an UI image cant really be concerned with passing input to whatever it shows.
Any tips on how I could get this working? Screenshots are:
- Empty place in the "main" scene for the renderTexture
- Example game with a camera that renders into the renderTexture
- Current use-case, but without mouse events working
Unity HDRP 6000.29
Anyone else having an issue where text mesh pro lit/unlit look fine in scene view but stuck "blue" on camera?
Saw a thread on this from 2021 but no fix there.
It is not post process related.
Not sure, where to put it. Does TMPro support the font tag in stylesheets?
Okay, it was just me not putting them in resources folder ๐
I can't decide for the life of me which version is better (shroom inventory alpha 1 or 0.8)
Does anyone here know how to make the text and sprite up there be affected by the render texture? I have the impression that they are a bit detached from the image. Like, the resolution is 640x480, and the text and sprite are not at that resolution.
yes
is it possible to use two canvas? because I think one is for the raw image with the render texture and the other with the sprite and counter text
Sure, it's up to you
Hey I'm pretty much a beginner in Unity and I'm trying to make a fun little project, however for some reason my button keeps locked on Top Left instead of where I want it, I can't move it and I can't change the anchor point either and I have no clue why this even happens in the first place.
https://gyazo.com/5919da13a64e71dbccf14b35124ffe9e.mp4
Could it be because I'm using a Vertical Layout Group in the parent of the button?
As it says on your RectTransform yes it's because of the layout group
Can any one told me what is wrong with this TMP font
given this kind of game what should be the rect transform for item slot and draggable items since it would skew it placement when any rect transform is done
that depends entirely on how you want the UI to react to the different aspect ratios
i want the bar to lie always be atleast a maximum 80% of the screen width and min 60% on tablets and such also for all fonts to scale properly
i think imma just rebuild this from scratch with scaling in mind because i have 30 levels to worry about XD
Hello
Wanted to ask, is this a bug? the vertical layout list only show properly if I trigger it in editor.
You can arrange canvas ui objects in a way that cannot be layouted in a single pass (often involving content size fitters). When you click on it in the hierarchy you effectively trigger another layout pass. You can also trigger these in code with the LayoutRebuilder https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.UI.LayoutRebuilder.html
If you have any content size fitters with a warning about having a layout group as a parent, you need to get rid of them.
Or use manual re-layout. The warning is not entirely truthful ๐
It's warning you that the UI will not behave reliably
which is, indeed, the outcome: you have to whack it with the relayout stick over and over until it settles
Not necessarily, if the layout axis and the fitter axis are orthogonal, it also works
but yeah, fitter use == layout pain
I've never used a fitter anywhere but the top-level
except in scroll rects, of course
They are kinda required for scroll views
yeah
which is why the preset scroll rect object has... no content size fitter!!
Yay!

well it should be called YGUI
all of the pre-made UI objects were carefully crafted to scare people away from auto layout
I have a dysfunctional love hate relationship with it
it was a mess for me until I actually grokked the idea of layout groups and elements
It takes 80% of any of my projects budget and willpower
Yeah, but itโs still a time sink after that
now it's...remarkably smooth sailing. most things Just Work on the first or second try.
Itโs just extremely frustrating if you are a trial & error person
The system is really good at tricking you if you do that
especially given the default Force Expand options on layout groups
those are really good at making the UI mostly work
unfortunately, "mostly correct" is still "sometimes wrong"
I think ugui is pretty neat for static uis where the layouts donโt do much
It is more awkward for UIs that resize and fly around
But dynamic stuff needs to be authored carefully
Also try making a group with the items in it flexibly expanding to fill the space
Or make one item flexible and the others fixed
there is just is stuff it canโt do without a custom layout groupโฆ typically itโs possible to just change the design, but beware if your design is mandated disregarding efficiency in implementation
how do i make different kind of like pages, im guessing i can link them up from buttons
so like between the actual game and starting page and then pause menu (the list goes on really)
kinda yeah but atm im just looking to make the start menu
Ok thank you ๐
Sorry so @wild blaze just started watching the tutorial and i need to have my game scene ready first, so do you know what's the best size for a square for mobile?
no so when the game gets played on a phone, will it fit the canvas size or do i have to make my own square for the game to fit?
oh :/ wait sorry this might make more sense. When you do the game mode, does that fit the entire screen of the phone
Theres a good way to do it (for future, by in the drop down of game, theres simulator, choose a device and it shows you what it looks like from that device
I have a script which works fine and it makes it so the background for the menu scrolls and loops somewhat nice.
However, when i try to change the image to the "nicer" version it breaks and only loops the color background and im not sure why. i already double checked the image itself and its fine.
What's "the color background"? How does your script work? What are the import settings for the two images?
This belongs in #1179447338188673034 or #1080140002849214464
@steady robin There's no promotion in help channels. Make sure you read channel posting guidelines if you reposting somewhere else.
just curious regarding game ui responsiveness and whats more efficient, i have about 15 levels working on and 6 different gamemodes in those 15 levels do i just create the 15 levels first make them functioning and then worry about responsiveness later or finish a stage then work on that stages responsiveness
i already have a responsive templates for basic and redundant parts of the stages like complete, tip and pause screen (img2)
Hey there everyone! i have a question regarding adding outlines to a textmeshpro text that uses pixel art fonts! i have tried researching how to achieve this but found nothing useful :((
is there a way to add outlines to pixel art fonts that are used for textmeshpro? or is it something that is simply not possible with bitmap fonts?
Googling -> tmp outline bitmap font resulted in this thread, where there is info spanning many years https://discussions.unity.com/t/textmesh-pro-bitmap-font-outlines-and-shadows/662502/20
(there are other results that may be of use too)
One message removed from a suspended account.
the script you posted here is literally empty
it doesn't do anything
what are you expecting it to do?
Also !code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Anyway you don't need a script for this.
Pretty sure you can just check this "use sprite mesh" box here and call it a day.
One message removed from a suspended account.
there is a random capsule collider on my charcater and i cant remove it
like i cant find it
One message removed from a suspended account.
Nothing random about it
That's your CharacterController
which is a capsule-shaped collider
if you are using a CharacterController you should not have any other colliders on the object as they will cause problems
So really your BoxCollider here is the extra weird collider
I'm trying to display my UI in a ingame monitor, My game is a 3d urp project. I've been using render textures for 3d security cameras but struggling with finding a way to display a specific UI/Canvas to a monitor:
any ideas?
Create a world space UI, position it on top of the panel.
I only want to display it, in this case my buttons will be clickable in World Space
So It shouldn't be interactable on the monitor
UI doesn't have to be interactable?
UI has to be
I'll be only displaying it on the monitor, when i interact with the object I'll display the exact UI to do upgrades to be more specific. let me send an screenshoot
I only want the same image in my UI to be displayed on the monitor screen
Yes, so create a World Space canvas, put this art on it and then scale and position the canvas so it's overtop the screen on your model.
is using LayoutRebuilder.ForceRebuildLayoutImmediate() bad practice?
I have a relatively complex auto layout hierarchy and calling only once doesn't seem to actually rebuild the layout completely.
Ive also trying LayoutRebuilder.MarkForRebuild, that worked worse.
But if I just.. spam LayoutRebuilder.ForceRebuildLayoutImmediate() it works. (like 6 separate lines)
Spamming it is very bad, but sometimes itโs necessary if your layout canโt be evaluated correctly in a single pass. You should always investigate where exactly you need to put a call to it. Typically you need it for each nesting of a content size fitter inside a layout group that also controls the same axis.
Well when we say "spam" I mean, I only use as many as needed via trail and error, but the actual amount seemed pretty ambiguous.
So, there IS a method of figuring out that amount. I guess the follow up question is: Can / Should I continue using trail and error? Or when you say "investigate where exactly you need to put a call" do I actually need to code some logic to call things a bit more methodically?
Iโve never fully figured out how to arrive at the minimal number of calls. I just know that more content size fitters == more problems and re-layout calls grow proportionally
Well I guess thats good to know now, before I went any further. For the most part, I'm really only making rebuild calls in the editor for testing purposes.
Is there a better way of making responsive auto layed out UI, or do I just have to be super purposeful with everything?
I've added a video of what I'm using the rebuild for, for reference. (forgive and forget the art UI quality)
Itโs one of those things Iโve always given up on eventually in order to get on with life.
Suppose responsive is the purview of a flex box based engine like UI Toolkit, which in turn has other issues.
#๐ปโunity-talk message
its a world space canvas @azure flame
if a world space canvas with pixel perfect font rendering is too much to ask, then well I tried
Like I've mentioned previously, if you don't want for UI to be affected by camera effects, set it to overlay mode.
what camera effects?
Also fix your pronouns trolling, very tempting to reference you as such
It is what you asking to be called after all
honestly I wouldn't mind it but I dont wanna give the impression im making fun or pronouns/neopronouns or something
aaaaanyway
Whatever effects you have they affect your world space ui
put ui outside of that to not be affected
post processing effects? I just dont know what camera effects refer to sorry
if u mean like a pixel perfect camera component im not using that
Also make sure your game screen is not just zoomed in. Zoom controls are on top
The scale slider that is. Make sure it is in the left position.
Also since it's in the world space it can also be corrupted if you use scaling in the object or one of the parents
Oh right, you have weirdly low pixel per unit setting, that would do it.
Actually reference PPU doesn't seem to affect SDF font, and scaling either, in world space. So it would have to be camera effect of some sort.
Outside of that you can do sanity check, and re-create it in a clean scene. Then you'll know at what point something corrupts it.
Posted this in web but I am also posting it here as I don't know if its an issue with webgames or with android or with UI.
Got an interesting issue here. I have a small webgame that I made to teach english to Japanese students (basically classic snake where you collect words to build a sentence). As such some of the instructions need to be in Japanese. I added a font with Japanese support (notosansJP) which is a google font, and it works fine on windows. However if I open it on android the font wont render. It's not that the text objects are not rendering though, because if I use the default font everything works fine.
Anyone have any suggestions?
why is that low? thats the amount of pixels per unit
Yes, it doesn't affect sdf font though, only ui graphics fidelity.
that doesn't answer my question, why is that low
what is ppu other than pixels per game unit
usually it's 100 by default
right but I want 16 pixels per unit not 100
Like I said, it doesn't matter here because it doesn't affect sdf
alr just was curious
See ^^ on how to find the problem
Don't cross-post, please.
And one possible reason is that resolution/padding for the generated font asset is too low and it bleeds into neighbouring symbols, which covers the entire symbol. Try testing with well spaced out font asset.
screen space - camera canvas doesn't actually seem to work in this case
not camera, Screen Space - Overlay if you don't want it to be affected.
they all have the same result
this is a test scene with screen space overlay and a camera with nothing else on it
what gives
Did you generate the correct font asset?
