#๐Ÿ“ฒโ”ƒui-ux

1 messages ยท Page 30 of 1

mortal robin
#

they're easy once you grasp the fundamentals

tacit basin
#

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

rapid ferry
#

nvm I just fucekd the image up

fickle pagoda
#

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

near coyote
steep warren
jolly flame
#

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?

tacit basin
azure flame
jolly flame
#

i fixed it by moving my UI elements to the center of the canvas and scaling them up

azure flame
#

Your logo was lower and covering the button.

mortal robin
dry pivot
#

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?

white rose
#

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

low pike
white rose
#

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

low pike
#

Hitboxes aren't a thing in Unity, clarify what you actually mean

white rose
#

the area where you click/mouse over for the button to register is offset to a different location

low pike
#

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

white rose
#

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

low pike
#

you're gonna have to show the setup

#

sounds like you've got something offset that's invisible

white rose
#

These 4 buttons are the ones with the weird detection. I have one selected to show the bounds of it

#

inspedctor looks like this

low pike
#

show the inspector for all three (EquipmentButton, Background, Foreground) and INCLUDE the RectTransform

white rose
#

The weird behaviour is specifically with the camera it seems as moving the camera causes the offset to shift

low pike
#

I doubt this has an affect on the issue.. but how come you've got the Z pos at something other than 0?

white rose
#

I dont know... I dont recall ever touching that

#

set it to 0 and it still has the issue though

low pike
#

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

white rose
#

oh yup, popupmenu has a z pos of 11.9

#

HUD2.0 is clean and canvas is weird

low pike
#

canvas may be - lemme see

white rose
low pike
#

Yeah, that's fine - it does it all automatically, because it's scaling to fit within the frustrum of the camera

white rose
#

ah ok

low pike
#

and the distance from the camera set by 'Plane Distance'

low pike
white rose
#

unfortunately no

low pike
#

see at the bottom of the inspector, there's a little bar ? has like three lines crossing it

white rose
#

the little preview one?

low pike
#

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

low pike
low pike
white rose
#

I somehow just managed to lose the three bar preview window thing. Is there a way to bring it back?

#

oh nvm

#

found it

low pike
#

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

white rose
#

well it was there and now its gone

#

it used to be inline with preview

#

oh i see

#

dock preview to inspector

low pike
#

That looks different to what I'm used to - are you using U6 ?

white rose
#

Im using Unity 2022.3.2f1

#

with URP

low pike
#

I don't think URP makes a diff to this bit

white rose
#

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

low pike
#

Oh, the preview isn't there for me either in 2022

#

oh wait, are you using the new input system ?

white rose
#

uhhh let me check I've been working on this with others but they're all away for the holidays

low pike
#

project settings -> player -> other settings -> part way down under 'Active Input Handling*'

white rose
low pike
#

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

white rose
#

this the new one?

low pike
#

yep

#

I've no idea if that has the info panel that the event system on the old input system has

white rose
#

doesnt seem to

low pike
#

I'm afraid I'm out of ideas

white rose
#

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

low pike
#

have you got multiple cameras?

white rose
#

yup

low pike
#

maybe they're not rotating together, either at all or fully?

white rose
#

the canvas is rendering to an overlay camera and the main camera has some cinemachine stuff going on

low pike
#

as a test, move the canvas to the main camera

white rose
#

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

low pike
#

you can just change the plane distance to a low number

white rose
#

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

white rose
#

hmm so increase the near clipping plane

#

currently my near is 0.3

low pike
#

yeah default is 0.3 and 1000 .. doesn't feel like this is going to help

white rose
#

yeah definetly not

low pike
#

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

white rose
#

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

low pike
#

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 ?

white rose
#

its a little offset

low pike
#

but less?

white rose
#

though now its almost as if its offsetting along a diagonal?

low pike
#

๐Ÿ˜„

white rose
#

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

low pike
#

heh

#

something going on with the camera stacking and plane distances

white rose
#

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

low pike
white rose
#

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

#

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

low pike
#

so now it's a child of the main camera and rotated to match (0,0,0)?

white rose
#

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

low pike
white rose
#

Oh they probably need to be exactly lined up

low pike
#

yep, pos of the child should be 0,0,0

#

and it should be rotating with the parent

white rose
#

okay the diagonal nonsense is resolved but theyre still offsetting vertically

#

which I suspect is due to the fov

#

nope

low pike
# white rose

the selected camera here hasn't rotated with the other one - this would / could account for the offset

white rose
#

that didnt solve it

low pike
#

if the UI camera isn't rotating with the main cam 1:1, it looks like that would cause issues

white rose
#

its currently rotating 1:1

low pike
#

great

#

but also .. not great, because what else could be causing the offset ๐Ÿ˜„

white rose
#

plane distance doesnt seem to change it

#

my next thought is its probably the cinemachine causing it

low pike
#

I don't see how, but investigate

white rose
#

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

low pike
#

I would say it hasn't been disabled if it's doing that

white rose
#

oh thats with it enabled again, my bad. Shouldve worded that better

#

Though that seems unrelated to the current issue

white rose
#

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

supple basalt
#

I'm having trouble understanding what's going on

white rose
#

the area where you can mouseover/select a button with the cursor

#

it seems to completely disconnect from the buttons themselves

supple basalt
#

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

white rose
#

yup

supple basalt
#

and I presume you've configured their culling masks so that they don't render the same things

white rose
#

yup

supple basalt
#

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)

white rose
#

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

low pike
#

rotation shouldn't move anything closer/further away

#

are the transforms for the cameras at 1,1,1 for scale?

white rose
#

heres what its doing

#

and the cinemachine camera is having a freak out

low pike
#

wonder why the vcam is moving when you move some UI

#

Has it got a follow target?

white rose
#

thats not me moving the ui. Thats it just on run

#

the Cam pos I mean

#

and yes I think so?

low pike
white rose
low pike
#

yeah, that's fine

white rose
#

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

supple basalt
white rose
#

if I disable the cinemachine brain or I disable the camera that's spazzing out, it actually does look like that is happening xD

supple basalt
#

you disable the camera that's moving around rapidly?

#

and that cause the screen to start shaking?

white rose
#

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

supple basalt
#

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

white rose
#

this is the camera thats freaking out

supple basalt
#

The cinemachine camera is moving itself

#

since it's causing the main camera to move

white rose
#

wait wait wait, so the guy that set up the cinemachine, made the camera that moves a child of the maincamera?

supple basalt
#

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?

white rose
#

okay that fixed the spazzing camera but not the offset.

And yeah I'm specifically using screen-space camera for post-processing and shaders

supple basalt
#

You should also check that the canvas has the correct camera referenced

#

(it probably does)

white rose
supple basalt
#

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

white rose
#

they currently do have the same fov

#

all 3 have an fov of 90

supple basalt
#

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?)

white rose
#

nah thats just an empty

supple basalt
white rose
#

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

white rose
#

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

supple basalt
#

Perspective explains that. Things that are closer to you will move further away from the center of your view

supple basalt
white rose
#

yeah

supple basalt
#

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

white rose
#

it definitely does feel that way

supple basalt
#

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

white rose
#

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

supple basalt
supple basalt
# white rose I'm unfortunately not code-savvy

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

white rose
#

I tried to copy and paste it into a script named PositionTest but its throwing errors regarding DrawRay

supple basalt
#

oh right, wrong name lol

#

replace Gizmos with Debug

white rose
#

so this angle has the buttons working how they should but...

supple basalt
#

let me try it out myself..

white rose
#

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

supple basalt
#

Much more like I'd expect

supple basalt
white rose
#

very much so

#

the blue and green seem to be connected though

#

huh this is interesting

supple basalt
#

interestingly, though, the red line starts at the actual position of the camera in the scene view

white rose
supple basalt
#

You'll lose the blue lines if you don't have the game view up, btw

white rose
#

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

supple basalt
#

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

white rose
#

at least its replicatable xD

supple basalt
#

oh, dammit, that's because i used the wrong name twice

#

DrawLine, not DrawRay. notlikethis

white rose
#

oh xD

supple basalt
#

hopefully you'll get more useful results now

white rose
#

wait so do I want to replace all drawrays with drawline?

#

cause theres 3

supple basalt
#

Yes

#

DrawRay takes a starting point and an offset

#

but we have two points

white rose
#

oh yeah thats much better

#

though concerning

#

this is where its working

supple basalt
#

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

white rose
#

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

supple basalt
#

That is very weird. Something is flinging the camera all the way over there

white rose
#

if I press escape it jumps to another location

supple basalt
#

Much closer to what I'd expect (but still slightly weird)

supple basalt
# white rose

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

white rose
supple basalt
#

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

supple basalt
#

I'm getting suspicious of this "lock on camera" ๐Ÿ˜‰

white rose
#

these are the only changing values in the debug view of the freelookcam

white rose
#

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

supple basalt
#

splat

#

i think that system is fistfighting with Cinemachine

white rose
#

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

supple basalt
#

these sorts of sub-frame errors are really annoying to figure out, since the scene looks correct at the end of each frame

white rose
#

yeah

#

I think this was the original target lock that broke, based off of the comment

supple basalt
#

perhaps the system also turns off when you hit escape?

white rose
#

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

supple basalt
#

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...

rigid fulcrum
#

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

supple basalt
#

this is just an egregious example because the camera is getting moved and rotated dramatically

white rose
#

iirc the original target lock moved the camera, the current one just moves the player not the camera

supple basalt
#

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โ€ฆ

white rose
#

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

supple basalt
#

Do you have a crucifix handy

white rose
#

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

rigid fulcrum
supple basalt
#

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

rigid fulcrum
#

thanks

white rose
#

you okay if I dm it to you?

supple basalt
#

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

white rose
#

sent you the camcontroller script

supple basalt
#

hmm, that's a bit scary: the target lock works by directly setting your mouseX and mouseY fields

white rose
#

oh joy

supple basalt
#

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

white rose
#

Yeah I sent the guy multiple tutorial videos regarding it and he just ignores them

supple basalt
#

and to keep the camera from going through a wall

#

that's how I implemented it

white rose
#

he's a very "I can do it myself" kind of guy

supple basalt
#

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

white rose
#

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;
  • ...
โ–ถ Play video
#

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

chilly pumice
#

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?

supple basalt
#

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

chilly pumice
#

i used image not sprite importer

supple basalt
#

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

chilly pumice
supple basalt
chilly pumice
supple basalt
#

That is not the "HealthBar" asset in your Project window.

supple basalt
#

You need to change how you import the sprites first.

white rose
#

yeah you want to click on the small line of hearts, not the individual hearts

chilly pumice
#

i selected it in project window

supple basalt
#

Okay, now look at the inspector.

chilly pumice
supple basalt
#

Oh, you have the inspector locked.

#

Unlock it.

chilly pumice
#

man sorry i didnt see that

supple basalt
#

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

chilly pumice
#

i will probably need them singel but there must be some way

supple basalt
#

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

chilly pumice
#

no i want line of hearts but i want access each one

#

and i need it as one component

supple basalt
#

Why does it need to be exactly one component?

chilly pumice
#

its health bar and each with 3 lives and health will increase or decrees

mortal robin
modern owl
#

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.

thin creek
#

Hey, i wanna make my canvas worldspace like this, to a screenspace overlay, like with a smooth transition, is this possible ? (transition vice versa)

supple basalt
#

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

thin creek
#

Oh u mean just move the canvas worldspace in front of camera that sees the scene?

supple basalt
#

Yeah.

thin creek
#

that's a great idea, i didn't think about that

#

iis there a way to do it properly?

supple basalt
#

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

thin creek
#

i've never used screen space camera, but if i turn this on, i have to pass the camera as well tho

#

oh nice

supple basalt
#

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

thin creek
#

okay nice, im gonna try thx

#

and if i want a transition, what should i do ?

glad merlin
#

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.

mortal robin
glad merlin
#

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?

mortal robin
glad merlin
mortal robin
#

There is generally no reason to write any code for your layout

#

You just need to set up the anchoring and pivots etc properly.

glad merlin
mortal robin
#

you need to be more specific

#

i.e. show your UI and explain where you want everything to end up

mortal robin
#

Constant pixel size basically means "don't do any scaling at all"

glad merlin
#

I want the UI elements within the starfield area there, aka what I consider my reference resolution

mortal robin
mortal robin
#

Which ui elements are we talking about, and where should they end up?

glad merlin
#

they are in the far upper left corner (solid black) area, they are little health bars. they should end up within the starfield area.

mortal robin
#

Not the left side

glad merlin
#

okay I will do that then

#

TY!

supple basalt
#

Otherwise, the UI elements will fly off the screen if the resolution changes

quartz whale
#

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

mortal robin
#

generally you shouldn't scale canvases or UI elements, only use the RectTransform to size them

serene tusk
#

URP is installed

quartz whale
#

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

serene tusk
#

Oh. Great

supple basalt
#

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

serene tusk
#

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

white rose
# supple basalt Do you have a crucifix handy

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
winged coral
#

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.

mild kernel
amber peak
#

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.

rigid fulcrum
#

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

mortal robin
neon birch
#

why is it so far to the right?

modern timber
#

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

neon birch
#

fixed it

honest saffron
#

you have a mask on this object but no children

modern timber
#

"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

honest saffron
#

try turning show mask graphic off

modern timber
#

there is no mask on the game object "start-behind" that is behind the masking bg

honest saffron
#

why do you have 2 hierarchies

modern timber
#

yea i was trying to show both on same screen shot so i locked inpector tabs

#

i dont normally have my editor like that

supple basalt
#

additionally, the graphic on the "circle to cut through mask" object will render on top of the "start-behind" image

low pike
#

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

dire orchid
#

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)

dire orchid
#

@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

subtle pilot
#

Oh you mean like traditional shooter games, where you are moving your FOV as you click other buttons?

dire orchid
#

yeah

subtle pilot
#

I havenโ€™t done mobile development but iโ€™m pretty sure youโ€™d use the input system or touch controls

dire orchid
#

that buttons block camera movement

subtle pilot
#

So to be clear, youโ€™re able to control your FOV and use the buttons, just not simultaneously?

dire orchid
#

yes

subtle pilot
#

Use one joystick for movement and another for controlling your FOV (typically an invisible one on the entire right side of the device)

subtle pilot
dire orchid
#

controlling fov and everything else work lol

subtle pilot
dire orchid
#

how adding another joystick will help me? lol

subtle pilot
#

You need to use the input system

dire orchid
#

why?

#

if i use it - it will be the same lol

subtle pilot
#

For movement, youโ€™d write a script that will rotate the camera on the X and Y axis depending on the joystick motion

dire orchid
#

just with the input system

dire orchid
#

im telling you again

#

that it works

#

just if not pressing buttons

dire orchid
#

better use drag event in script

subtle pilot
#

Have you tried On-Screen stick prefab?

dire orchid
#

why? lol

subtle pilot
#

Do you even know what that is?

dire orchid
#

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

subtle pilot
#

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?

dire orchid
#

how showing the code will help you giving me an answer with raycasts

#

its just drag event

subtle pilot
#

Because I gave you all the UI based approaches and you are still saying itโ€™s not working, which rules out your code.

dire orchid
subtle pilot
#

You can try disabling the raycast target for the buttonโ€™s background while still detecting clicks on the button

subtle pilot
# dire orchid nah

That doesnโ€™t tell me much. Howโ€™d you approach disabling raycasting while still being able to press the button?

dire orchid
subtle pilot
#

Why are you using code to disable it rather than just unchecking the tick in inspector?

dire orchid
#

because unchecking it will make button not interactable

#

thats not what i need

subtle pilot
#

What button? You are disabling it on the RawImage, which wonโ€™t affect your buttonโ€™s interactability.

dire orchid
#

i made a custom button script

subtle pilot
#

Ok so disable raycasting on the image component in the inspector. No need to use code at all for this.

dire orchid
#

because since button doesnt have any objects without raycast target enabled - it of course ignores it :)

subtle pilot
#

No it will not, RawImage and button are two separate components.

dire orchid
#

it will

#

check it by yourself

subtle pilot
#

At this point, youโ€™re wasting my time. Are you trying to receive help or just argue?

dire orchid
#

u dont even know unity good enough if you think that button doesn't rely on Raycast Target of any other component

subtle pilot
supple basalt
#

(similarly, a Button does not have any text -- you just frequently parent a text component to your button)

supple basalt
subtle pilot
dire orchid
#

by adding EventTrigger component

supple basalt
dire orchid
#

and passing panel's function OnPointerDown and Up

supple basalt
#

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

dire orchid
supple basalt
#

that'll make it so that pressing on the button with a cursor (nothing other than a cursor, mind you) runs those methods

supple basalt
#

I suppose that touch input winds up causing the Pointer* events

urban crescent
#

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.

proud sandal
urban crescent
urban crescent
#

Is there also a way to enable visualization of the layout groups, similar to web dev tools?

proud sandal
proud sandal
# urban crescent I have a horizontal layout group, how can I align the yellow icon to the far rig...

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.

elder tangle
#

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 :(((

hidden kiln
#

Does anyone perhaps have some good advice on making ui assets / where i can find some free ui assets?

proud sandal
supple basalt
celest lodge
#

do you guys have any resources on how to make UI really pop? i feel like my UI feels kinda crap and static lmao

pliant ether
celest lodge
celest lodge
low pike
celest lodge
low pike
#

A lot of animation to add juice is just basic tweens

celest lodge
#

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

low pike
#

why's that funny? ๐Ÿค”

#

UGUI has the navigation stuff, which is for controller movement around UI

celest lodge
#

i just use lmao as a sentence ender sometimes

#

idk why lol

low pike
#

You heard of the fullstop? ๐Ÿ˜„

celest lodge
pliant ether
celest lodge
celest lodge
pliant ether
#

I like UI toolkit a lot since you can write CSS style effects more easily.

celest lodge
pliant ether
celest lodge
#

i just know that it wasnt recommended for most users

#

unity logs themselves recommend default unity Ui stuff lmao

pliant ether
#

Fair enough. Just be aware that you'll have to write all the effects yourself.

celest lodge
#

i think its better than laerning a whole new workflow at least

quick nova
#

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

split finch
#

have you tried it without the game content mask?

quick nova
#

but i need the game content mask and the store mask

split finch
#

then you should probably try a different masking operator

#

try this

#

worked for me once

quick nova
#

thank uu

#

ill upldate u if it works

quick nova
#

it is a diffrent mask component

#

ui mask

#

content mask

split finch
#

there you go

quick nova
split finch
#

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

quick nova
#

yoooo

#

thank youuu

split finch
#

np

celest lodge
supple basalt
#

that's what I get for not reading further back

celest lodge
#

thank you though

celest lodge
jolly flame
#

why are the buttons not clickable

#

they worked yesterday

mortal robin
jolly flame
mortal robin
#

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

jolly flame
#

oh

#

not working still @mortal robin

mortal robin
#

Show what you have

#

and show your console

jolly flame
#

event system object

mortal robin
#

So what isn't wokring exactly?

#

Show the hierarchy

jolly flame
mortal robin
#

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

nocturne valley
#

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

supple basalt
#

it does not randomly set the position of objects, no. perhaps there is some more context here?

#

does this thing have a parent?

worldly charm
upper wigeon
#

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?

honest saffron
# worldly charm please could you help me with setting up a main menu

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...

โ–ถ Play video
celest lodge
#

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?

proud sandal
celest lodge
proud sandal
celest lodge
proud sandal
celest lodge
#

like a state machine that does stuff based which panel is open?

proud sandal
#

If you want really smooth gamepad ui, skip the ui navigation you get from canvas objects and implement all your game pad controls manually

celest lodge
#

how would i do that? gamepad UI and mouse selection should work interchangeably like it does with the default event system stuff

proud sandal
proud sandal
celest lodge
#

damn

#

im doing a fighting game so the primary control scheme is gamepad, i should probably optimize for that rather than mouse

proud sandal
#

canvas ui gives you a crude way to unify them, but itโ€™s not really what you expect from a gamepad ui

celest lodge
#

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

proud sandal
#

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.

celest lodge
#

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

proud sandal
#

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)

soft monolith
#

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.

mortal robin
soft monolith
# mortal robin I've never seen a problem with the size of the caret. Are you doing something un...

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

mortal robin
soft monolith
# mortal robin 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?

mortal robin
#

That's an extremely low resolution, and probably what's causing the issues.

glad merlin
#

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

proud sandal
proud sandal
#

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)

glad merlin
#

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

quasi matrix
#

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?

mortal robin
#

setting world position works well only for screen space - camera and world space canvases

quasi matrix
#

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.

mortal robin
#

The values for anchored pos are based on the reference resolution and scaler settings, not actual screen space pixel coordinates

#

that converts from screen space points to "canvas space" basically

whole pecan
#

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...)

mortal robin
#

What debugging steps have you taken?

#

this will ensure the text is laid out properly from the start and doesn't re-layout as it "types"

whole pecan
#

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.

mortal robin
#

Clearly something unexpected is happening in terms of when and where this code is running

#

and with what parameters

whole pecan
#

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.

mortal robin
#

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

whole pecan
#

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()));
        }
mortal robin
whole pecan
#

Well, ok...

            textBox.text = speech;
            Debug.Log(speech);
            Debug.Log(textBox.text);

Both output the string. The textbox, however, is still empty.

mortal robin
#

that means some other code is modifying it

whole pecan
#

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).

mortal robin
#

you don't have an Animator for example do you?

whole pecan
#

Nope

mortal robin
#

I would say it's probably one of those other lines of code you don't suspect then.. no matter how improbably that seems..

whole pecan
#

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).

supple basalt
glad merlin
#

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?

mortal robin
#

But in this case isn't it just divide by 2 and add .5?

mortal robin
#

Yes in Unity.Mathematics

glad merlin
fossil shale
#

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?

tender hamlet
#

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

proud sandal
proud sandal
tender hamlet
tender hamlet
proud sandal
proud sandal
tender hamlet
proud sandal
tender hamlet
#

Oh, I see now. Changing Scale X to 1 normalizes hud, thank you!

deft crypt
#

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 ๐Ÿ˜Š

supple basalt
#

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

rapid ferry
#

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

tidal wigeon
#

when i copy and paste a ui button it goes to the right, how do i make it so it will go down

mortal robin
#

Use a vertical layout group if you want them to be laid out vertically

tidal wigeon
brave ermine
#

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

mortal robin
#

E.g. if making a mobile game you might want to work in a portrait resolution.

brave ermine
mortal robin
#

but certainly test with other common resolutions when you want to publish

boreal moat
#

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?

mortal robin
#

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

boreal moat
#

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.

mortal robin
#

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

boreal moat
# mortal robin Then I don't understand what the issue is. Sounds like registering enter and exi...

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.

mortal robin
#

What do you want to use Screen Space Camera for? Something with postprocessing?

boreal moat
boreal moat
mortal robin
boreal moat
mortal robin
#

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

boreal moat
#

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.

tropic turtle
#

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:

  1. Empty place in the "main" scene for the renderTexture
  2. Example game with a camera that renders into the renderTexture
  3. Current use-case, but without mouse events working
serene edge
#

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.

cyan sentinel
#

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 ๐Ÿ˜„

lyric oriole
#

I can't decide for the life of me which version is better (shroom inventory alpha 1 or 0.8)

harsh edge
#

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.

azure flame
#

put UI in camera space mode

harsh edge
#

this?

azure flame
#

yes

harsh edge
#

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

azure flame
#

Sure, it's up to you

leaden lance
#

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?

mortal robin
leaden lance
#

Ohh bruh I didn't even see the text

#

Thanks

ruby inlet
#

Can any one told me what is wrong with this TMP font

hollow lintel
#

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

mortal robin
hollow lintel
robust bobcat
#

Hello

#

Wanted to ask, is this a bug? the vertical layout list only show properly if I trigger it in editor.

proud sandal
supple basalt
#

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.

proud sandal
supple basalt
#

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

proud sandal
#

Not necessarily, if the layout axis and the fitter axis are orthogonal, it also works

supple basalt
#

True.

#

in that case, they aren't stepping on each other's toes

proud sandal
#

but yeah, fitter use == layout pain

supple basalt
#

I've never used a fitter anywhere but the top-level

#

except in scroll rects, of course

proud sandal
supple basalt
#

yeah

#

which is why the preset scroll rect object has... no content size fitter!!

#

Yay!

proud sandal
#

well it should be called YGUI

supple basalt
#

all of the pre-made UI objects were carefully crafted to scare people away from auto layout

proud sandal
supple basalt
#

it was a mess for me until I actually grokked the idea of layout groups and elements

proud sandal
#

It takes 80% of any of my projects budget and willpower

proud sandal
supple basalt
#

now it's...remarkably smooth sailing. most things Just Work on the first or second try.

proud sandal
#

Itโ€™s just extremely frustrating if you are a trial & error person

supple basalt
#

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"

proud sandal
#

I think ugui is pretty neat for static uis where the layouts donโ€™t do much

supple basalt
#

It is more awkward for UIs that resize and fly around

proud sandal
#

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

rocky sky
#

how do i make different kind of like pages, im guessing i can link them up from buttons

rocky sky
#

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

bold cargo
#

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.

mortal robin
mortal robin
azure flame
#

@steady robin There's no promotion in help channels. Make sure you read channel posting guidelines if you reposting somewhere else.

hollow lintel
#

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)

elder tangle
#

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?

low pike
#

(there are other results that may be of use too)

golden skiff
#

One message removed from a suspended account.

mortal robin
#

it doesn't do anything

#

what are you expecting it to do?

#

Also !code

onyx flowerBOT
mortal robin
#

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.

jolly flame
#

im really not sure where to ask this but

golden skiff
jolly flame
# jolly flame

there is a random capsule collider on my charcater and i cant remove it

#

like i cant find it

golden skiff
mortal robin
#

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

jolly flame
#

oh

#

im dumb

rich crescent
#

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?

mild kernel
#

Create a world space UI, position it on top of the panel.

rich crescent
#

So It shouldn't be interactable on the monitor

mild kernel
#

UI doesn't have to be interactable?

rich crescent
#

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

mild kernel
#

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.

fresh saddle
#

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)

proud sandal
fresh saddle
# proud sandal Spamming it is very bad, but sometimes itโ€™s necessary if your layout canโ€™t be ev...

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?

proud sandal
fresh saddle
# proud sandal Iโ€™ve never fully figured out how to arrive at the minimal number of calls. I jus...

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)

proud sandal
#

Suppose responsive is the purview of a flex box based engine like UI Toolkit, which in turn has other issues.

wanton ivy
#

if a world space canvas with pixel perfect font rendering is too much to ask, then well I tried

azure flame
#

Like I've mentioned previously, if you don't want for UI to be affected by camera effects, set it to overlay mode.

wanton ivy
#

what camera effects?

azure flame
#

Also fix your pronouns trolling, very tempting to reference you as such

wanton ivy
#

i should probably change that yeah lol

#

am I just that nasty or something

azure flame
#

It is what you asking to be called after all

wanton ivy
#

honestly I wouldn't mind it but I dont wanna give the impression im making fun or pronouns/neopronouns or something

#

aaaaanyway

azure flame
#

put ui outside of that to not be affected

wanton ivy
#

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

azure flame
#

Also make sure your game screen is not just zoomed in. Zoom controls are on top

wanton ivy
azure flame
#

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

azure flame
#

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.

bronze crane
#

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?

wanton ivy
azure flame
wanton ivy
#

that doesn't answer my question, why is that low

#

what is ppu other than pixels per game unit

azure flame
#

usually it's 100 by default

wanton ivy
#

right but I want 16 pixels per unit not 100

azure flame
#

Like I said, it doesn't matter here because it doesn't affect sdf

wanton ivy
#

alr just was curious

azure flame
azure flame
wanton ivy
#

screen space - camera canvas doesn't actually seem to work in this case

azure flame
#

not camera, Screen Space - Overlay if you don't want it to be affected.

wanton ivy
#

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

azure flame
#

Did you generate the correct font asset?

wanton ivy
#

ive certainly tried my best