#📲┃ui-ux

1 messages · Page 24 of 1

mild kernel
#

You don't, you choose a resolution (1920x1080 is common), then you design around that. Then you use the Match slider to have it scale based on which side will push inwards if the aspect ratio doesn't match.

rose urchin
#

Is it possible to have GameObjects clickable (with the exact same behaviour as a TMP button) and would that even be the correct way to allow the user to interact with buttons that are shifting around (slowly and then increasingly faster) while allowing visual interaction with other game objects, for example a gameobject which emits light would light up these buttons, and if these buttons emit light, they would be able to light up game objects.

mortal robin
rose urchin
#

Can you try distilling this question

storm wharf
#

When designing UI element in Unity, how do you create the object structure?
I.e. I am making a "card" which will contain icon + header + body + footer

Root object is set to 400x400(default center anchor etc) and all child objects will be set to stretch to parent.
My question is mostly about the root object, but if you have other tips then let me know(like child objects set to stretch, is it a good practice?)
What is the default size you go for?
Is it around the size you want your object to be in the game?

rapid ferry
#

once you got full understanding with the recttransform, ui will be a LOOT easier

rapid ferry
#

Anyway, for a more helpful answer regarding to making card UI:
These blue things are the anchors, anything inside the anchors will adapt to the parent's size. Just play with it and you can make an adaptive card

storm wharf
#

Any recommended guides/tutorials on the topic?

rapid ferry
#

as i said, everything in UI entire depends on what you want to happen

storm wharf
#

I always used pivots to set my anchors, but it doesnt seem like a good idea if I want UI to scale, so setting up anchors manually did the trick for me,
There is 1 issue I am having tho, if I want to resize things or move them around, my anchors break and I have to set them up again.
Is there a way to avoid that?

rapid ferry
#

i didnt have any learning materials when i studied UI, i just played with recttransform for weeks til i master them

storm wharf
rapid ferry
#

then just keep practicing, recttransform is the only hard thing here

#

since you already understand how anchor work, that's half of the lesson already

storm wharf
#

As an example, I wanted to add padding around the content of my card.
That meant I had to add "content" object and put all other objects inside.
That content object had to have anchors set to : 0.05, 0.95 in order to add padding around.
But doing that caused some issues and required me to fix all anchors again.

#

So what is the other half of the lesson?

#

Pivot?

rapid ferry
#

yes

storm wharf
#

alright, I will read up on them to see the difference

rapid ferry
#

pivots generally just tells which part is nailed to the parent

storm wharf
#

oh by pivot u mean typing values in the rect transform

#

not choosing 1 of the options like stretch/top/left

rapid ferry
#

those are anchor presets

storm wharf
#

makes sense

rapid ferry
#

they arre helpful for beginners, but custom is more fun to learn in the long run

storm wharf
#

yeah that was my issue probably, I often use those(they are good to quickly setup an object, but after that you have to manually change anchors anyway

rapid ferry
#

esp, since there's no anchor preset (afaik) that will make card parts adapt to it's parent (holder)

storm wharf
#

yes, it definitely makes more sense to use custom so the UI works for different resolutions.
I assumed at the start that using those presets would be enough, but I was wrong 😄

#

Exactly that was my issue

rapid ferry
#

anyways, goodluck learning, it's worth it. I can literally make UI with minutes now that would have took me 30 before

storm wharf
#

Thanks!

formal mango
#

hey yall i want to intansiate a message when i press enter which works fine but for some reason it is compressed to a corner

#

the message text input works fine it just the instanciated text looks ugly

#

i want it to be a line at the top of the chatholder

burnt mica
#

My text keeps appearing as blocks

#

What should the default shader for TextMeshpro be?

valid osprey
#

i have this scene, no matter what i do this gap will not be filled, it appeared out of nowhere, i disabled everything from the scene to see where it comes from, and it still appears ???

#

my camera is orthographic, the color of the camera is solid

#

it doesn't show up on the camera

light mulch
#

@supple basalt leaderboard button which is one of the buttons messing up.

#

Inner is the background sprite behind the text "Leaderboard" and it has the text inside it

#

Image is the icon next to the button

supple basalt
#

Do you have any code that modifies the transforms of these objects?

light mulch
#

uh not for the buttons
for the scores, sort of. it retrieves the records from database and fills out the existing fields
but it doesnt transform the ui elements.

supple basalt
#

would you mind making a prefab out of the UI and exporting it as a unitypackage? you can turn off "include dependencies" so that it doesn't export a huge pile of assets and scripts

#

i'd like to see how it's set up

light mulch
#

yea one sec

#

see if it works hmmGe
ive exported the entire UI

#

It has a GameOver screen inside
and yea the issue only seems to happen when it enables this menu a second time (first time is fine)

supple basalt
#

I wonder if this is because of the Drop Shadow Filter components

#

I don't see anything happening as I activate and deactivate different game objects in the UI

light mulch
#

they are third party assets so could be hmmGe

#

aha! you're right disabled them for leaderboard and mainmenu and now everything else has the issue LUL

supple basalt
#

I suppose the component is changing the size of the rect transform

#

It might behave better if you add layout groups.

#

e.g. like this

#

so that the UI auto layout can completely control the size and position of everything

#

as for your original question: you'd usually reach for LayoutRebuilder.ForceRebuildLayoutImmediate to immediately recalculate UI sizes

light mulch
#

ill give this a try
on another note, is there a way to force it to "refresh" the ui? the same way resizing the window apparently fixes the issue?

supple basalt
#

but I'm not sure that'll help here, since this isn't a problem with a layout group

light mulch
#

thanks

supple basalt
#

the other approach would be to just deactivate and activate it

#

I wonder if this is something you can fix by changing your anchors and pivot points

#

assuming that the Drop Shadow component is changing the size of the rect transforms

#

also, you appear to have parented a gigantic Background image to the Run Button :p

supple basalt
#

the canvas scaler has an execution order of 0

#

so I wonder if this'll change if you put the UIFX stuff earlier or later

light mulch
#

uh uifx doesnt have a priority field to set i think :o

supple basalt
#

this is in the project settings

#

Project Settings > Script Execution Order

light mulch
#

hmm yea nothing about uifx in here hmmGe

supple basalt
#

you have to add a script asset to the list with the + button

light mulch
#

ooh ok ill do that

#

hmm yea i added all uifx scripts before 0 and that didnt fix stuff either.
I'm gonna work with layout groups a little more and try other solutions you've recommended. If nothing else works, i contact the devs for support i guess since its a 3rd party asset

thank you so much for your time Fen comfy

supple basalt
#

I'd try sticking them after 0, too!

#

but yeah, I'd have to look at the asset to figure out what's going on there

light mulch
supple basalt
#

sounds like they're mucking with their size in Update or something similar

#

If two script assets have the same priority, they run in an order that depends on when the individual instances were created

#

(and i'm not sure it's even that well-defined)

#

I don't like messing with execution order for my own scripts, but it's more of a necessity for third party stuff

crystal quail
#

Hey, I'm having difficulty with arranging objects in a layout - I'd like to get it so that when only one of these are shown in the game, they will start showing on the left and then expand on the right afterwards (in no particular order). I.E is SPD+ is applied first, it will be on the left, then when RNG+ is applied it will be "next to it"

As it is, they all just show/hide in the current locations

crystal quail
# mortal robin Use a HorizontalLayoutGroup

I am/was but they aren't moving position. I was watching some tutorials before I had to do something else but I'm assuming I may need to script it instead?

When setting the UI in Unity it's hard coded so I'm assuming Unity doesn't have that "freedom" and in the script, I'm assuming I need to get a list and then populate the groups I've set in the inspector?

mortal robin
silk storm
#

lmk if this should be posted into a different channel

been trying to work on card game to mess around, but the cards aren't scaling with the panels. Anyone got any tips as to how to get this to work ^^;

I've tried looking up solutions and haven't been able to find much that helped

low pike
# silk storm

Something on the 'Hand Panel' is controlling the size of the card

warm moth
#

Hey! I was wondering what you all use for your UI? I want to be able to loop through my UI items infinitly and I would like to be able to add to the list of items during gameplay.

mortal robin
warm moth
mortal robin
jade loom
#

Hello guys, i have the following hierarchy:

Canvas
- Parent_Mask
- - Child Image

I need to resize the mask and only the mask, but in order for the mask to work the Child Image need to be a child of the Parent Mask, is there a way to scale the mask without scaling the children? Or is there any other free mask solutions to address this problem?

#

Is there any way to mask a non child image or raw image?

mortal robin
#

Resize it via the RectTransform settings

jade loom
#

I can chage it to this, but ill still have the same problem

#

As it will affect the child g.o

#

A hacky fix could be aplying the same thing up and down, but still kinda tricky to do

chrome kettle
#

When using TMP Input Field the text area starts moving horizontally when using large characters, when the left edge should remain fixed and the written text not move
I guess this behaviour would have to be a setting but I can't find anything associated with it
Doing inputField.textComponent.rectTransform.localPosition = Vector3.zero; every frame kind of prevents this behaviour but the text then flickers when the input field fights to move it

#

I'd think it was something to do with pivots but it's just totally ignoring them

indigo egret
lament olive
#

guys is there a way to make images with preserve aspect ratio turned on corners round?

analog urchin
#

Hi guys, is anyone familiar with an issue where on Legacy text and the console, a text displays correctly (A), but on TMP_Text it displays as A whitesquare? (A when copied into discord)

#

To be more specific it's trying to show A'\u25A1'

#

It's as if there's a char at the end that is normally not seen/ignored, but TextMeshPro's trying to display it anyway

#

I'd have nearly assumed that it's the EoL char tbh

azure flame
#

Experiment with another font asset perhaps. To figure out which character exactly is missing.

tawdry ferry
#

I don't think you can do anything about it is the character is not supported

analog urchin
#

Ah, dam, the other font is LegacyRuntime

tawdry ferry
#

There's also a method to check whether your font supports the character

#
if (t.font.HasCharacter('\u25A1'))
analog urchin
#

Tbh ig I never really considered font to be a possible issue here

tawdry ferry
#

It is

#

You cannot write a character using a font, which doesn't support it

analog urchin
#

Though that does mean that other fonts must be interpreting it as nothing, no widths or anything

tawdry ferry
analog urchin
tawdry ferry
#

You can make it so that not supported characters are either not displayed or displayed as another characters

analog urchin
#

Honestly, pretty sure it's meant to be ignored

#

The "normal" is just displayed as A, the other adds the hidden char

tawdry ferry
#

Is it an issue for you?

analog urchin
#

Normal:

#

Not normal:

tawdry ferry
#

Is it supposed to not be written?

analog urchin
#

So yes, I'd assume that the other simply hides those

tawdry ferry
#

I'm asking whether you have an issue to be fixed

#

Do you want to use a specific font without an empty rectangle being written instead of the character, not supported by the font?

analog urchin
#

I'm not sure how it should be done so I can't directly answer on that

#

Am currently searching about hiding missing chars or stuff

warm moth
#

Does any of you use pre-built solutions for your UI? I am having a super hard time getting my UI built the way I want. I also don't have a grid based UI so pretty much 70% of videos on YouTube is not helping , (Fair warning I am super green at UI)

analog urchin
#

Mistake: It's \u0001 missing, replaced by \u25A1, \u0001 means Start of Header, not that it makes any sense in the current context.

Bigger confusion: Most action names besides a few, like RMB, LMB, and the arrow keys, adds \u0001 to the end, SpaceBar is represented by \u0001, and the same goes for the Return key, like seriously tf is this? I'd expect such things to work out of the box but I find myself kneedeep in troubles with it

#

Even if I had a font that supports \u0001, first of all, it's literally StartOfHeader, secondly, it's oddly shared between multiple use cases

#

The Esc key returns \u001B, which is the escape key, so I'll give it that, it's somewhat countable as a bad font issue, even though I'd honestly expect them to just return "Esc" and not a single char

tawdry pond
#

idk where else to post this, but I'm having trouble getting rid of these weird lines with tiled textures on certain resolutions

#

It's really weird and specific

#

heres the single player button idk

#

only happens when it's set to tiled

mortal robin
#

what kind of canvas is it

tawdry pond
#

I haven't touched this in 2 years so I'm not too knowlegable

#

this bug has just been here for years

narrow dust
#

Hi. I'm copy and pasting steam player names to see if my game will display all characters. There are some characters that won't display (shows the empty square symbol). I think Steam uses the Motiva font, but it's not free. What is a good fallback font to use when displaying steam player names? I'm currently using Google's Noto font.

#

I do use various Noto fonts like simplified Chinese, Korean, Japanese, etc. as fall back fonts so I suspect they are symbols not in any of these fonts.

#

I't a multiplayer game and I'm sending the text as bytes, using utf-8 encoding. Is this perhaps stripping out those characters?

solemn pivot
#

Im having problems with text mesh pro's Dropdown component.
I am trying to add, sort, remove from a TMP dropdown, but every time I interact with the dropdown in any way, the selected value gets lost and it resets/defaults to the top most value.
I've tried everything in the documentation but for some reason I just cannot retain the dropdown's value

#

I need to be able to add and remove from it, without changing the selection. (of course, if your selection itself is the thing removed, its fine to then reset selection to the top most value)

full heath
mortal robin
#

With a +1 or -1 if a thing was added or removed before it

full heath
chrome kettle
#

@indigo egret @full heath I just got back to it and with your help got two solutions
I believe what I'm seeing is the default Overflow behavior when Wrapping is disabled
Expanding the yellow area so overflowing can't happen even with wide characters does work, and using Overflow: Truncate simply cuts off the text rather than moving it

hard spoke
#

Hi everyone!
Before i start asking random question do you know a good guide to layouts?
I come from a web dev background and i'm trying to find something like flexbox from css.
So like creating a sidepanel covering full height and a 1/3 width of the screen with the other panel 2/3.
I managed to do this with horizontal layout and layout elements but then when i added a textmeshpro component to the panel with autosize=true it ruined the layout. why is that?

tawdry ferry
hard spoke
#

well, I think i've solved it D:

#

I have to put the textmeshpro inside the row

#

instead of putting it as a component inside the row element itself

#

but im still curious if there's some guidelines on how to use layout out there

#

got any suggestions?

tawdry ferry
#

Do you mean general guidelines on how to use Unity UI?

hard spoke
#

like best practices yeah

tawdry ferry
#

There should be a bunch of videos, but I was just creating UI when needed. So I have learned it simply thru practicing

#

Just make sure you know about the components like Layout Groups, which help you to structure the object correctly, and use anchors to not align the objects manually

tawdry ferry
# hard spoke

Also make sure you simply have an object to structure all your texts. You usually don't need a separate empty object for every text you have.

Upper Panel
  - Text 1  | aligned to the top
  - Text 2  | aligned according to your stretching objective
  - Text 3  | aligned to the bottom
hard spoke
#

thank you

hard spoke
#

ruining the 1/3-2/3 screen layout

tawdry ferry
hard spoke
#

idk i just started trying game dev 😄

tawdry ferry
#

Well, it shouldn't do that

#

Could you, please, show how it's happening?

tawdry ferry
#

I thought you've already applied that Upper Panel I have shown

#

So if you have them directly inside of your canvas, they're going to stay in it

#

You need a parent gameobject, which fits all those texts together

hard spoke
#

Is there a way to position something relative to something else?

tawdry ferry
full heath
velvet ivy
#

hello! can you tell why this happens?

#

The X value is decreasing on it's own, in editor view with and without entering play mode

heavy sentinel
# velvet ivy The X value is decreasing on it's own, in editor view with and without entering ...

There is a chance some component has an attribute that lets it run in edit mode (https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html). Alternatively, some editor scripts can modify it.

If you want to narrow the problem down, I would suggest creating a backup, then:

  • turn off gizmos (to ensure that OnDrawGizmos code is not affecting it)
  • close unnecessary windows (some custom editor windows can affect it)
  • delete other objects in scene (some scripts can affect it)
  • disable other components in this GameObject
    I believe at some point the issue should be gone. Then it will be easier for you to figure out what exactly is causing the problem.
tawdry pond
mortal robin
tawdry pond
celest coral
#

Hi all, new to Unity and looking for some help.

I've currently got a button sprite that has a lot of transparency. The sprite image get's cut off when I use it on a button:

How it looks in the sprite editor:

I've turned off as much Alpha/Transparency related things I can find but still have no success. Any pointers to what it could be?

full heath
rose urchin
#

There's this annoying artifact I'm getting in game-mode (in-editor), doesn't appear to occur on build, but it persists during editor play. Any idea if these can be removed? The scene which holds the canvas and the scene which holds the background and other elements are separate (loaded additively)

Should probably mention I'm on Unity 6.1f

rustic fog
#

Has anyone had the problem where they places UI somewhere on the screen, then you reopen the project and the UI is just gone, with the cordinates being NaN? How do I prevent this for happening next time?

#

I can't even change it back to 0

radiant sorrel
#

how do i make it so that the amount of space from the grid layout elements (dark green boxes) is the same from that of every side?

tawdry ferry
tawdry ferry
mortal robin
radiant sorrel
tawdry ferry
radiant sorrel
tawdry ferry
radiant sorrel
tawdry ferry
#

Make sure the elements have the sizes which fit into that grid

tawdry ferry
#

In your case, both Horizontal and Vertical Fit should be set to Preferred Size. The Padding and Spacing should then be the same

#

Hope, this answers your question

radiant sorrel
#

oh yes, it works!! thank you so much for your help!

tawdry ferry
long grove
#

can someone help with vr UI ? i'm new to unity i just made a ui with health system, the canvas is set on overlay but it doesn't show when i test the game

#

anyone know how to do ?

mortal robin
#

VR only supports world space canvas

long grove
#

ok i used world space and fixed it on the camera but i need to fix it on the left corner and rn when i look around the healthbar go from left to right idk why

#

this is the script i used to make it appear in front of the main camera

#

how can i fix it in the left corner of my screen ?

dire gust
#

Very very stupid question, but does someone know why I cant click on the elements of my canvas?
I can move the elements changing the transform values, but I dont know what option I touched that I cant move them using the mouse in the editor

mortal robin
dire gust
#

Where is that option?

dire gust
#

nope is toggle

#

like, the finger is not crossed

mortal robin
#

It's unclear to me what your issue is

#

what happens when you try to move it

dire gust
#

letme send a quick video

#

Im cliking on the elements, but it just dont work

#

as seen in the video, If I select an object in the hierarchy I can move it freely

#

but I cant select them by cliking

#

Oh its fixed

#

I just need to close the scene window and open it again

#

seems like a bug

hollow sleet
#

I've got a Vertical Layout Group controlling a text mesh text so it dynamically expands doing down based on the amount of lines in it

#

but I wanted the childed image to fill the relevant text box area dynamically

#

I see the vertical layout group isn't actually updating the text transform values which is why im assuming its not working as i expected, any suggestions on setting this up?

mortal robin
#

a single text element isn't going to really benefit much from it

hollow sleet
#

fair, i'm open ears for alternate suggestions on doing what im trying to do with it

mortal robin
#

Use multiple text elements

#

all children of the layout group

hollow sleet
#

like per line?

mortal robin
#

yes

hollow sleet
#

this is for a dynamic console

#

i basically swap between different code based string holders (im pressing tab in the gif)

#

w/ the vertical layout group the gif is showing what i want to happen but i also want the effect of a image that fills the dynamic space the text is taking

#

oh it maybe looks like the layout group has the size i need internally

#

@mortal robin i think its slightly hardcoded for the anchor im using but got what i wanted using this 😄

#
    public void Update()
    {
        float newX = verticalLayoutGroup.preferredWidth;
        float newY = verticalLayoutGroup.preferredHeight;
        image.rectTransform.sizeDelta = new Vector2(newX, newY);
        image.rectTransform.anchoredPosition = new Vector2(newX / 2, -(newY / 2));
    }
safe glade
#

Hello, im trying to set up two groups of buttons. I want two groups of buttons because I want to be able to have one button in each group in the "selected" state is there an easy way to do this using a toggle group or something or do i need to add the functionality in code?

tawdry ferry
tawdry ferry
#

I would create a Vector2 and not access the RectTransform twice

#

Also, does it do what you want? This seems a bit strange for me

safe glade
#

@tawdry ferry okay lets say i have 10 buttons. currently if i click on any of those 10 buttons it goes into the "selected" state and changes its color accordingly, when i then click on any other button the currently selected button goes back to normal and the new button becomes the selected button

instead i want it to function where my 10 buttons are in two groups or sets of 5 buttons. where each group of 5 buttons can have up to 1 button selected the (way the original 10 buttons worked) so at any given time one button from each of the two groups can be in the "selected" state

#

i can for sure do this with code without much issue im just wondering if there is an easier/faster way using a toggle group or something like that

tawdry ferry
safe glade
#

gottchya 👍

tawdry ferry
safe glade
#

ill dm you if i get stuck but i should be able to figure it out. thanks though!

tawdry ferry
#

Good luck!

long grove
#

how can i fix a frame in the top left corner of the screen in a vr game ? i have my frame in the worldspace but i only can put it centered or it moves

low pike
long grove
rapid ferry
#

UI 2-sided card with thickness, is this doable with a Custom Graphic?

#

At least even with shaderwork

rough halo
#

Someone knows why when i try to update a toggle depending on if the screen is fullscreen or not

#

i get a bug in which i cant change it?

austere nest
rough halo
#

My problem is that when i come back from another scene the toggle is always on even if the screen is not fullsize

austere nest
rough halo
#

that triggers the onvaluechanged method in the inspector?

austere nest
#

i think yeah

rough halo
# austere nest i think yeah

so how do i change that value without triggering? Because the toggle always reset as I restart the game or change scenes and come back

austere nest
#

you need to save and load your settings

rough halo
austere nest
#

you can use playerprefs tough i personally wouldnt reccomend it

rough halo
#

Or how do u do it with playerprefss

austere nest
#

you dont need to disable it, once the game starts or you switch scenes it will load your settings by setting the values of your UI elements to the saved values, that will call the functions and apply the actual setting

rough halo
#

like if i swith scenes i dont want to go back and apply again the windowed mode

austere nest
#

i wont, cuz is saved

rough halo
# austere nest i wont, cuz is saved

so right now if i have in the start this:
if (PlayerPrefs.GetInt("Fullscreen") == 0)
{
toggle.isOn = false;
}

    if (PlayerPrefs.GetInt("Fullscreen") == 1)
    {
        toggle.isOn = true;
    }
#

what should I do so the toggle image is in the correct form

austere nest
#

first of all you can make that shorter by doing this

toggle.IsOn = Convert.ToBoolean(PlayerPrefs.GetInt("Fullscreen"));
#

2nd put it in awake since is called before start

#

actually put it in a function that gets called in awake

rough halo
#

done

#

should i do something else?

austere nest
#

well that gets the saved value, you also need to set it

#

in the function you call when toggling, save the value to the playerprefs

rough halo
#

and still im getting the bug

austere nest
#

whats the bug again?

rough halo
#

let me show you a video so its easier

rough halo
#

screen is windowed but the toggle is on again

austere nest
#

wait a min, this is a build

rough halo
#

yea ofc, i cannot change fullscreen in the editor

austere nest
#

you did build again after the changes i told you right?

austere nest
#

ok

#

you dont set that toggle value anywhere else right?

#

just in awake

rough halo
#

correct

austere nest
#

also make sure you dont have any misspelling in the playerprefs key

rough halo
#

this is all i use

#

and the method is being called through here

austere nest
#

you dont call PlayerPrefs.Save()

rough halo
#

and they work perfecly

austere nest
#

try doing it for settings

#

see what happens

rough halo
#

Oh btw, if i dont change res, only the fullscreen, when going back to the menu fullscreen gets enabled automatically

rough halo
#

this is the complete script

austere nest
#

what is this supposed to do?

rough halo
austere nest
#

yeah i got that but why is it there?

rough halo
#

where should it be

austere nest
#

from the looks of it you try to set a default value

#

but you shouldnt do that

rough halo
#

okay nvm i fixed it already

austere nest
#

oh, k

rough halo
#

but i have another problem

austere nest
#

what is it?

rough halo
#

My res sometimes changes randomly when i go back to the menu

#

or when i open the game

austere nest
#

that sounds like something overriding the current resolution, im sorry but i cannot go trough your entire script and fix the issue for you put some breakpoints in your code and see when that happens, to do that in build you have to make a develpoment build and link the visual studio solution to it

#

you can also do it in editor and watch for the dropdown value changing

rough halo
# austere nest you can also do it in editor and watch for the dropdown value changing
 {
     // Comprobar si los valores de la resolución están almacenados en PlayerPrefs
     if (PlayerPrefs.HasKey("ResolutionWidth") && PlayerPrefs.HasKey("ResolutionHeight") && PlayerPrefs.HasKey("RefreshRate"))
     {
         int width = PlayerPrefs.GetInt("ResolutionWidth");
         int height = PlayerPrefs.GetInt("ResolutionHeight");
         int refreshRate = PlayerPrefs.GetInt("RefreshRate");

         // Establecer la resolución guardada
         Screen.SetResolution(width, height, Screen.fullScreenMode);
         Application.targetFrameRate = refreshRate;
     }
 }```
why my fps doesnt cap at my HZ chosen in the dropdown for the resolutions?
austere nest
#

refresh rate and framerate are different things first of all

#

to cap the fps to the HZ you have to enable vsync

silk storm
#

no clue where to put this- idk if it's coding issue or unity
no clue how to describe the issue so I recorded it-

here are the codes related to this if that helps

selecting which cards get hidden

public GameObject cardInDeck2;
public GameObject cardInDeck3;
public GameObject cardInDeck4;

    void Update()
    {
        ThisCard card1 = cardInDeck1.GetComponent<ThisCard>();
        ThisCard card2 = cardInDeck2.GetComponent<ThisCard>();
        ThisCard card3 = cardInDeck3.GetComponent<ThisCard>();
        ThisCard card4 = cardInDeck4.GetComponent<ThisCard>();

        card1.cardBack = true;
        card2.cardBack = true;
        card3.cardBack = true;
        card4.cardBack = true;
    }```
### ThisCard.cs (card back booleans)
```public bool cardBack;
public static bool staticCardBack;

void Update()
    {
        ...
        ...

        staticCardBack = cardBack;
    }```
### covering the cards
```public GameObject cardBack;

void Update()
    {
        if (ThisCard.staticCardBack == true) 
        {
            cardBack.SetActive(true);
        }
        else
        {
            cardBack.SetActive(false);
        }
    }```
mortal robin
#

also - you should use a list or array for your cards, not numbered variables.

silk storm
#

I'm kind of out of practice when it comes to coding-
can you point me in the right direction for how-? ^^;

lament olive
#

Hey everyone,

I'm facing an issue where my UI isn't displaying in full screen on my Android device. In the Unity Editor, when I set the same aspect ratio, everything looks fine. However, on the Android device, the UI is cropped. Additionally, the black screen appears because I set the skybox to a solid color; previously, the skybox was visible. It doesn't seem to be a device-specific problem, as the splash screen displays correctly.

wide sedge
#

Can someone point me in the right direction to fix my blurry text?
It's good when the scale is at 1, but then it get blurry for some scalings:

mortal robin
#

That can mean several things

wide sedge
mortal robin
wide sedge
#

but users can resize the window not?

mortal robin
#

Tehy can resize the window, but that's not the same as the scale slider in the game view

wide sedge
#

ah alright thx 🙂

mortal robin
#

That's like changing the resolution here

frozen narwhal
#

hey guys?

anyone here can help me with an UI problem?

if u use Canvas with RawImages and Buttons...then the images are on his place...
but if i restart Unity, (sometimes its same if i just stop and restart the game) then the UI Elements are not on his place...sometimes they are smaller, or bigger but every time have another position...

how i can fix that??

full heath
#

Maybe if you have set FreeAspect and change the size of the window that shows the scene the UI Components moves. You can have the elements fixed on a specific position but you have to set propperly the anchors. But first of all lets see if you have FreeAspect or any other aspect ratio

toxic mural
#

Hello I'm trying to create a menu scrolling system where there's a base sidescrolling menu with horizontal scroll

And in the child of this horizontal scroll there are few vertical scrolls.

If my finger is on vertical scroll but I'm scrolling horizontally, it should scroll the base horizontal scroll but nothing ends up happening as base scroll is blocked by vertical scrolls.

In essence I want to achieve something like this

Any suggestions on how to go around it?

full heath
toxic mural
#

It worked, thanks a bunch! Really struggled to find the solution online due to limited vocab 🥲

honest saffron
daring sonnet
#

@low sluice so i added world space and nothing happened when i tried to click the text or a gameobject

low sluice
#

Did you put the world space canvas at the correct location instead of your render texture?

daring sonnet
#

i added under the map

the second image is where the camera is

(sorry i never used world space)

#

also i like more using render texture for the effects and stuff

low sluice
#

You don't need the render texture at all for this. Just put the world space canvas at the correct location

daring sonnet
#

but then how can i add the post processing stuff for the effects

low sluice
#

If you insist on using the render texture then I already told you how you'll need to handle that 🤷‍♂️

frozen narwhal
full heath
frozen narwhal
full heath
#

Have you change that? Consider that if you change the aspect the position of your ui items change depending how you put your anchors

low pike
#

It's on Free Aspect by default - you do not want it on this when working with UI

#

As this is a visual issue, SHOW the issue rather than describing it. It will be easier/ quicker for someone to spot the problem

tulip stag
#

Has anyone had any luck generating TMP Sprite Assets at runtime? I need to be able to embed sprites into text, but I won't actually have access to those sprites prior to runtime since they're loaded from user-provided files in streamingassets.

rugged wadi
#

How do I change the material of a TMP object? I have another material without a text outline, but it's not letting me swap out the material

#

in this screenshot, I'm trying to assign the circled material, but dragging it into the inspector doesn't work. Also, there's no option to remove the current material

ebon reef
#

Hello ! I would like to display a vfx above a button(the button will be invisible) but I struggle a lot.
technically this is what I got
But when I make this button spawn (it a simple dialog box) everything spawn except the vfx or lets say it spawn because I found it in the hierarchy but the camera don't render it.

mortal robin
#

Two completely different coordinate systems

#

The easiest way here is to make your UI use screen space - camera

ebon reef
#

Ok thanks for that info 🙂

radiant sorrel
#

why is my scrollbar fully white and why doesnt it scroll properly?

mortal robin
tulip stag
terse tulip
#

im kinda new with ui, i am using a horizontal layout group to center both (text + image(currency)
i want the image to not get stretched when the text increases in length dynamically

how could i achieve this

#

case ex: none

#

case on which the img is stretched

terse tulip
#

found it

#

nvm

#

layout issue

analog urchin
#

I have issues with scrollview cus scrolling doesn't work when your mouse is over ui with RayCastTarget on

#

So I ended up making some sort of wrapper...

#

But then I've got serious trouble with controlling the scrollview via the other script

#

Is there a solve for the first problem without using another script? If not... How was I actually meant to scroll a scrollview by script?

azure flame
#

Unless you are blocking it with something scrolling while hovering over scrollview should work just fine. If you absolutely have to have something overlayed, you can pass raycast with custom event under it.
For animated scrolling on scrollview, I've manipulated scroll progress variable, it's 0-1f I think. So calculating height of the content area object vs, for example height of an item, would allow you to calculate the percentage for the scroll step you want.

analog urchin
#

Where you can't scroll while hovering over inventory slots

azure flame
#

Items should be part of the content container

analog urchin
#

It's just a bunch of inventory slot arranged by a grid layout group within the content tab

azure flame
analog urchin
#

Each inventory slot consists of

  • Slot (Background img)
    • Content (Item img&has event triggers)
    • Text (Item amount display)
azure flame
#

If you are blocking events preventing them from reaching scroll view, then it won't work

analog urchin
#

Nothing has raycast target except Content

azure flame
#

Use event manager debug screen in the inspector and see what's blocking

#

when event manager selected, make sure it's extended on the bottom in the inspector

#

It's active only at runtime

analog urchin
#

I'm not quite sure what the event manager debug screen is... No results show up

#

After a simple double check, it's 100% confirmed that it's the Content that's blocking the scroll

#

However I'm not using the scroll event

azure flame
#

At runtime select event manager to show in the inspector and look at the bottom of it when you move the mouse over UI

#

Easiest way to test is to create default scroll view and examine what elements exposed while scrolling to work properly

analog urchin
#

Welllll... Definitely the event trigger

#

Hmm... Maybe the scrollview also uses OnPointerEnter & OnPointerExit to know if you can interact...?

#

Nope, the mere presence of an event trigger blocks it

azure flame
#

I'm guessing it supposed to take over all the events, so you need to forward them if you want them to work

#

Never used that component. If you want castom event redirection it's simple enough to add Selectable script and capture and redirect only events you want

analog urchin
#

All I need are these two functions to be triggered ngl

#

How would you do it?

#

The Selectable script looks like... Just a base ui component?

azure flame
#

Your component needs to implement Selectable interfaces you want
public class ScreenEventsManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IScrollHandler, IPointerDownHandler, IPointerUpHandler

analog urchin
#

Ahhh I see

#

So Unity probably searches up the hirarchy for components that implement those

azure flame
#

And also if the component is blocking one, you can reference blocked component and redirect event, receiving it like that
public void OnDrag(PointerEventData eventData) => OnDragProxy(eventData);

analog urchin
#

And Event trigger implements them all?

azure flame
#

Never used event trigger. I use events through scripting

analog urchin
#

Yeah I mean, probably why it blocked it while empty is cus while events are optional, the implementations are always there

azure flame
#

it might implement everything, thus blocking everything, I can only speculate

analog urchin
#

That's what I mean lol

#

Hell no

#

I think that it's OnBeginDrag and OnEndDrag

#

Ig I'll just implement them too (While I don't need them)

azure flame
#

You need corner case handling. If you start drag over an item to block drag for the scroll view

analog urchin
#

Uhm... Exception?

#

Pffft okay

#

Pretty sure I just need to implement the few stuff I need to intercept

#

I mean, inventory slots are meant to be dragged after all

#

Even if I don't specifically utilize them

azure flame
#

So the item would need a Selectable drag interface, which will block scroll event for the scroll view

analog urchin
#

No... I need the scrolling

#

I just don't want the dragging

azure flame
#

...for the time you are dragging the item

#

then restore it on release

analog urchin
#

Hmmm... I don't think that it'd be necessary?

#

Cus honestly no one would actually care if they can use the scrollwheel while dragging

azure flame
# analog urchin

That's not scroll view being scrolled, that looks like drag event working for the item you are dragging and for the scroll view

analog urchin
#

Yep

azure flame
#

Anyway, you have all the information you need to handle it now

analog urchin
#

That's why ig that I'd just need to implement PointerDown and PointerUp OnBeginDrag, OnDrag and OnEndDrag

lethal breach
#

I'm trying out Unity 6 preview. I am trying to reference a TMP_Text. I have asmdefs setup, and since there was no Unity.TextMeshPro assembly, I found out that it was merged to ugui 2.0.0. I verified that I have that package installed. But I still can't access TMP_Text. Is it under a different class name or what am I missing here?

lethal breach
#

I temporarily removed the asmdef file and now it can see TMP_Text using TMPro. Is this broken in Unity 6?

gleaming current
#

Hello please help me how i can fix this

#

When i add UI prefab in small resolution it become big and small on big resolution

mortal robin
fiery spoke
#

Im trying to make a button that respawns the player when he dies, it works but the text "Restart" covers the button. How can i make the text like transparent?

mortal robin
dry rover
#

trying to create a chess move history panel, I wrote the script, but Im not sure the best way to show the info during game play, I thinking scrollview? but anybody have suggestions?

mortal robin
#

Vertical layout group in a scroll view sounds pretty typical

crystal violet
#

Having an issue where a small gap appears at the top showing the game when I'm trying to hide it (a pause menu is supposed to obscure it). This only occurs when I set my game view to 16:9 aspect ratio.

low pike
pseudo sierra
#

Hey im having real issues with the layout groups, and cant find a good tutorial about it, do you have any suggestions?
my problem is that the tutorials show only the basic uses but it you try to do something tiny different all hell break loose
SOS

mortal robin
pseudo sierra
mortal robin
#

Just focus on one thing at a time

pseudo sierra
#

the most annoying is when i use vertival/horizontal layout some elements cant be stretch , so i need to resort to silly hacks

#

I try to anchor it and it jump back... sometimes it workd but then give length -XXX and i need to manually remive the - and it works-ish
sometimes it will start on the wrong place. and mess everything up
im sure im just missing something out, it cant possibly be that bad

pseudo sierra
mortal robin
pseudo sierra
#

for example
wtf is going on here? i enchored it to stretch and it got backwords, but all the elements inside are on place...

mortal robin
#

You have width set to -550

pseudo sierra
pseudo sierra
mortal robin
#

The layout doesn't change the size of itself

pseudo sierra
#

i can remove it and it will kinda work, but i refuse to keep doing hacks, im sure im doing something else wrong

pseudo sierra
#

@mortal robin sorry me recording software didn’t work

#

nothing working like it should with the elements inside the layout, you can also see that the texts are starting before the edge of the container...
so many things are fucked there, i assume i did something wrong along the way but i have no idea what

pseudo sierra
low pike
#

does the parent game object have a layout group on it

pseudo sierra
#

problematic child

#

if i give the child anchor stretch it gets -width, and if i remove the - it kinda work but stuck to the left even thought the parent is not

#

any clue what's happening? @low pike

low pike
# pseudo sierra parent

ok, for a start, never change the scale on the rect transform*. You're going to have bad things happen because your scale is not uniform. Keep it at 1,1,1.
Only use width/ height to change the size.

  • unless animating
pseudo sierra
low pike
# crystal violet

what's the hierarchy - do any of the parents of the background have their anchors set to not be flush with the top edge?

low pike
pseudo sierra
#

gtg now, can we get back to it in 3h?

low pike
#

just ask someone in the channel - if I'm here and I see it great

crystal violet
#

do any of the parents of the background have their anchors set to not be flush with the top edge?

How do I check if it is?

low pike
#

look at these

crystal violet
#

The image object's transform looks similar to the one above; pretty default with max stretch.

This is the Crossfade object's rect transform 👇

#

There does seem to be a solution in Canvas

#

If I set the Render Mode to Screen space - Camera rather than the default Screen space - Overlay

#

Messing around with that rn

#

Yep works UnityChanThumbsUp

#

thanks for the help

peak shale
#

Hey, I have a button and a Scrollbar, when I press the button it turns to its "selected" color. But when I press the scrollbar, the button is no longer "selected" and I do want it to stay in its "selected" color. How can I achieve this?

fierce rampart
#

Hey there! Can anyone tell me how to enable the Achor Presets? As you can see their disabled in my Inspector.

mortal robin
fierce rampart
#

Yes it has. Its a blank GameObject.

#

Saw that one in a tutorial where the user was doing the same and for him it worked out using this method.

mortal robin
#

It needs to be a child of a canvas

#

with another RectTransform

fierce rampart
#

Actually it is, the GameObject its the Parent of the Canvas.

mortal robin
#

and Healthbar has a REctTransform too?

fierce rampart
#

Game UI (Canvas) and both Healthbar (Image) and Fill (Image) do have a RectTransform but without Achor Presets.

mortal robin
#

Seems like maybe just a bug in Unity

#

try restarting

fierce rampart
#

As usual 😄

#

Ill try it out, 1 sec

#

Still no presets.

fierce rampart
mortal robin
#

If you make a fresh canvas does it work?

fierce rampart
mortal robin
#

So maybe just recreate it

#

Other suggestions would be:

  • Make sure all your packages are up to date
  • Make sure you don't have any third party plugins interfering
  • Upgrade to a newer version of Unity
fierce rampart
#

Are there some features in the Canvas Inspector that do effect that cause ive needed to change some. But from what ive tested there wasnt anything changing that.

fierce rampart
#

Can anyone tell me what caused that? There should be my HealthBar but instead of that there are just this
red crosses. The problem occurred after restarting the program.

#

I absolutly have no clue how to solve the problem or what might cause that.

low pike
fierce rampart
fierce rampart
#

As soon as ive recreated the UI and started the game twice the same problem occured. So if anyone has a clue what could cause that, let me know.

whole drum
#

A layout group doesn't seem to update itself when its parent is disabled, is there anyway to force update is? I've tried ForceRebuildLayoutImmediate and MarkLayoutForRebuild from LayoutRebuilder and also ForceUpdateCanvases, no luck there. What is happening is that I'm loading what is inside the layout group at runtime, but I need the correct positions of them before they're enabled.

urban spindle
#

complete UI noob, why are they different sizes if they have equal scale? canvas is set to scale with screen size

low pike
#

Never change the scale, keep that at 1,1,1.. use height/ width to change the size

#

What you want here though, is a parent object with a vertical layout group, and these two as children

urban spindle
topaz walrus
#

hi

#

one question, on preview the resolution is ok but when i build all gone

mortal robin
full heath
lilac egret
#

I have a problem - i'm using a combo of sprites and UI elelemts to build the menu and will be using the same for the game too (2d). I'm using UI becouse of anchors and sprites becouse they are easier to use. They dont combine well together tho. The reason why i don't use imges for the decoration is becouse they can't be rotated on a shader level (I'm using shaders for the dynamic moving patterns on the rectangles), as seen in image 2. Idk how to aproach this anymore.

full heath
full heath
eager wharf
#

Hello! I'm pretty new to UI creation, so I've been watching some tutorials and I've seen that some people have a 'ball' or 'circle' source image. At first I assumed this was build into unity, however I do not have what they have. (Multiple tutorials). My first thought was to just import an image of a circle, although I dont know if this would work since I'm trying to make a circle progress bar, and I need to use the fill amount feature. Does anyone know what I can do.
Also I apologize if the answer's very simple 😅

mortal robin
#

But it's really just a white circle image afaik

eager wharf
mortal robin
#

Assuming it's not already installed in your project

eager wharf
#

also my apologies for the late responses. Im packing for a trip

storm stream
#

randomly had a bunch of my RectTransforms get values replaced with NaN

#

any idea why that could happen?

amber gull
#

I'm trying to create an inventory and hotbar with slots...
It is essentially just a background image with square images in a layout group.

I have set the spacing to 6, but for some reason it is impossible to actually force it to be 6. Different spaces have 1 pixel difference for some reason. Same issue with different layout components. Any clue how I could fix this small, but annoying issue?

Easy to see that the spaces are changing when you move it a bit:
https://streamable.com/bck1oz

Watch "Recording 2024-06-17 184546" on Streamable.

▶ Play video
mortal robin
amber gull
mortal robin
amber gull
#

1920x1080

mortal robin
#

Basically I'm wondering if it's some interaction with the pixel perfect canvas and your canvas scaler and the resolution

amber gull
#

I also removed the pixel perfect options from stuff on the picture, but still have it on camera itself

#

fiddled around quite a bit with everything, nothing mattered really

#

same with built game in full screen if that could matter in any way

eager wharf
full heath
# amber gull

Try changing on the Grid Layout Group the Child Alignment to Upper Center or Middle Center

amber gull
#

didn't see any changes :/

full heath
#

I will also suggest to add the component Grid Layout Group to your hotbar panel game object

amber gull
#

the video was cropped, I have enough room on all sides

#

hm, will see how that last suggestion goes

full heath
full heath
amber gull
#

the issue was same when it was way larger as well

full heath
amber gull
#

yeah it is pretty strange, I've been on it for hours in total 😄

#

moving the group up in hierarchy also doesn't seem to do the trick, but thanks for the suggestions

full heath
#

Also you have Pixel Perfect enabled on your Hotbar Canvas, I just see that

amber gull
#

yeah already turned it off some time ago, changes nothing for given issue

#

but i do have it on my main camera

#

then again disabling that only changes my world scene, not that UI

full heath
#

I don't know anything more to suggest, sorry I can't help you more.
I don't know how is your padding, but with chil alignment on center you can put 0 on Left and Right, maybe the padding is high

amber gull
#

I'll see what happens if I disable the padding and just make my slots smaller

#

atm even with padding 1, some slots have none

full heath
#

Also, why do you have another Grid Layout group on your slot elements? Maybe this is conflicting with the layout on the parent

amber gull
#

it is easy way to center an item that is being dropped there

#

for the science, I'll see if removing those helps, after I'm done with the other test

#

really appreciate it

#

I have to play around with the sizes a bit to be sure... but I think removing the padding and only using smaller slots did the trick
thanks again ❤️

#

one can go mad when debugging these things 😄

supple basalt
#

@kind storm you want to adjust the Left and Right bounds of the Handle Slide Area

#

You will also need to adjust the Left and Right values on the Fill Area

#

These values represent how many pixels of space you have on the left and right sides

#

0 should be a good starting point though

#

because that means the fill and slide areas are exactly as wide as their parent

#

and both are children of the slider object

kind storm
#

Ohhh thanksss! I'll take a look at it tomorrow :>

supple basalt
#

figuring out how the Slider works was a big step in understanding UGUI as a whole, haha

primal burrow
#

@supple basalt I made two versions of the background one using game objects and one using the canvas I went with game objects because I couldnt figure out how to put other game objects infront of the ui background I had made

supple basalt
#

(to clarify, both of these are using game objects)

#

it's just a matter of using a sprite renderer vs. a Graphic (which gets drawn by the canvas)

#

So one option would be to just use a "Screen Space - Camera" canvas

#

You'd create a second canvas and switch it to that mode

#

A "Screen Space - Camera" canvas is positioned in the world (at 100 meters from the camera, by default)

#

So it'll wind up behind everything by default. Normally, that's a nuisance, but that sounds useful here.

primal burrow
#

one moment

#

as I try to find what youre talking about

#

I appreciate the help too

#

thank you

supple basalt
#

Make a new Canvas and have a look in its inspector

primal burrow
#

found that

supple basalt
#

So it'll get positioned, but it won't draw in the area you want it to

primal burrow
supple basalt
#

Does your other canvas have a gray background on it?

#

The original canvas is still drawing in "Screen Space - Overlay" mode, so it's being drawn directly on top of everything else

primal burrow
supple basalt
#

show me the inspector for the background image's object

primal burrow
#

I think I just used a simple panel to make them and slapped a image on them

supple basalt
#

first, set all of these values to 0

#

left/top/right/bottom

primal burrow
#

done

supple basalt
#

then go to the parent object (it's called "scene" in your screenshot and set it to stretch in both directions and have left/right/up/bottom values of 0 as well

primal burrow
#

would it be better to just delete that?

supple basalt
#

if you don't need it, then yeah

primal burrow
#

and save the work for rn

#

ok updated both to be at 0

#

ohhhh

supple basalt
#

also, why is there a "foreground" object?

primal burrow
#

the grass was the fore ground

#

both are 'background items' I just had them split for later on stuff so that I could change out the scenes

#

I see both on the camera now

#

So now when I increase the game view the canvas flips the images themselves

supple basalt
#

show me what that looks like

primal burrow
#

can I post clips in here?

supple basalt
#

you can post images and videos

primal burrow
#

ok

#

I'll just do a before and after

supple basalt
#

is "Game Items" also a canvas?

primal burrow
supple basalt
#

there's a RectTransform on "Gamebounds"

#

which is very odd for something that isn't UI

primal burrow
supple basalt
#

okay, but that doesn't answer the question

#

or are you using RectTransformUtility methods to check if something is inside that region?

supple basalt
#

i see

primal burrow
#

game items isnt a canvas

supple basalt
#

inspect your scene canvas object

primal burrow
supple basalt
#

and how about when you've changed the game view size and your images have gotten screwed up?

primal burrow
supple basalt
#

the red "X" indicates that the images now have a negative height or width

primal burrow
supple basalt
#

inspect the "foreground" object again

primal burrow
supple basalt
#

Put the scale back to [1,1,1] and set the left/top/right/bottom values to 0

#

Also set the Z position to 0

#

That could be relevant

primal burrow
#

it very much was

supple basalt
#

especially with the screen space - camera rendering

#

since you can actually get perspective effects there

primal burrow
#

everything is popping up too like how its supposed to

#

thank you so much

supple basalt
#

np (:

#

Children render on top of parents, and later siblings render on top of earlier sibilngs

#

Maybe another object is drawing on top?

supple basalt
#

notably, pauseMenu

#

or anything parented to it

fervent yarrow
#

How do I make sure all the "Answers" are lined up perfectly in a nice grid?

low pike
supple basalt
#

Indeed. The main thing to know when using layout groups is that you need groups all the way down to individual layout elements or graphics

#
  • Rows <-- VerticalLayoutGroup
    • Row <-- HorizontalLayoutGroup
      • Button <-- VerticalLayoutGroup
        • Text <-- Nothing

e.g.

#

even if you only have one child, you still want to have a layout group

#

I need to write some kind of blog post about this. The default settings are a bit bad (you want to turn off Force Expand and turn on Control Child Size)

kind storm
#

also i've made the slider point bigger by changing that... and i don't think is the right way to do that...

supple basalt
#

I'm not familiar with UITK

eager wharf
#

When creating a ui element that uses the material of a shader, the shader is black in game but the correct color in the editor and graph

mortal robin
eager wharf
mortal robin
#

What about just in the game view (not scene view), before you hit play?

eager wharf
#

Same issue

mortal robin
#

ok so your shader or material just isn't appropriate for UI I guess

#

what shader are you using?

eager wharf
#

Strange. I’m using an unlit

mortal robin
#

It needs to be specifically made for UI typically

eager wharf
#

Hm. I mean the shapes appearing and everything, just not the color. I even got desperate enough to make a second after following a tutorial (still same issue)

mortal robin
#

wdym by "shapes"

eager wharf
#

Oh okay. Forgot to explain this. I’m just making some simple shapes using some nodes and then cut out the black space. For instance, I made a circle

#

Although I’m trying something now which might fix it

eager wharf
#

I fixed it. I just had to change the screenspace-overlay to screenspace-camera.

#

Stupid me. Thanks for the help though!!

lethal breach
#

Has anyone figured out how to reference TMPro from within a asmdef script? Currently using com.unity.ugui@2.0.0. I am able to reference TMPro successfully without asmdef, but under asmdef it doesn't exist.

mortal robin
lethal breach
mortal robin
lethal breach
lethal breach
jagged leaf
#

why are the buttons hitboxes are weird

#

or maybe its something different

#

i dont know

mortal robin
# jagged leaf

Take an actual look at their RectTransforms in scene view

mortal robin
jagged leaf
mortal robin
#

E.g. the Text

jagged leaf
mortal robin
#

There ya go

jagged leaf
#

oooh

#

tysm

void lynx
#

does anyone know how to grab the gameobjects and stuff that a dropdown creates

like i wanna grab each value's gameobject (which in the template is called 'item') at runtime to change certain child objects in it.

How do i do that via script, as for example when adding a script to the Content that triggers something in the main script that executes what i said above, it just looks at the template and not the shit it instantiated?

dark night
#

I'm new to Unity UI and struggling mightily trying to get a grid that will dynamically re-size depending on screen size . The grid is made up of individual gameobjects for each cell, each with a RectTransform. I'm trying to constrain the grid inside the gray rectangle (which is also the parent of all the cell objects). But as you can see in the other image, if I go full screen, the cells don't re-size. (I know they're not constrained in the image with the larger cells, but I previously accomplished that, but now it's just a mess from so much trial and error)

I've been working at this for like 2 days and can't figure it out, feeling pretty dumb. The reason I have gameobjects for each cell is because I want each to be clickable and contain coordinate info. My intention is to allow dragging of bocks that "slot" into the grid cells.

Super grateful for any tips!

rapid ferry
dark night
#

I also have a Content Size Fitter, but perhaps not using it correctly

#

Seems like it might not be possible without some extending, unless something has changed since this thread:

jagged monolith
celest lodge
#

how can i make the objects in this group move upwards instead of downwards? the select box is the box for the notificaitongroup

jagged monolith
celest lodge
mortal robin
void lynx
void lynx
#

this looks like it'll do lovely :33

wide night
#

anyone knows how i can make a circkel fill itself up

dark night
misty lagoon
#

One solution I found using UIBehaviour.OnRectTransformDimensionsChange results in this (rather ugly) code, do you have better ideas?

protected override void OnRectTransformDimensionsChange() => OnDimensionsChange?.Invoke();
public Action OnDimensionsChange;
eager plover
#

Hello can someone tell me what the issue is with this Box Collider 2D? It seems to be rotated 90° to the direction of the camera.

#

At the beginning of the gif the object its on has rotation 0,0,0. I then change the Y rotation of the object.

#

I need the collider to span the white box when the objects rotation is 0,0,0.

misty lagoon
#

I dont think 2D colliders are ment to be on UI-elements?

mortal robin
#

2D Colliders are permanently on the x/y plane

eager plover
#

I have a prefab for a on-screen joystick that has a field in the inspector for a 2D collider that enables limiting the area where the user can drag the stick.

mortal robin
#

since colliders live in a completely different coordinate space than UI elements

eager plover
#

I didnt make that component, so I guess Ill have to check back with the person who did and ask how he intended this being used.

mortal robin
#

indeed

#

seems like a poor design choice

#

A RectTransform would be better

eager plover
#

Yeah Ill ask the guy about that. Thanks for clarifying, I am not too well versed in UI and 2D stuff myself.

limpid torrent
#

is there an easy way in Unity to make rounded box borders like this?

static monolith
#

When I apply a textmeshpro outline it makes an ugly outline centered on the bounds of the letters, so the ouline clips inside. I can use the underlay to fix that, but I'd like to use that to also make a shadow effect, and its also not wide enough as an outline. Any ideas? Thanks

celest garden
#

I have a problem, i made list of objects/graphics, but when i enter playmode it shriks to object size, and changes back if i change anything, but when i add CSF component it moves object/graphic, is there any way to fix it?

fresh valve
#

There is a problem with canvas ordering. There are two canvases, both have the same order. For example canvas A is rendered on top of canvas B. The problem is UI events (click) does not work for canvas A and instead, it works for canvas B!

Canvas A contains several buttons. It does not work when CanvasB is active
If I increase Canvas A order, it would be OK

fresh valve
#

Now, I resolved it. The problem is because of render mode. Both have screen space- camera render mode! but why?
If I change them to regular screen space - overlay, it is OK but I want screen space- camera

lilac egret
#

I wanna make my custom UIsprite for a button, but it don't work. What do i have to fix?

fast meadow
#

You don’t need to make it multiple sprites in the texture importer

lilac egret
#

what?

#

btw i followed this tutorial for button sprites
https://www.youtube.com/watch?v=vleull-aONk

In this video, I show how you can create custom buttons for your UI in Unity. We will use the sprite swap option to change sprites when the user clicks on the button.

Please consider supporting my work with the links below.
https://www.buymeacoffee.com/SodaRocket
https://www.paypal.com/donate?business=2XAWU43T4DFVG&no_recurring=0&currency_code=USD

▶ Play video
#

but i need a stretchable one

#

3x3 spritesheet that works

#

like UIsprite

bleak geyser
#

When I add a UI element into my scene, Unity creates a bunch of gameobjects with all many components

#

Is there a good way to know what does which ? And which ones I can safely remove ?

pure hatch
#

Hey everyone, how can I get my pixel font to look crisp?
Unfortunately TMP smooths out the edges

orchid vale
#

Trying to use materials for my UI

It is visible in prefab mode, but in play mode it all goes invisible

broken cliff
#

But give an example

mortal robin
silver crypt
#

umm but

#

the first one is normal

silver crypt
mortal robin
#

Test different resolutions in the editor via the game window resolution drop-down

silver crypt
#

so probably

#

I should change to

#

constant pixel size

#

but I already did that

mortal robin
#

I don't see why you would use constant pixel size

#

But that's scaling

#

I'm talking about anchoring your UI elements

jagged mesa
#

I'm having a problem related to vertex colors being reset on TextMeshPro components in a camera space canvas. I have a type writer effect that sets every letter's vertex color alpha to 0 and then loops through every letter of my text and sets the alpha of each vertex to 255. This works completely fine until ANY change to the camera's FOV is made. As soon as the FOV changes due to my character sprinting, every single character on every single TMP text in this camera space canvas has it's alpha reset to 255. I've tried caching the alpha values that the characters should be and setting them in late update every frame to override the changes made by the camera updating, but I just end up getting this horrible flickering effect. If anyone has any tips, that would be very much appreciated.

silver crypt
#

POV: Me
Made a gameobject for a button
But they dont work on different screen resolution but I am to tired to make it as a ui 💀

#

can I add animations on ui too?

#

wait

silver crypt
severe heart
#

why my text is blurry, what am i doing wrong?

mortal robin
#

can't tell anything from this picture

severe heart
#

but still so dumb that i had to do that to make it clear

#

and now im having a 2nd problem, the text does not show in game

severe heart
mortal robin
#

more context like - where does this lie in the hierarchy, what kind of canvas is it in, where did you position it, etc... are all needed as well

mortal robin
#

so that explains a lot about the blurryness

severe heart
#

well im following a tutorial, thats what the guy did

mortal robin
#

which explains the rest

severe heart
#

but i can see it in the camera

mortal robin
#

you're likely making the typical rookie mistake here of trying to position the UI according to your game camera

#

If you double click your canvas in the hierarchy it will show you the full extents of the canvas/screen

#

position your UI elements accordingly

severe heart
#

so wait a second

#

ur saying that big frame

#

is the screen

mortal robin
#

That's your screen yes

#

do yourself a favor and open the game view window side by side with your scene view

#

and you can see the UI updating there in real time as you position stuff in the canvas

severe heart
#

i am using the text mesh pro thing now, which is way more clear, but how do i cant drag it into a script public thing

mortal robin
severe heart
mortal robin
#

Text is the legacy text

#

TMP_Text is textmeshpro text

severe heart
#

oh yeah i just changed it

#

now it works

split stone
#

how can i fix my u.i when changing resolution? some are fine but others dont stay put

severe heart
#

nvm i still cant drag it

#

am i doing smth wrong?

azure flame
onyx flowerBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

azure flame
# severe heart

You are rescaling text element there, it's probably part of your problems. Never rescale UI or its parents, it messes up with fidelity, it should only be used for temporary animation. Set element size instead.

severe heart
ashen goblet
#

how do I add animation on an imported panel

azure flame
#

Easiest way is with Unity animation. You should contain the element in own canvas probably as well to not redraw entire UI each time it changes.

ashen goblet
#

I added the sprite to a panel anf an animation with the animatuion on it but when I play it dosent work

azure flame
ashen goblet
#

how do I add a custom font

nocturne valley
#

Had a rendering bug with Unity where child ui objects were not rendered in the correct order. Where's the documentation for rendering order by hierarchy?

celest garden
#

I made menu for my (fan) game, and separated buttons to different images, but now their "collisions" are squares and they cross each other, is there any way to fix that?

mortal robin
mortal robin
celest garden
#

rn no.. 12 AM for me.. i remmeber trying both

mortal robin
celest garden
#

mostly likely tomorrow

mortal robin
#

but if you're not available at your PC right now kinda hard to work on this

celest garden
#

yep, gonna try to do smth and text here again (tomorrow)

low pike
#

... what? 😄

tight lance
#

I am trying to use horizontal layout group but it sets every child object transform to 0.
So it looks like it. Content has Horizontal layout group(child force expand enabled both) and content size fitter(prefered size both).

low pike
#

What components are on the children?

tight lance
#

image

low pike
#

If there's nothing with size, then it'll be 0

#

an image shouldn't go to 0 tho

#

Do you want the layout group to control the size of the children ?

low pike
#

you can put a layout element on that object, and set the preferred size

tight lance
#

I create a few prefabs in a certain area and I want it to fit in.
Obviously, in order for the prefabs to fit in this area, the layout group needs to control the dimensions of the child objects. But its just not scaling

limpid torrent
#

@supple basalt you mean this?

supple basalt
#

This is part of a VerticalLayoutGroup. That means it's going to be put below everything else

#

If you want it to fill all of the space of its parent, you need to:

  • add a LayoutElement and set it to ignore layout
  • Set the RectTransform to stretch in both directions
#

then set left/right/top/bottom all to zero

limpid torrent
#

okay, add the LayoutElement to PlayerRow?

supple basalt
#

Right.

#

This will prevent the parent's LayoutGroup from affecting it

limpid torrent
#

what do you mean by "Set the RectTransform to stretch in both directions"? on the PlayerRow? @supple basalt

#

so, again this is the layout..

#

or do you mean on the Vertical LayoutGroup to Child Force Expand?

#

@supple basalt idk, i'm trying different arrangements and keep getting the same problem

supple basalt
# limpid torrent

Your vertical layout group should be set to control child size, and to not force-expand children

#

This will probably break your layout

supple basalt
# limpid torrent

ah: I misunderstood where PlayerRow was. I thought it was a child of the actual row

supple basalt
#

After doing that, show me the scene view with PlayerRow selected.

limpid torrent
#

okay..

#

and this is the LayoutGroup:

#

still the same problem

supple basalt
#

LayoutGroup has a height of zero

limpid torrent
#

oh

supple basalt
#

After fixing that, switch to the Rect tool (second from the bottom in that list) and show me what PlayerRow looks like in the scene view

supple basalt
#

You're making a scroll view, correct?

limpid torrent
#

yes

supple basalt
#

That means the content can grow beyond the size of the Viewport

#

which will then mask out everythign that's out of bounds (if it has a Mask component, at least)

supple basalt
limpid torrent
#

so i think i should set Horizontal Fit to Preferred Size

supple basalt
#

You only really need vertical fit

#

The LayoutGroup object can already just stretch to fill its container

#

(that's how you have it configured)

limpid torrent
#

ok

supple basalt
#

If PlayerRow doesn't need to automatically resize itself (e.g. it contains a fixed amount of content), you can slap a LayoutElement on it

#

This lets you manually configure how big it should be

#

Give it a minimum height that's big enough to fit its children.

limpid torrent
#

i don't actually have the Rect tool on mine, in Unity 2023...

#

that's with the second row selected

#

still having the same issue, experimenting with different setups

mortal robin
supple basalt
mortal robin
#

2nd from the bottom

limpid torrent
#

ok, so here is that view..

supple basalt
#

0 pixels wide!

#

Show me the inspector for PlayerRow again

limpid torrent
supple basalt
#

I need to see its LayoutElement

#

If you haven't added one, do so now

limpid torrent
#

yeah, it had one

#

ok fixing that

supple basalt
#

Give it a flexible width of 1, so that it'll fill the horizontal space

#

That tells its parent that it can accept any leftover width

limpid torrent
#

ok, gave it flexible width of 1

#

but yeah, the button only hits if it's about 20 pixels below the row

supple basalt
# limpid torrent

LayoutGroup's "Right" is set to 188, so it has a 188 pixel margin on its right side

#

that may be getting in the way

supple basalt
#

TxtPlayerName, looks like

limpid torrent
supple basalt
#

Its pos Y is -16.7

#

I guess it's kind of positioned right

#

You should set the text to be centered and then fix the width and height

limpid torrent
#

ok

supple basalt
#

Pos Y will need to go to 0 ,and Pos X will need to be reduced

supple basalt
supple basalt
limpid torrent
#

well i think that is because i had the text object selection in the latter one, the first one had the PlayerRow selected

#

oh, but i changed the Layout Element to Minimum Width just now too...

#

since that actually works for the image in the PlayerRow so it shows up

supple basalt
#

it might just have a width of zero, meaning its children also wind up getting 0 width

limpid torrent
#

ok this right margin looks better:

supple basalt
#

basically, you should have this:

  • Scroll View
    • Viewport <-- Mask, stretch in both directions, 0 margins
      • LayoutGroup <-- VerticalLayoutGroup, stretch horizontally w/ 0 margins, ContentSizeFitter that grows vertically
        • PlayerRow <-- LayoutElement with minimum height of 20 and flexible width of 1
          • Stuff
          • Stuff
          • Stuff <-- this is all manually positioned, so auto layout doesn't matter here at all
limpid torrent
#

i may have found the issue, 1 sec

#

well, no... but here is a more telling demonstration of what's happening...

#

the third button down is actually fine, seems like a pivot thing?

#

idk, i will get lunch

limpid torrent
#

well, i've got it working after understanding things better, thanks Fen

celest garden
vestal drift
#

Hello, I'm having an issue with the scrollview, for some unknown reason, a child image of the scrollview is still showing up when I scroll down.

#

The image is clearly a child of the view and has no special property or component

#

The parent Gameobject "Delete" also is an image and does not have this issue, it's really weird.

#

Here is if I disable the viewport mask, everything shows as expected.

#

Would anybody have any idea what could cause this problem?

#

OK found the issue which was dumb... The maskable bool on the problematic image was disabled... No idea why, I must have messed it up previously...

eager wharf
#

Hello. This s probably a very simple fix, but why does my UI appear to be pixelated in my game view but smooth while editing in my scene view and what can I do to fix this? Could this be an issue with anti aliasing?

eager wharf
mortal robin
eager wharf
mortal robin
eager wharf
lilac egret
#

For some weird reason my image keeps dissapearing in Game

low pike
#

The anchors aren't anchored to anything? Change this to top right.

#

And - Why is the z pos not 0?

#

@lilac egret ☝️

light mulch
#

im trying to figure out Scroll Rect component... How do i change the bounds at which the scrolled elements start disappearing.

i made little arrows to show how its overflowing from its inner component. how do i make it so it doesnt overflow like that HmmNoted

low pike
#

use a mask

light mulch
#

oh i have a mask component but is there no way to modify the dimensions of the mask? hmmGe

#

i have the mask component on the ItemList gameobject that also has the scroll rect component

low pike
#

of course you can change the size of the mask - the mask component uses the size of the recttransform it's on

light mulch
#

oh interesting
guessing the sprite im using is just a bit off thats making this small issue

low pike
#

That gap could be the scrollbars