#📲┃ui-ux

1 messages · Page 31 of 1

wanton ivy
#

you can see all the settings ive used above

#

idk what i could be doing wrong

azure flame
#

You need to use Text Mesh Pro asset generator. and generated pixel font should look like this

#

Yours looks like bitmap font

wanton ivy
#

i think im an idiot

azure flame
#

I'm not familiar what would happen if you use it with tmp, that could be it

wanton ivy
#

I put in 8 instead of 16 into the ppu and it works

#

oh

#

nevermind :|

#

i am so lost

#

its at least working in my test scene now?

bronze crane
#

Apologies, wont do that again.
Could you tell me what you mean by a well spaced out font? I should clarify that the font uses both JP characters as well as english letters, and both are affected.

azure flame
#

You can also test it with dilate option almost all the way to the left to minimize bleed in. If it fixes it, then you need to space out your asset better

bronze crane
#

Ah, that is what you mean. Nope, I don't think that is the issue, it renders fine on windows but not android. Don't know how to show the entire thing but it looks like there is decent amount of space between them

#

If it was an issue with the atlas I would expect that the font would be broken on windows as well

azure flame
#

It could render slightly differently. Easy to test

bronze crane
wanton ivy
bronze crane
#

This is windows

azure flame
#

Other than that, renderer might not be supporting material shader properly on android.

#

You can test with simple built-in font on the same device to check that

bronze crane
#

Already did, built in font works fine

bronze crane
#

You will also note that the size and shape of the boxes drawn in android are the exact same size as the text that is supposed to be rendered.

bronze crane
#

Sorry, I did not intend to sound argumentitive

azure flame
#

If rendering material works fine with another asset, then the asset is the issue. Different devices can render differently. And bleed-in threshold might be closer.

bronze crane
#

Fair enough.

azure flame
#

Also android just might flat out doesn't support atlas of that size, so excluding bleeding-in thing would point out to that.

bronze crane
#

Well its not android per se, its webgl rendering on android

#

Students use chromebooks

#

I noticed this issue when I opened the game on my phone, and I am currently I am testing by opening the webgl build in bluestacks

#

And I know unity can support Japanese text on android. Plenty of mobile games made with unity on the Japanese market.

azure flame
#

WebGL has memory limitations, so it doesn't look good for the atlas size. Still should test that.

bronze crane
#

So generate it with like 2048x2048 and a padding of like 10 and see if that works?
The weird thing about this issue is it is so specific. WebGL works fine on windows, its only when doing WebGL on android with the new font that there is an issue

#

These are the setting I used to generate my current atlas

foggy pivot
#

my arrow key keeps going big when im in full screen mode, ots supposed to look like the one on the right

supple rivet
low pike
#

Also, don’t work on UI with the game view set to “free aspect”

supple rivet
#

Yeah ig so show your hierarchy is everything in 1 canvas ?

cloud lintel
#

What is the use case for a canvas in constant physical size? I understand what it does, but is there any practical use case?

mortal robin
#

(remember Unity has other industrial and artistic uses besides games)

cloud lintel
#

Makes sense, thanks for the example!

golden skiff
#

One message removed from a suspended account.

supple basalt
#

I don't believe that has anything to do with graphical raycasting

#

Ah, well, maybe it does -- it could cause the image to be drawn with a tighter mesh if it has transparent parts at the edges

vague oriole
#

Is it possible to wrap a canvas onto an object?

#

I'm trying to overlay a canvas onto a bent plane that's meant to represent a screen

#

Ideally I don't want to use another camera but if I have to then it'll work

radiant sorrel
#

how do i make my text look like its going from top to bottom?

inner sail
#

anybody know why I cannot find the sorting layer option under text mesh pro's extra settings category?

Shader is Mobile/Distance Field
Unity Version is 2022.3.55f1 LTS

mortal robin
inner sail
mortal robin
strong quest
#

How do you port the text using the package version of TMP from Unity 2022 LTS into the new and built in version that is in Unity 6? I get like 20 errors every time I open my project because the text in my scene is not using the new version of TMP that is built into Unity 6?

copper slate
#

Hello everyone 🤗

austere ibex
#

please help,

bool IsPointerOverUIObject()
{
    PointerEventData ped = new PointerEventData(EventSystem.current);
    ped.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);

    List<RaycastResult> results = new List<RaycastResult>();
    EventSystem.current.RaycastAll(ped, results);
    foreach (RaycastResult result in results)
    {
        print(result);
    }
    return results.Count > 0;
}```
i have this code to check if im clicking on a ui object, cuz i dont want people to place buildings and such when clicking on the ui but its saying im clicking on the ui while i dont think i am? its saying im clicking on my money counter.
there is a gray line in the middle when i select my counter (as seen in the pic) that is way off from the yellow box. and whenever i click on the right half it thinks im clicking on the money counter ui
low pike
#

The yellow square shows the margins for the TMP, looks like you've manually resized that and left the rect larger

manic valley
#

I'm trying to make an Image recognize pointer based on its shape by generating physics shapes for the sprites and then using "Use Sprite Mesh" on the Image. Any ideas why that isn't working for me?

#

Found a better way of doing it by using Image.alphaHitTestMinimumThreshold

austere ibex
rustic wing
#

I have an issue with text showing as squares? I use the same material and font in other places in my project and they work just fine. Not sure why it doesnt here.

mortal robin
subtle valve
#

I'm trying to make content for a scroll view viewport scrollable, but it doesn't seem to want to work. The content inside isn't text, but prefabs that I'm creating that fill up the content area. I'm not sure how to make it scroll unless I make a Text component of the Content to add newlines for each instantiation, but there has to be a better way

mortal robin
subtle valve
pure moss
#

TMPro_InputField weird behaviour when click on one inputfield and then click on other mobile keyboard not open properly. see the video

olive matrix
#

I need some help with my graphics settings since they say low but im on high at first. When you change them its fine but I would like it to say high when u first enter the menu.

#

I tried changing the orientation of the options, so high on the top and low on the bottom but that just messes it all up and makes it not work instead.

olive matrix
#

I got it fixed

golden skiff
#

One message removed from a suspended account.

oblique sonnet
#

Hi, I can't figure out why my scene view is using a Solid white background. I have no Skybox set and my camera seems to be set up appropriately.

supple basalt
#

HDRP's automatic exposure gets confused by non-lit renderers, like an overlay canvas

#

it tries to adjust so that the average brightness is correct, but the UI doesn't change in brightness

oblique sonnet
rustic wing
#

Is there a way to change the sorting order of text using TextMeshProUGUI when all the text is under the same canvas?

supple basalt
#

It renders in hierarchy order

#

top to bottom

rustic wing
#

what about rendering with sprites outside of the canvas?

golden skiff
cloud lintel
#

So I managed to get hosting UI Toolkit controls inside of uGUI working, the grid looking control is UI toolkit and the blue squares are uGUI. Right now I have it working with Screen Space - Overlay canvas and works when scaled at different resolutions. The next step I guess is to get it working in Screen Space - Camera mode.

rapid ferry
#

I have an HUD on the enemy that appears during runtime, how to make sure the HUD of the enemy isn't influenced by the post processing, otherwise it makes the text more difficult to read

cloud lintel
#

Hopefully you don't have world space canvas on enemy

rapid ferry
#

simliar to the assassins creed games

cloud lintel
#

It's going to be affected by post processing then since it is rendered by the camera

#

You might be able to do something with render passes to render after post processing

rapid ferry
#

is it available in Built in? I use that render pipeline

cloud lintel
#

Is this a relatively new project?

rapid ferry
cloud lintel
rapid ferry
cloud lintel
#

Yeah essentially have a camera that draws your world normally with post processing, this camera should not draw UI layer. Then have a second camera that only draws the UI layer

#

I don't think you even need camera stacking for this

rapid ferry
cloud lintel
#

Sorry haven't used built in pipeline in a very long time

rapid ferry
cloud lintel
rapid ferry
rapid ferry
cloud lintel
#

Did you set every object on the world canvas to the enemy layer or just the root object?

rapid ferry
#

I tried with the UI layer as well but same issue

cloud lintel
rapid ferry
cloud lintel
#

set it to be a child of the main camera and zero out its transform

rapid ferry
# cloud lintel set it to be a child of the main camera and zero out its transform

I've seen that this was the problem, it fixed it but the issue is that the main camera has zoom effects, during aiming or skills which makes the child zoom as well and therefore the UI elements move away.

the main camera follows the player with a cinemachine brain, is it somehow possible to freeze the 2. camera forward movement?

cloud lintel
#

essentially you want most of the settings on both cameras to be in sync

rapid ferry
subtle valve
#

I'm not sure how to do this correctly. If you know how to use scroll views please help, video above

peak mirage
#

The Speech ui contains the Content Size Fitter, and the Vertical Layout Group, the image contains the Vertical Layout Group. How do I make it so that there isn't so much padding between the text and the speech bubble image?

north shale
low pike
#

show the inspector for the TMP when it should be visible - at runtime

#

"layers" aren't something you'd change with UI

north shale
#

heres the tmp at runtime

low pike
#

Is button the scrolly looking thing? If so the TMP is behind it

#

UI draws in hierarchy order, from top (first) to bottom (last)

#

It could also be positioned poorly, those are some large values for it's x/y pos

north shale
#

it also seems to be in correct position

low pike
#

Oh, your font size is tiny, 0.25 is far too small

#

This isn't worldspace UI, is it?

north shale
#

no

#

how big should it usually be?

low pike
#

This red line is your canvas.
You have positioned the TMP off the canvas.

#

Overlay UI in the scene is HUGE. You don't position it with the game scene.

#

this is from the middle of the screen.. which puts it out of view if the screen is smaller than those dimensions

low pike
north shale
low pike
#

what gameobject is this image on?

north shale
low pike
#

Is it an image? show the inspector for it

north shale
low pike
#

Sprite Renders are for game objects, don't mix SpriteRenderers and UI

#

You either want to:

  • Make the canvas the parent of this. Create an image to assign this sprite to.
    OR
  • Remove the canvas and TMP, and use the 3D TMP instead (RMB -> 3D Object -> TMP Text)
#

3d TMP is text in world space, it uses a mesh

north shale
#

The text seems to still be behind the image (I went with the TextMeshPro)

low pike
#

dont crop sreenshots, youve cut off useful information

#

cant see the hierarchy or transform

north shale
low pike
#

keep the scale at 1,1,1 - you will get problems with TMP when you dont (use width / height to change the rect size)

#

Now you're using 3d TMP, your font size will be around 1 (probably the value you had it at before)

north shale
#

ive done roughly around that, but the text is still underneath the image

low pike
#

On the TMP component - expand 'extra settings' -> change 'order in layer'

#

hopefully

north shale
#

it works!

timid rock
#

what is UI-UX

low pike
#

User interface, User Experience

low pike
warped kite
#

What y'all think of this

supple basalt
#

I forget the exact name, but there is a property on a sliced image that controls the pixel-per-unit multiplier

#

try increasing that, so that the corners render a little smaller

woeful kayak
#

Does anyone have any tips for making my UI truly pixel perfect? As you can see here, the pixel borders do not stay the same for all frames. I've tried all different kinds of canvas settings

hazy edge
#

is it ok to have multiple canvases?

#

googling gives me answers from several years ago, so just wanted to make sure

timid rock
timid rock
woeful kayak
#

that's already done

#

it's blue beacause I have it colored when it's running

timid rock
#

explains that

#

well I only know past the point no filter thing

supple basalt
verbal blaze
#

Hi someone told me there is a guide to adapt screen with every mobile screen, but i don't find it in the pinned message

coral echo
#

Hello, i hope this question belongs to this channel. I need to do graphs/charts into UI of application. I think creating the own plots is very time consuming. Is there any other way? i was searching in asset store but for one use, 80 euro is too much. notlikethis chatgpt said me, maybe use python, but i dont have any experience with it and im not sure, if this works.

wild pebble
#

Aand which UI system (IMGUI, uGUI, UI Toolkit)?

coral echo
#

It's little bit older project. Nowadays I would try to use UI Toolkit

misty lagoon
#

I am trying to build a log book that functions similar to this example (of Call of the Sea) and losing my mind. Is there a magic button that makes TMP flow around images?

Also: Is there a way to get those two nicely aligned columns with the old UI system while also being robust towards different resolutions? I know of layout groups but since the columns do have to be spaced on the pages graphic (which scales as well) it is super hard to make sure nothing wanders in the middle where the pages meet and respect the boundaries to the top/left/bottom/right. Any advice?

low pike
#

Something like this
Red - vertical
Blue - horizontal
Green - vertical

misty lagoon
# low pike You would do this with layout groups. Two parent layout groups would be the page...

Yes I understand that but have a hard time making sure the red boxes stay where they are when it comes to different resolutions. I.e. it works on 16:9 but not anymore on 16:10. Adjusting the slider in the canvas scaler that differentiates between height/width matching also does not solve the problem.

(btw thanks for making the arcade vehicle controller I wrote my master thesis using it <3)

low pike
#

If the book is UI too, should be doable - if it's not... it's doable, but no idea about it

#

heh, good to know - glad it was of use!

craggy rapids
#

hello! i am writing an editor tool to automate the transfer of data from Dialogues(scriptable object) to the Unity Localization System and vice versa. It almost works, but the LocalizationTablesWindow doesn't refresh until i press the New Entry button, or i close and reopen the window. Is there a way to automate this process without messing up the layout?

LocalizationTablesWindow window = EditorWindow.GetWindow<LocalizationTablesWindow>();
window.Close();
window = EditorWindow.GetWindow<LocalizationTablesWindow>();
window.Show();```
Calling this code after modifying the SharedTableData works, but the window loses the docking state
wild pebble
#

Haven't looked into it recently so there very well might be a free one too

nova flower
#

how bad is the unity vector graphics package (experimental) ?

#

the result looks super pixelated and reading online they seem to say it's normal

#

any alternatives?

#

looking for the "infinite resolution" svgs provide, right now it looks worst than the rest of the scene

supple basalt
#

I don't remember having that problem. I know there are a few different ways to import SVGs..

#

I'm not currently using it because I switched how I create my graphics (winding up back with rasters)

mortal robin
#

Or use the advanced settings to change the sampling settings

#

Just know that the vector graphics package doesn't directly render SVGs. All it does is rasterize them ahead of time into regular textures.

supple basalt
#

Yeah -- it can't magically make your Image components start doing vector rendering

soft sail
#

I swear all this stuff is just half-baked

vapid edge
#

Is there a way to get a non-worldspace canvas to render into multiple cameras?

#

optionally, is there a way to get a child canvas to render into a different camera than the parent canvas?

mortal robin
vapid edge
# mortal robin What's the context?

I have a setup where my UI is composed of a lot of nested canvases
I'm using a ui blur tool, that requires some of that UI (the one that's supposed to be blurred) to be rendered onto a separate camera than the one with blur components
and I'm stuck

vapid edge
# mortal robin No

ok - how about parent canvas is set to camera, child canvas is overlay? is at least that possible? Or am I stuck with having to split them

mortal robin
grim kestrel
#

I am using the Pixel Perfect Camera with the URP. In order to get my UI to stop jittering when the camera moved I had to set up a second Camera and set the render type to Overlay, and then add it to the Main Camera's Stack. However, the Pixel perfect Camera gives this error message.

From what I've seen online others get this but don't notice any issues. I'm curious if anyone else has had experience with this as I'm worried it'll appear fine, but down the road I'll suddenly discover the issue and it'll be a big problem somehow.

I'm hoping this is some legacy thing and a non-issue 🤞

sand mantle
#

alright so here's more details about the SVGImage issue I was talking about yesterday
this is using the unity Vector Graphics package (experimental) inside a worldspace canvas

#

i've tried messing around with the import settings but I think that might just be how it is after reading this:

#

i would expect smooth lines from any distance since it's an svg

mortal robin
#

it's not a true vector graphics renderer

#

World space canvas itself has resolution concerns too

supple basalt
#

i forget what the vector graphic importer settings look like

proud sandal
sand mantle
#

good to know, and sorry totally missed the reply yday, only saw fen's

#

i'll look into maybe avoiding world space (which i think the only way is using sprite renderer with the svg sprite)

#

there's also another package i found on github, used to be paid but the author opensourced it, maybe the rendering would be smoother?

#

i tried reading on it a bit but i think just testing it is how i'll find out

sand mantle
#

here's what the importer looks like

#

picking something else than vector sprite gives different options

#

although rasterizing at high res creates very large textures which is an issue for my project

mortal robin
sand mantle
#

it seemed slightly better with that technique but still meh

#

maybe i'll try without the render texture the way u said

sand mantle
#

(without using a render texutre)

mortal robin
sand mantle
mortal robin
#

rather than UI?

sand mantle
#

although no technique looked super nice for me yet

#

i think the screenshot i posted was with the sprite renderer

#

it's kinda annoying me that the 3d looks much better than an svg image

#

i was expecting the opposite or atleast equal aliasing/pixelation

#

also i tried the thing from github, it did render a simple material icon svg properly but didn't render my drawing well

#

so i think i'm all in on the unity svg renderer

#

if i'm not mistaken, seems like theses two values have the biggest impact on the end result

#

not quite sure what to do with advanced tesselation

#

mostly pixels per unit, not sure if there's a high cost of putting in a big number there

#

some people also talk about converting the svg to a mesh instead

#

nvm, kept doing some testing and struggle to see a difference between the different vector sprite import settings

sand mantle
#

i think advanced -> step distance is the only (main) thing that matters

#

does seem to affect file size though

supple basalt
#

do other sprites render without the aliasing?

sand mantle
swift basin
#

Is there a way I can allow the player to scale the UI in like manually, in runtime?

#

You know, in like if they were dragging the blue dots of the UI scale

mortal robin
swift basin
mortal robin
supple basalt
#

you just need to get a handle on how RectTransform works

#

notably, you'd need to adjust its size and position simultaneously

swift basin
#

I am basically now trying to have like dps meter type thingy working and right now I am trying to make sure the proportions for the panel are right, and I guessed the best way to do that if I allow the player to resize it. I am kinda having troubles trying to make it not overlap with stuff

#

How hard would that be?

supple basalt
#

the anchoredPosition and sizeDelta change as I resize something with the Rect tool

swift basin
#

What else is changing other than the size and possition?

supple basalt
#

Just those two things -- well, the local position changes too, but it's calculated from those two properties

swift basin
#

I mean.... sounds like superhard if I have to like calculate a scale and position from a mouse position tbh

supple basalt
#

Record the position of the opposite corner, then use that to figure out a rect

#

the rect will touch:

  • the opposite corner's position (which never changes)
  • the mouse cursor
swift basin
#

I could get the difference in X and Y from the bottom left corner but... doesn't they use like different units of meassure?

#

Ther Canvas is pixels right?

supple basalt
#

I forget in which space the anchored position and size delta properties are defined..

swift basin
#

So.... uh.... this is a boolean that tells you if the screenPoint is inside the plane of the RectTransform???

#

I do not understand

supple basalt
#

no, it takes a point on the screen and gives you a point in the local space of a RectTransform

#

it's possible for this to fail (maybe it's a world-space UI that's perpendicular to the camera?)

#

hence the bool

swift basin
#

Oh, right, so it's like a rayCast, I get the out

#

Gotcha

supple basalt
#

yeah

#

I want to say the anchored position is defined in the space of the parent (or in world-space, if you have no parent)

#

I haven't fussed with this stuff in a while, though

swift basin
#

Yeah, me even less lol

#

So I could get the possition of the mouse in local space, then translate to space in Rect transform, and compare the X and Y from the anchor point on the bottom left corner to change the width and height on via script

#

Cool

supple basalt
#

a lot of things become easier once you find the correct coordinate space

#

(instead of trying to approximate it by just slamming in screen coordinates or something)

mighty ridge
#

@swift basin once u do this you may want to package it up to keep for later..

#

that'd be a system worth keeping

swift basin
#

I mean, I don't intend in erasing anything I do

mighty ridge
#

lol.. oh well if its your only project, nevermind me

proven flower
#

can someone tell me why cani see my blocks in scene window but not in game mode?

#

@mighty ridgehello! sorry for pinging but can you help me asap

mortal robin
#
  1. What are they made of? (SpriteRenderer? UI Image?)
  2. What position are they in?
proven flower
#

spriterenderer

mortal robin
#

ok what's that other stuff made of?

#

UI Images or SpriteRenderer?

proven flower
#

wdym position?

mortal robin
#

I mean... position!

#

In the Transform component

proven flower
#

if i click on those spaces the blocks appear

mortal robin
#

What is that background made of?

#

And what position is everything in?

proven flower
mortal robin
#

And what position is your camera in?

proven flower
#

bg is image

mortal robin
#

ok the BG is a UI image

#

on a canvas

#

presumably in overlay mode

#

overlay canvases draw on top of everything in the game

#

that's why you can't see anything

#

disable it for a second

proven flower
mortal robin
#

Oh it's a world space canvas?

#

Anyway - that BG image thing is just in front of your sprites that's what it seems

proven flower
#

no cuz when i click those spaces where sprites need to be, the sprites appear

mortal robin
#

disable the bg image for a minute

#

to see if ytou can see the pieces

proven flower
#

didnt work

#

still cant see them

mortal robin
#

Are the sprites a child of something?

proven flower
proven flower
mortal robin
#

Which are positioned where?

#

what's the z axis position

#

all the way up the hierarchy

proven flower
#

og

#

oh

#

i got it

#

the z positons were like -9k

#

thankss

mortal robin
#

yep that'll do it

proven flower
#

thank you

void lynx
#

chat, why is my layout group fighting with my elements?
i'm embarking on making my 16:9 UI responsive to other aspect ratios but a reocurring issue is how layout groups react to the "Content" gameobject being changed in width (which is what changes on different aspect ratios), they respond by setting width to 0, anyone know why (??)

low pike
void lynx
#

ty

haughty surge
#

I'm new to Unity, I've only used UI Toolkit because it is familiar to me as a web dev

I am considering using Canvases for player HUD. Is it better to have the same duplicated canvases across every scene for my HUD or should it be a single set of canvases kept in my UI singleton? What is the best practise for avoiding repetition in canvases

mortal robin
#

Either way, you'd use a prefab

haughty surge
mortal robin
#

sure

mental oriole
#

Hello, I need help with TextMeshProUGUI rendering Devanagari fonts

#

There is this asset which does it

#

But the website of the creator is down

#

Im not sure if its worth putting in so much money to get it, if it doesnt work

#

Is there an alternative way to implement this?

#

For those unfamiliar with matras, they are vowel modifiers that attach to consonants. Unlike English, where vowels are separate letters, Hindi modifies consonants using matras, which can appear before, after, above, or below a character.

tame shell
mental oriole
#

one min

#

ill post a screenshot

#

ಭುವನೇಶ್ವರ

#

looks like this

tame shell
#

hmm i kinda see whats wrong. Have you tried with tmp v 3.2?

mental oriole
#

testing

#

i thought text mesh pro was in built in unity 6?

tame shell
#

i cant even find a font that support these characters on google fonts.
I dont know, check the package manager

mental oriole
#

eh, something weird happened, wasnt able to sent message

#

it isnt there in the package manager

#

2 mins

#

will check again

low pike
#

TMP is built in with U6 I believe - theres no package for it

mental oriole
#

ah okay 😦

#

welp, he isnt active on github as well

tame shell
#

why did they change it 🤔

#

I wonder if ui toolkit will render it correctly or better

mental oriole
#

T_T

low pike
tame shell
low pike
#

That is a good point - cant think of ever doing that personally, but is useful

haughty drift
#

can some one please tell me what im doing wrong here. Im trying to use the horizontal layout i made the width 360, the text width is 260 and the circle image is 80 the height of all 3 are 100. but it does not put them centered inline.

mortal robin
rapid ferry
#

I'm trying to add a Scroll View to my UI, I created this from the menu, so it came with the Viewport, and Content Game Objects.

I have some text which I was trying to scroll through vertically.

If I choose Elastic (Movement Type), the scroll bounces back to the starting point when I let go.
If I chose Unrestricted, I can scroll out out of bounds of the text so it disappears.
If I chose Clamped, it doesn't scroll.

I can record the screen to show the examples if it helps.

Can someone please help with how I allow my scrolling as I would expect?

  • To stay at the location when I let go.
  • To only be able to scroll to the top and bottom of the text.
azure flame
cloud stratus
#

any ideas why scene view darker than game view?

proud sandal
cloud stratus
supple basalt
#

Note that the scene view will incorrectly display an Overlay canvas with post-processing

#

that's why turning it off made it consistent

dense hornet
#

Hi! Need help with toggles

#

I have a bunch of toggles in my scene. Instead of having a separate function for each, I made it take a string with the toggle so I can make a case switch with each possible result

#

The problem is that toggles only call On Value Changed (bool), and apparently I can't pass both a bool and a string into my function. If my function is public void SetTags(string tag) it works, but if it's public void SetTags (bool check, string tag) it suddenly stops showing up on the editor

minor ocean
#

Not totally sure of your setup, but if the string is the toggle name or something, you can make the toggle call SetTags(bool) and then in that function send the string you want. Like the gameobject name.

long marten
#

Elastic just pulls it back

#

when I do have content that should allow it to scroll

minor ocean
#

Make sure the content rect is big enough to hold all of the content. The scroller only cares about that rect, but what's in it.

rapid ferry
# azure flame Size of the content object must be larger than the frame so it has something to ...

Thanks! It could be my mistake, but I either did not come across it, or there was a lack of the UI tutorials on Unity Learn.

My mistake was creating a child Text - TMP GameObject, when the solution was to simply add a TMP Text(UI) component to the Content GameObject.

This person (https://www.youtube.com/@ChristinaCreatesGames) helped explain it, and has quite a few UI related tutorials which might help others.

supple basalt
#

The defualt content object doesn't have a vertical layout group

supple basalt
#

(it also needs a Content Size Fitter to make it actually change in size)

#

Attaching the text component directly to the Content object does work, too (as long as you only need that one text component!)

woven lake
#

Im trying to open up the unity ui editor and it refuses to let me do so. any help pls?

woven lake
#

when my mouse is here, it works. not on any of the other buttons tho

wise estuary
#

i used a script to check where my mouse position was hitting and it hit the button fine... i dont know, if you want more details with screenshots please follow the link it not too much but its already there

#

but in short on focused mode it does not recognize hover and click on the mouse, but on maximised everything works fine. and also touch works fine for click in any mode

woven lake
#

hmm.. i moved on from that part, and now im trying to make it when i hit the start button, i go into the other scene, but it doesnt seem to wanna work now

supple basalt
#

you can double-click on the game tab to maximize the window

wise estuary
#

yes, if i maximise (starting in focused mode) works fine

supple basalt
#

What else is in your hierarchy?

#

The script you used earlier tells you all of the things that one graphic raycaster hits, but it's possible that you have another canvas with something that's eating the raycast

wise estuary
#

no i dont have any more canvas

#

i have a few objects but no more canvas, no more event systems

#

its strange, if i touch the button, with my touchscreen, it works

#

so i dont know why would it "eat" the raycast with the mouse

#

only on focused mode

supple basalt
wise estuary
#

yes

supple basalt
wise estuary
#

the behaviour maintains

haughty drift
#

i have this tv static generator, its using a quad is using scale the only way to control the size? would there be a better way?

supple basalt
#

the size of the actual renderer?

#

i'm a little unclear what's going on here

supple basalt
#

can I see the inspector for the canvas and the button?

haughty drift
#

so the static is small. the only way to make it bigger is to use scale. feels like increasing the scale is the wrong way to do it

#

only way i can get it to fill is scale

supple basalt
#

you should be using an Image for this, not a mesh renderer

#

a RawImage, specifically

#

that'd let you use a render texture directly

#

(although it looks like the "TV Texture Generator" wants to modify an entire material, rather than just drawing to a Renderexture)

haughty drift
#

ok cheers

wise estuary
# supple basalt that's quite interesting...

maybe i should report as a bug.. i dont know what else to try, i am not currently focusing on that since i can keep going, its just anoying that i cant test my button normally in the focused window

supple basalt
#

and then reference its RenderTexture from a RawImage

#

(this all assumes a render texture is involved)

haughty drift
#

like this im just getting a black screen

wise estuary
# haughty drift i have this tv static generator, its using a quad is using scale the only way to...

i had to take my mind away for a bit so i made this:

using UnityEngine;

[ExecuteInEditMode]
public class QuadResizer : MonoBehaviour
{
    [SerializeField]
    MeshFilter filter;

    [SerializeField]
    Rect rect = new(0, 0, 1, 1);
    Rect previousRect;

    void Awake()
    {
        previousRect = rect;
    }

    void Update()
    {
        if (rect == previousRect)
        {
            return;
        }

        var vertices = filter.sharedMesh.vertices;

        vertices[0].x = rect.x;
        vertices[0].y = rect.y;

        vertices[1].x = rect.x + rect.width;
        vertices[1].y = rect.y;

        vertices[2].x = rect.x;
        vertices[2].y = rect.y + rect.height;

        vertices[3].x = rect.x + rect.width;
        vertices[3].y = rect.y + rect.height;

        filter.sharedMesh.vertices = vertices;

        previousRect = rect;
    }
}

if you add this to your quad object you can adjust the vertices, i have no idea if this is the same as scaling, and as fen said you might have better options

supple basalt
#

If you can modify the script a bit, you can add a RawImage field, then have it assign the render texture to the mainTexture property of the raw image when it sets itself up

haughty drift
supple basalt
#

It should have something very roughly like this:

RenderTexture rt = new RenderTexture(2560, 1440, 0, ...);
material.SetTexture("_MainText", rt);
wise estuary
#

sure, this seems "dirty" it just doesnt change the scale but i assume the material will stretch anyway idk

supple basalt
haughty drift
#

awesome thank you

haughty drift
#

somthing is alittle off, the screen is now black but i can see the texture preview

#

i did ask chat gpt for alittle help, as im not to clued up on this.

wise estuary
#

idk if you ca ntry the component i shared, as i said i dont have much hope but i am curious and it doesnt take much to test (just add new component on the original quad object, if it doesnt work at first just set the filter field and reload scene as i assign a value in the awake method)

haughty drift
#

yh i did try that it didnt strech it at all

wise estuary
#

you mean the quad didnt resize?

#

or the texture?

haughty drift
wise estuary
#

if its the texture you might need to apply normals or bounds after modifying te vertices

haughty drift
#

ah ok ill give that another look at in the morning, cheers

wise estuary
#

what is that? i see you have the component but i dont know what is happening if you dont explain, i tested the script and it does modify a quad, but i didnt have texture, you might need to add a line of code or two after the vertices are modified, such as some of these:

filter.sharedMesh.RecalculateBounds();
filter.sharedMesh.RecalculateNormals();
filter.sharedMesh.RecalculateTangents();
filter.sharedMesh.RecalculateUVDistributionMetrics();```
if its not working at all maybe need to reload scene for first time or change code to avoid the awake logic
haughty drift
#

Ah yes sorry, it does seem to set the quad to 2560x1440

wise estuary
#

ok, and if the green is the quad and its not at the correct position just set the x and y to center

haughty drift
#

yh so your script does work, so will the width and height be what the scales would have been i thought it was 2560x1440 for my screen size. 1, 1 ust makes it the size it originaly was

wise estuary
#

the transform position is the origin, the x and y will offset that, width and height will "scale" but without modifying transform scale. its like if you imported a quad with a different size

#

the issue with this approach is that i think will be effectively the same as using scale 😅

woven lake
#

im still having some issues making the play button open a new scene. any help?

mortal robin
#

And by "play button" do you mean the Start button pictured?

#

or something else?

woven lake
#

yes

mortal robin
woven lake
#

ive tried following a tutorial listed by the professor, and editing the code for fixes and checks, but it just wont swap. i even made the scene name changed to have no spaes in case it didnt read it but it still wont swap

#

ah- sorry-

mortal robin
#

ok well - you would need to show us what you tried

#

and also - make sure your console window is open so you can see any logs and errors

woven lake
#

it was this one that was listed-

woven lake
mortal robin
woven lake
#

one moment, let me forward my thing to the right chat

cyan fossil
#

i cant click my button

oak lantern
#

Hello everyone! I was wonderinf yall could maybe help me out. I have the GREEN UI objects and I want to make their POS be the same as the YELLOW object.

As you can see they are in different hierarchies and it makes it hard to make their position be the same.

The object is instantiated at runtime so i can manually place it there.

Can anyone provide some guidance?
I tried various options but used AI so i dont fully understand the anchored postition and point to world space jargan when it comes to UI.

sand mantle
#

Not sure how to search for this, or where to ask for this since it's more of a design question. How can I signify that a text is coming from a character outside the screen? I know I've seen this in games but can't quite remember different ways of doing this.

supple basalt
#

You could have it subtly move away from the edge of the screen as it appears

sand mantle
#

yeah definitely think that's gonna help, I feel like I'll probably need more than that though

#

will start experimenting with atleast that

haughty drift
wise estuary
#

good to know

low pike
sturdy narwhal
#

If I have a ui panel that i want to display items on, how would i make them not spawn on top of each other? I assume I could just change the spawning pos by a set value but is there a quicker way to do it?

ebon badge
#

What do you mean 'on top of each other'? If you mean one of them overlapping the other, use Sorting Layers.

supple basalt
#

a VerticalLayoutGroup set to control child size (and to not force-expand children) will arrange them vertically

gloomy whale
sturdy narwhal
alpine glade
#

hi, the yellow box is a container and i am trying to add sprite into it, but its invisible, what am i doing wrong?

mortal robin
alpine glade
#

SpriteRenderer

mortal robin
#

SpriteRenderer is not for UI

#

that's for game world objects

#

use the Image component

alpine glade
#

ok, got it

#

thanks

deep turtle
#

Anyone got any ideas / resources for functioning radial slider bars? looking to spice up the look of the normal sliderbars, knobs would work aswell. prefferably free resources

mortal robin
deep turtle
#

thats wierd, i dont have those options

mortal robin
#

you do

#

you need to assign a sprite first to the "source image" field

#

then set the image type to "filled"

deep turtle
#

ahh yeah i see

#

This makes radial value display easy enough, however i really wanted to make it interactable, like a slider. I suppose its possible but its gonna take time i dont really have

#

found sliders that work radially, but it still a "left-to-right" dragging action

mortal robin
#

Yeah you would probably need some custom code for that

#

wouldn't be super hard I think - just a Vector3.SignedAngle call basically between the mouse position and the center of the slider

deep turtle
#

i dont think it'd be too difficult no?

#

yeah thats what i thought

#

wierd that theres no assets or stuff when i search for it

mortal robin
#

I guess it's just not that common of a use case

#

I can't remember ever in my life dealing with a radial/dial style interactable UI in a video game

#

In real life plenty sure

deep turtle
#

yeah for dragging ur mouse around a radial is gonna be that much more annoying i guess

mortal robin
#

Yeah I think it would be sort of weird/annoying lol except as like a very stylized thing

deep turtle
#

just looking for ways to spice up my UI tbh from just buttons, inputfields and sliders

mortal robin
#

I could see a game where you're driving an 80s car around and there's a knob in the car to turn the radio volume up or something lol

deep turtle
#

mysummercar type game fr

mortal robin
#

I think it'd be better to spice it up visually rather than fundamentally chjanging the interaction style maybe?

#

Are these just for like a settings menu?

deep turtle
#

ah no, im using unity for a rather unique scenario, working with a company to gamify / spice up one of their tools. but it could be compared to a settings menu i guess

#

but yeah spicing them up visually brings the risk of too much distraction, so im trying everything to introduce a certain feel without too much visual stimulus

#

ah and its for my undergraduate project, student boio here

deep turtle
#

but i suppose im gonna have to do this with stuff thats external to the buttons and stuff itself for now

supple basalt
#

Dials usually get rotated with a horizontal or vertical mouse movement

simple torrent
#

Hey I've been trying to figure this out for a while now, I feel like this should be very simple but all the forum posts about this exact thing just don't work for me...
I want a vertical layout group that holds a number of children
each child holds a variable height textbox

the textbox is simply a background image with text in front of it
like this:

#

I just can't seem to get my head around it,
I've made a textbox that scales its background image depending on its child TMP using a content size fitter,
but when I try to put this in my vertical layout group it gets fussy about children of layout groups cannot have content size fitter and it does not do the layout properly

supple basalt
#

Content Size Fitter should only be used if your parent doesn't control your size

#

Your hierarchy should look like this

#
  • Root <-- ContentSizeFitter, VerticalLayoutGroup
    • Box <-- Image, VerticalLayoutGroup
      • Message <- TextMeshProUGUI
    • repeat many times
#

Every vertical layout group should be set to control child size. Uncheck the "force expand" options.

#

Set the content size fitter to provide the preferred amount of vertical space

#

You can leave the horizontal size unconstrained if you want a fixed width

sturdy narwhal
#

I have 2 images (Tooltip and Soda) which are overlapping, the panel is a child of the soda on the left. How can I stop them from overlapping?

supple basalt
#

Anchor the tooltip to the bottom right, rather than the center

#

Additionally, set the tooltip's pivot point to the top left

#

Here's how it should look.

#

And here's how that'll look. The "tooltip" is the red panel here

#

You might want to use the bottom center instead

sturdy narwhal
#

That hasn't helped

#

It's still under the soda

supple basalt
#

Oh, you're talking about how the tooltip appears under the second soda can

sturdy narwhal
#

Yep

supple basalt
#

You'll have to place the tooltip after all of the other images in the hierarchy

#

so it won't be a child of the soda can image

sturdy narwhal
#

How would I do it on a prefab?

supple basalt
#

Does every single soda can icon have its own tooltip attached to it?

sturdy narwhal
#

Yeah

supple basalt
#

If so, I'd get rid of that. Use a single tooltip object that you position via script

sturdy narwhal
spare hollow
#

Is it actually worth using svg in ui at all? Seems like it comes out all jagged and distorted. Wondering if it’s better to just use vector for the art but export to png at the intended size instead

supple basalt
#

switch it off from the "Vector Sprite" import mode and you can get roughly that

#

i forget the exact names of the other modes

#

one will just create a texture

spare hollow
low yoke
#

Hello, can I replace the blinking " | " in an input field with an underscore ?

low pike
#

That's called the 'caret' - which might help you in you googling

low yoke
#

Can I make it so that the content in my Scroll View is aligned with the top instead of the center of my " Content " game object ?

mortal robin
#

Change the anchor

haughty drift
#

Hi whats the best way to use unity events for buttons my current set up is like this for the buttons are like this

#

or tho this works as soon as i move the mouse out side of these buttons none are no longer highlighted. in the past i did somthing like this to set the buttons. EventSystem.current.SetSelectedGameObject(null); EventSystem.current.SetSelectedGameObject(controllerButton); I was just wondering if im making it to complicated and unity ships with a tool to handle this. because if i do it this way - again i got an issue of when my mouse hovers on them and when they dont

minor ocean
#

Not totally sure what you're trying to do. Do you want buttons to remain highlighted after your cursor leaves their boundaries?

hoary kettle
#

I want to remake the HUD for my game to fit better in the environment, any ideas?

vapid edge
#

Hey friends, I'm working on an extremely ui-heavy mobile game, and I have an interesting task.

Turns out we need support for not only phones, but tablets as well - including portrait AND landscape.

For reference, I'm using the old ui system, not uitoolkit.

How do you all here tend to approach something like this?

#

Different prefabs based on aspect ratio/orientation? Or fight with the layout system?

#

Something else?

mortal robin
#

Use the resolution picker in scene view to test different resolutions and set up anchoring etc properly

#

In some cases you might want a totally different layout for portrait vs landscape but it depends

rain flare
#

Someone know ow to fix it?

azure flame
rain flare
#

so what should i do?

#

in short

azure flame
azure flame
#

Make sure you are using TMP Font Asset creator not regular one and there's atlas preview as well. For regular font 512 usually enough too.

mighty ridge
#

sometimes using a smaller atlas (like 512) fixes it..

rain flare
#

In one scene the text looks good and in another scene it looks like this:

mighty ridge
#

theres also different shaders u can try out Bitmap has worked for me really good for crisp text

rain flare
#

but when i change "cull mode" to front its look like this:

mighty ridge
#

oh welp theres yet another solution ill have to remember or look into lol

mighty ridge
#

so now i only use 512

low pike
#

TMP doesn't like small values. So the scale of the RectTransform should be 1,1,1 and the font size needs to be > 1

rain flare
#

yeah its related to he canvas

#

when i changed it to screen space its back to normal

mighty ridge
harsh cobalt
#

also not sure if it would be a good idea here then to use ugui in tandem with ui toolkit, as i'm not exactly sure what the intended relation between these two are...

low pike
#

Move this question to #🧰┃ui-toolkit (delete from here so you don’t get told off for cross posting)

low pike
strange imp
#

Hello everyone, me and my teammates are currently debating how to architect our Unity UI. (Not toolkit) We are leaning towards having each UI View in it's own scene with it's own canvas. The main benefit being you can hit play and the UI is quickly fully interactive and quick to debug while you develop. I and another teammate find the idea of using scenes for views kinda repulsive and don't really know why. We can't really find any reason not to.

In the case we need to instantiate multiple of the same view, such as generic popups, we can just manage them under a single view.

So, looking for reasons this might be a bad or good idea.

mortal robin
strange imp
#

That is what we are moving away from

mortal robin
#

Scenes can be a little cumbersone to deal with in the editor

#

but there are some advantages like async loading

strange imp
#

You can async load prefabs in addressables too though.

mortal robin
#

Indeed with a little more setup

strange imp
#

The argument is prefabs vs scenes. I prefer prefabs but can't really say why.

mortal robin
#

What's the benefit of scenes

strange imp
#

The main benefit being you can hit play and the UI is quickly fully interactive and quick to debug while you develop.

#

This one is the only one we have so far

mortal robin
#

Couldn't you achieve that for your prefabs pretty easily too? Something like a UI tester scene?

strange imp
#

Faster iteration on testing and development

mortal robin
#

You could just make a little helper script that, for example, lets you pick which UI you want to edit from a dropdown

strange imp
#

We could but the question is why put the extra effort into it?

mortal robin
#

populated via AssetDatabase calls

#

The benefit would be that you can just use prefabs

#

instead of scenes

#

and not have to deal with scenes

#

I don't have a horse in this race really, just pointing out options

strange imp
#

Yeah and again, I prefer prefabs. Trying to look for a good argument not to do scenes

mortal robin
#

the main argument against scenes is they are cumbersome to load and unload and manage in code compared with prefabs

#

they're also more annoying to edit

#

prefabs get prefab mode

strange imp
#

So far I have none other than maybe multiple canvases vs a single root canvas with subcanvases might have slightly worse rendering?

mortal robin
#

you have to actually load a scene in the editor to edit it

strange imp
#

You have to load prefabs too in order to edit them.

mortal robin
#

you'll also need to keep your build scene list up to date for the UI scenes

mortal robin
strange imp
#

You can change a few things on the root of the prefab via the inspector but anything inside you have to open the prefab.

mortal robin
#

which leaves your scene intact

#

yeah but that's lighter weight than opening a scene

strange imp
#

So double click prefab vs double click scene?

mortal robin
#

Editing a scene -> double click prefab -> hit the back arrow to go back to the scene

#

there is no back button when you load a scene

strange imp
#

Yeah but the scene only contains that specific view. It's like a prefab but not haha.

mortal robin
#

You can also reference prefabs in the inspector

strange imp
#

It's a crazy idea and was caught off guard by it

mortal robin
#

that's a huge advantage

#

can't reference scenes

#

Not without plugins

strange imp
#

True but our UI system only cares about the BaseView component on the root game object.

mortal robin
#

Prefabs also get prefab variants

#

another huge advantage that scenes don't have

#

I think those two alone give prefabs a huge edge. Variants and the ability to reference in the inspector

strange imp
#

Yeah true, though our team does not want to have variants of our views. Only components like buttons, text fields etc.

mortal robin
#

If you have some BaseView component that's a great case for prefab variants.

#

There would be a base prefab with that component and all the rest would be variants of it

strange imp
#

Yeah, in theory it sounds great but we've noticed that people try to reuse views too much and they become complicated and maintenance hell with variants.

mortal robin
#

Anyway again, not my decision but I think those are some good reasons.

strange imp
#

I think that's because views are too specific in how they need to work. Though components like buttons and stuff it makes sense to make small changes and have variants.

mortal robin
#

I really haven't heard any benefit to scenes other than the ability to hit play and run the UI scene alone. Which doesn't seem all that useful to me tbh

strange imp
#

Yeah, thanks for trying. I'v already argued these things but valid points against it keep getting raised so we might just have to try it and see how it goes.

strange imp
pale lichen
#

anyone know why scrollbar steps are capped at 11?

#

at least switching to debug mode lets me set it to higher than 11

magic walrus
#

i have the character health bars as a canvas in world space as a child of the actual unit. it's not too bad in the screenshot here but sometimes larger units can block the view of the health bar more and im wondering what i can do about that short of switching to a screen overlay canvas. any recommendations? thanks

mortal robin
magic walrus
#

i dont mind when it's a little blocked like the screenshot, but sometimes the taller units block it more like this. maybe ill just up the y position on the healthbars a bit and see how that looks

harsh cobalt
#

I was testing out button.clickedWithEventInfo and was wondering if there was a reason why my originalMousePosition debug console always outputs (0, 0, 0)

#

For context I have three buttons in different positions on the same ui document

sharp dagger
#

probably easy to answer, I had a break from Unity and can't remember:
I have the attached sprite. When setting the GameObject to Simple I get second picture. Sliced I get third picture. Scale is X1 Y1.

How do I make the border stick to it's size and adjust to my tiling when changing it's size?

low pike
#

also press T and use the UI gizmo tools when working with UI

sharp dagger
#

I have not touched the scale, it's X1 Y1. I only changed the Canvas Scale to X.02 Y.02 for world space.

low pike
#

That is stretched to its parent, what is the parent rect like

sharp dagger
#

@low pike

low pike
low pike
#

would you mind sharing the border image?

#

the actual png

sharp dagger
#

Idk if I'm allowed from a copyright perspective tbh

#

does this help?

low pike
#

what's the image component look like now you've set it to sliced

sharp dagger
low pike
#

click 'fill center'

#

Though, thinking about it - fill center probably fills the square in the middle, not the "center" between the slices 🤦‍♂️

sharp dagger
#

yea this didnt help

#

I have set this up multiple times in past projects I really don't understand what I did wrong this time

low pike
#

Things look right.. but I need an image to play around with - rather than going back and forth

dense hornet
#

Why is my toggle not passing onto the method the bool value of Is On, and instead, is passing the value of that little square under the method?

#
    {
        if (is2024) toggledEntries.SetActive(false);
        if (!is2024) toggledEntries.SetActive(true);
    }```
honest saffron
dense hornet
#

Ohhh ok ! Thanks

fathom merlin
#

Should I use LeanTween for UI? or is Animator ok for UI now?

#

many tutorials said animator is a bit expensive on the system, but its been years so idk if that talk is still up to date

supple basalt
#

using an animator for UI animations just sounds annoying

fathom merlin
#

Heavy on the system I mean

subtle pilot
fathom merlin
#

Still very much a beginner

subtle pilot
supple basalt
#

Animators make sense for a single "thing" that has a complex series of animation states it can be in

#

UI is more like...50 tiny things, with only a few states

frigid bone
#

Anyone have any guesses as to why this localized text is showing two lines in the same place? I had this issue before a while ago but I don't remember what fixed it 😔

minor ocean
#

If you're using Text Mesh Pro, possibly have the "Paragraph" setting to a negative value?

radiant sorrel
#

hi, my circle gameobjects have text in them. how can i center their texts so that they're not centered in the middle of the screen?

supple basalt
#

show me the hierarchy, as well as the inspectors for the circle object and text object

supple basalt
#

Don’t use sprite renderers. The canvas has no idea what to do with those

#

They’re rendering separately

#

You should be using an Image component to draw sprites in a UI

radiant sorrel
supple basalt
#

You are probably trying to position the images at the world-space position that you clicked at

#

Notice how, in the scene view, an overlay canvas looks really big -- much larger than the camera

radiant sorrel
#

yeah

supple basalt
#

For an overlay canvas, you can literally just set the position of the object's Transform to the screen position of the mouse

supple basalt
radiant sorrel
#

ohh okay

radiant sorrel
supple basalt
#

bool Returns true if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle.

This just tells you if the method succeeded

#

in some cases, it's possible to miss the rectangle entirely

#

e.g. on a world-space UI

#

The actual result goes into an out parameter

#
public void GiveMeFive(out int num) {
  num = 5;
}

...

int x;
GiveMeFive(out x); // x is now 5
#

They're useful for when a function wants to give you several things

#
public bool TryGetNum(out int num) {
  if (canGiveNumbers) {
    num = 123;
    return true;
  } else {
    num = 0;
    return false;
  }
}

very commonly seen in "Try"-style methods

supple basalt
radiant sorrel
#

and then i can use that world-space point to see where i should spawn the circle right?

supple basalt
#

Yes.

#

pretty much just circleObj.transform.position = worldPos;

#

Personally, I would do it like this:

if (RectTransformUtility.ScreenPointToLocalPointInRectangle(holder, screenPoint, null, out var point))
{
  var circleObj = Instantiate(circlePrefab, holder);
  circleObj.transform.localPosition = point;
}

where holder is the RectTransform you're parenting the circles to

#

note that I used ScreenPointToLocalPointInRectangle here

#

which gives a local position

radiant sorrel
#

the circle are all parented to their own world space canvas so that would be the holder, right?

supple basalt
#

It'd work the same with WorldPoint; you'd just set position instead of worldPosition

supple basalt
#

Reference it as a RectTransform

radiant sorrel
#

okay, one last thing sorry, im a bit unsure of what screenpoint is. would that be a transform.position of the tile im spawning from?

supple basalt
#

Ah, I think I’ve misunderstood what you’re doing. Are you have a tilemap?

radiant sorrel
#

no, i just have some square gameobjects laid out in a checkerboard pattern and whenever i click them they spawn the circle objects. i just call them tiles, sorry for the misunderstanding

supple basalt
#

or are they using SpriteRenderers?

radiant sorrel
supple basalt
#

so you need to find a position on the UI that'll match the world position of the tile

#

you can first turn the tile's position into a screen position with Camera.main.WorldToScreenPoint

#

and then use that screen point to find the right position on the UI

#

it's a bit awkward because the tiles aren't part of the UI

#

(also, resizing the window would then cause all of the spawned objects to slide around!)

#

you may want to keep everything in the UI or out of the UI

#

rather than mixing the two

radiant sorrel
#

oh okay good to know

#

so then screenpoint would just be the rect transform of the tile i clicked since they're already ui right?

supple basalt
#

If you put the tiles into your UI, then yes.

You could also just use the tile's position at that point

#

(since it'll be on the same canvas as the circles)

radiant sorrel
minor ocean
frigid bone
# frigid bone

Bizarre. Deleting the text entry in the localization tables and retyping it fixed it.

cloud lintel
#

This warning is pretty annoying. Mainly because no matter how many times you disable Normal and Tangent channels they always get turned back on automatically.

mortal idol
carmine cliff
#

has anyone encountered (at least on mac os) that setting a custom mouse cursor, it reverts back to the OS one when you move the mouse (at least in editor)? The only way I found to keep it from changing back is to put "Cursor.SetCursor(gameCursor, Vector2.zero, CursorMode.Auto);" in the update loop...which is obviously a far from ideal solution.

dense hornet
#

Why is it that when I add Entry List as the content on my Scroll Rect the whole list gets pushed to the side?

subtle pilot
#

Or it could be padding if you are using a layout group

frank pewter
#

I currently have a canvas rendering everything including a camera and some ui elements, I want to add another camera renderin on top of the current canvas in a 300x300 pixel size, how could I do this. When I add a new canvas I cant change the size when it is in screen space rather than world space. I dont have a lot of knowledge so anything would help

mortal robin
frank pewter
mortal robin
#

The object with the RawImage is

austere ibex
#

why when i build does my UI get messed up?

mortal robin
austere ibex
#

alr ty

low pike
vague oriole
#

Anyone know why my TMP text is outrageously blurry from afar?

#

Third screenshot is the built-in Liberation Sans font asset for reference

low pike
#

Where's the inspector screenshot I asked for ;p

vague oriole
#

Oh crap sorry didn't see that part lmao

#

I'm assuming this is what you wanted and not the font asset

low pike
#

Yes, this is the inspector

#

Now, with the UI version of TMP, it does not like the scale or the font size to be < 1. Your font size is 0.37. I assume the issue happens on the 3d TMP as well, but I haven't used it in years to be able to say for sure

#

Make your font 1 (or higher), decrease the width/ height of the rect

#

Or maybe, increase the width/ height of the rect, and the font.. give it an empty parent and lower the scale of the empty parent

vague oriole
#

That sounds better I'll try that quick

#

Unfortunately that didn't work

#

I think it's a bit better? Definitely a tad less smudged from the bloom

#

But not as clear as liberation sans (none of the fonts I've tried were as clear is though)

low pike
#

Yours looks bold, the lib sans isn't

#

Is the 'bd' in the font name for bold?

#

get 'good timing' regular

vague oriole
#

That didn't even occur to me tbh I just snagged this off dafont

#

I'll see if I can find it

#

Doesn't look like there is a regular version I'll try a thinner font though and see if that helps

#

I don't think it's because of the font. I just tried a thinner font and it's still not as clear

#

Waaait

low pike
#

When you first created the sdf font asset, did you change any settings?

#

I've pretty much never needed to edit them

vague oriole
#

I did not

#

I just tried adjusting the padding with the thinner font and I think it's clearer than the thicker font I'll do a quick comparison

#

Okay yeah nevermind it definitely is the thick font

#

Which sucks because a thick font is really what I need

low pike
#

there's still the bold option on the TMP component, which might work

#

as in, might look ok

vague oriole
#

Yeah I'm probably just gonna have to settle for that lol..

#

Well I appreciate your help thank you

vapid edge
#

Unity's UI will drive me crazy one day.
Is there really no way to do render layers within a canvas, that doesn't include adding more canvases?

#

I want one object to be underneath another object, but I can't do it by reordering them in the hierarchy

low pike
#

why can't you reorder the hierarchy?

mortal robin
#

there's no other way other than multiple canvases

#

What are you trying to achieve?

merry creek
#

Hey, a question about TextMeshPro. It imports into the Assets folder. Is it 100% safe to move it to another folder (for example assets/plugins? Or could this break functionality/give errors/warnings?

vapid edge
# mortal robin What are you trying to achieve?

I have 2 UI objects, Content, and Background. Background uses this little script

            Bounds targetBounds = RectTransformUtility.CalculateRelativeRectTransformBounds(
                (RectTransform)rectTransform.parent,
                target
            );

            rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
            rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
            rectTransform.pivot = new Vector2(0.5f, 0.5f);

            rectTransform.anchoredPosition = targetBounds.center;
            rectTransform.sizeDelta = (Vector2)targetBounds.size + sizeBuffer;
``` to nicely get behind all the children of content, and cover all of them, with a padding of SizeBuffer
#

now, of COURSE, I have a situation where I want a child of target to NOT be included in this check

low pike
#

is there a reason you're not using layout groups and content size fitters?

vapid edge
#

content size fitters are too limiting, and what I'm doing is not really covered by layout groups

#

Unity's UI system is patheticly limited in that regard, sadly, and I have like 5 helper scripts that adjust sizes of elements on the fly - getting them to work without outright crashing unity in certain situations was a pain

vapid edge
#

I want it to stick out from underneath the background kinda outside

#

and I can do it, with careful anchor and pivot setting

#

but I'm also sometimes scaling the content, and the background updates nicely, but the element that's sticking out scales towards a different anchor point

#

and I'm afraid that I have to make another helper script, to force its anchor to be the same as content

supple basalt
#

if you're breaking the rules of normal UI layout, then you will need to do a bunch of extra work yourself, yes

#

what effect are you trying to create in particular?

#

not "make an element stick out" -- what kind of interface are you going for here?

vapid edge
#

I'm using an animation where my content goes between scale of 0 and 1

#

and the background scales automatically and nicely to account for that

#

but the decoration underneath the background scales towards the pivot of the background which is set as different than the pivot of the content

supple basalt
#

the first thing that comes to mind is doing an inverted mask

low pike
#

Id have a parent container and scale that

supple basalt
#

the next thing that comes to mind is this setup:

  • Window
    • Decoration
    • Background
      • Button
#

I think that's what Carwash is suggesting

#

Decoration would be excluded from auto-layout

#

(that's an option on the Layout Element component)

vapid edge
vapid edge
austere ibex
#

i want to make a nametag above players, but im not sure how.

ive tried attatching the canvas to the player and then:

  • rotate the text to the camera
  • set the rotation to the inverse of the camera
    however both of these barely dont get what i want and im not sure how to fix.
    the first one rotates the text on the Y axis which i dont want, i want it to be flat not turned
    the second one makes it rotated downwards
mortal robin
#

anyway you'd have to show your code

austere ibex
mortal robin
#

it should pretty much be text.rotation = Quaternion.LookRotation(-cameraForward, cameraUp);

alpine glade
#

im giving my script 2 images but when i starting the game remove them

#

before

supple basalt
#

which can be a bit weird

#

(i saw this in a VRChat world recently, which is why it was on my mind)

#

Ideally, it should look in the camera.position - transform.position direction

near coyote
#

huh

supple basalt
#

Does the rendered color change at all as you change the vertex color?

near coyote
wooden elk
wooden elk
# wooden elk

I don't know if it's related to UI. But in my game view, I can see the UI texure

unique orchid
#

Hey! I’m having a weird issue—it looks like a Unity bug, to be honest, but I might be wrong.

I’ve written a script to make the UI Image mask work the other way around (negative stencil):

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Rendering;

public class CutoffMaskUI : Image
{
    public override Material materialForRendering
    {
        get
        {
            Material material = new Material(base.materialForRendering);
            material.SetInt("_StencilComp", (int)CompareFunction.NotEqual);
            return material;
        }
    }
}

This works great, but only when I start the scene from the Unity Editor. The game runs, and the mask behaves as expected. However, if I start from an other scene and change scenes ( to the one with the mask ) using LoadScene(), the object with the mask is not rendered at all even tho I can see it in the hierarchy (enabled), and if I toggle it on and off, it appears as expected again.

Anyone have a clue ?

mortal robin
unique orchid
digital loom
#

Hello, my custom mesh canvas renderer only works when it is behind images and it disappears when it is in front of images, any idea why?

mortal robin
#

good lord why does that look so similar to the above screenshots

unique orchid
#

I thought the same, ahah

digital loom
mortal robin
#

what bounds is your Renderer outputting?

digital loom
#

It is a Canvas Renderer, it does not have a bounds property.

digital loom
#

that is a word space renderer

mortal robin
#

indeed - interesting that CanvasRenderer does not derive from Renderer

#

that's surprising to me

#

Maybe related to the RectClipping stuff then?

austere ibex
#

ive been messing with this for a while, im kinda new to unity so i dont know much.
i wanna have a in between screen where player see their point gains from last round, right now i am deleting tmp_texts based on the amount of players there are (delete 1 if there are 5 players, etc)

my issue has been this:
is there a way to make these space evenly? i put them in a layout group but then it just removes from the right

digital loom
mortal robin
#

basically you just didn't set up your layout group properly

austere ibex
mortal robin
#

For the second thing - the anchors are part of the RectTransform

austere ibex
mortal robin
#

Anyway it's quite easy to test the layout group at edit time

#

just adding/deleting objects

#

no need to run the game

#

so - play with things there till it's working properly

austere ibex
#

i got it to work, thanks :)

supple basalt
unique orchid
# supple basalt I bet that Unity was expecting to get the same material every time it accessed `...

Yes exactly! I've "cached it" so it works now, I can share the code for anyone that might be interested:

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Rendering;

public class CutoffMaskUI : Image
{
    // Cached material instance.
    private Material _cachedMaterial;

    public override Material materialForRendering
    {
        get
        {
            if (_cachedMaterial == null)
            {
                _cachedMaterial = new Material(base.materialForRendering);
                _cachedMaterial.SetInt("_StencilComp", (int)CompareFunction.NotEqual);
            }
            return _cachedMaterial;
        }
    }

    protected override void OnDestroy()
    {
        if (_cachedMaterial != null)
        {
            DestroyImmediate(_cachedMaterial);
        }
        base.OnDestroy();
    }
}
waxen anvil
#

We're updating our project from 2021.3 to 6000.0 and we've noticed something weird, on .32 fonts seem fine but when we moved to .36/.38 it seems like some TextMeshPro font assets are somehow broken and take random characters from LiberationSans default font, despite it not even being in the fallback list. Did anybody ever see something like this? It feels like a bug to us

proper onyx
#

I have finished the worst part of the game, so now I have a UI working properly with no bugs, but it's ugly. I am not good at ui-ux, so could you give me some advice to improve my ui's beauty?

(The squares of the shop are supposed to be illustrative images about the item)

low pike
proper onyx
turbid plume
#

Why is my button text so fucked up? It's skinny and I needed to add a space between every letter

#

and I can't see any new things I add to the UI.

Fuck I hate UI

proud sandal
turbid plume
#

and I can't add any new stuff to the UI, it doesn't show up in game mode

#

ok I figured out the showing up part but the text is still blurry and skinny

mortal robin
#

to properly work on UI do this:

  • Set your scene view to 2D mode (2D button on the toolbar)
  • Select the Rect tool
  • double click your canvas in the hierarchy
turbid plume
#

it's already in 2d mode and textbox is about the size of the button

mortal robin
#

you'd have to show the inspectors of those objects

turbid plume
#

for new text added, it's not showing up at all

mortal robin
#

screenshots

turbid plume
mortal robin
#

why are the height and width so tiny

#

1 and 2 pixels?

#

you're doing something weird here

#

Can you show your whole canvas?

#

And jus8t share full screenshots of the whole editor, don't crop it

turbid plume
#

ah I think I see

#

stupid unity

mortal robin
#

Also would recommmend not using the legacy text

turbid plume
#

scaled my parent object to 60, 60 without provocation

mortal robin
#

TMP is better

#

yeah do not scale UI stuff

#

resize it

turbid plume
#

yeah I know tmp is better but I need the bare basics for this

mortal robin
#

using the rect tool

turbid plume
#

yes yes

#

It was either an accident or unity being stupid and resized it for me

low pike
#

unity doesn't change the scale of anything without you telling it to do so

vapid coral
#

Does anyone know why my buttons click area is so offset, I tried remaking the buttons and moving them from the container into just the canvas but it still happens?

mortal robin
vapid coral
mortal robin
vapid coral
mortal robin
#

Not the move tool

#

And why is there a green outline 🤔 did you add a physics collider to it?

vapid coral
#

Oh wow, it was the text box attached to the button... The width was too big

vapid coral
frosty venture
#

Hi, what texture resolutions do people tend to author for UI on desktop? I assume 4K and just let Unity downscale on lower resolutions? I'm about to create a ton of UI, but not really done this in earnest and just want to get it right from the start... but there's like a million articles about supporting multiple resolutions all with their own tips and tricks. So curious if there is a right way?

mortal robin
#

Use a comfortable resolution for your dev machine as your reference resolution and then test the final result across the popular targets

#

I tend to use 1920x1080 as the reference resolution

frosty venture
#

Yeah, that's what I've been doing, but I'd like the textures to look good at 4K too. So was going to export 4K based textures but still use 1080p reference for the canvas. Just not sure how well Unity downscales and if there's things that can be done to keep the textures looking good at common resolutions - 1080p, 1200p, 1440p etc. since only 1080p is perfectly divisible into 2160p

mortal robin
#

It's for layout purposes

frosty venture
#

Yeah, I'm more interested in the actual texture resolutions of the sprites. I assume everyone just designs their art for the best res (4k?). Import them at those sizes and let unity downscale them for users at lower resolutions.

short lava
#

any good recommendations of ui code architecture? I'm mostly finding some really basic "how to create a button" or very specific things or some very very custom things. Haven't done UI in Unity before and tbh in general I find all ui (not just Unity) inherently messy outside some immediate mode debug stuff :D

Trying to come up with some generic solution for interactable ui elements, since it feels like ui code "wants" to fall into a spiderweb chaos where delegates and dependencies are flying all over the place. I'm thinking of something like state machine for interactable ui elements. Like OnClick etc. would invoke a delegate with next button state as return value. Somewhat limiting as we can only invoke one single function at a time, since multiple return values would mess it up.

As a more concrete example: enum InteractableState with values Enabled, Disabled, SuccessEnabled, SuccessDisabled, Failure. Player presses "Buy Food" button and delegate is invoked. There is enough money, enough food and more food to buy, so SuccessEnabled is returned. Button state machine goes to SuccessEnabled state, some effect is displayed and sound played and after that button goes back to Enabled state.

proud sandal
#

typically you'll be well advised to make a state-machine that controls all the primary game states and potentially all the individual UI panels. If you keep them modal (only one panel at a time), you can a void a lot of spaghetti

short lava
#

well I do already have many gameplay systems in place and currently mostly manipulating things with debug booleans on inspector and tbh it feels like UI agnostic API would just mean super complex ui configuration, as in UI system or some middleman between UI and gameplay would have to be aware of all kinds of gameplay system specific information, as opposed to gameplay system just telling ui "I'm out, please disable yourself"

proud sandal
short lava
#

yeah I've also considered that possibility after finding reddit posts and stuff where people complain that tycoon game code they inherited is absolute mess :D

proud sandal
#

maybe the boundaries between systems haven't been drawn in useful places or you haven't layered & sliced your systems and everything is just a pot of ravioli.

#

but regardless, UI is always complicated and feels like a waste of time

short lava
#

This is not a tycoon game per se, but has some similarities as in has resource management and both global and local UI elements will have many different states, which depend of gameplay system values

proud sandal
#

i find that even the most elegant gameplay systems ages into a shrivelled pig when it receives UI, metrics tracking, notifications, logging and localization

short lava
#

... and then you google ui architectures, both game- and non-game related, and everyone is just talking about super simple "here is a button and it interacts with this event system or interface and everything is super agnostic" and I'm like... fuck it I have like five buttons that simple here :D

proud sandal
proud sandal
short lava
#

hmm, now that actually sounds pretty good idea

#

separate the mess into a closet and close the door

proud sandal
#

at least that creates a nice boundary and you can see what goes in/out in one place

short lava
#

@proud sandal thanks, this feels indeed much better, even if it's somewhat anomality in my general code structure, but it's better to contain the anomalities into specific places

mortal idol
short lava
#

To clarify I’ll have total hundreds of interactive ui elements in the end and maybe five of them fall into fire and forget category

hushed mortar
#

Does anyone know how to get these images to stop becoming ovals, ive set them as these. Im trying to make it into just a standard health bar / meter but its keeping turning ovally lol

#

If i have it set to tiled, it goes back to normal

mortal robin
hushed mortar
#

these r my scales, its fine when i set it to tiled but i need it to be filled cause its a health bar system

mortal robin
#

what about its parent objects?

#

And what kind of canvas is it living on?

hushed mortar
#

I believe ive figured it out now

mortal robin