#📲┃ui-ux

1 messages · Page 26 of 1

pale island
#

ok I added a canvas as a child to my camera for a ui. I have a grid with some filled tiles, but now the filled cells are no longer visible. What is happening?

pure cloak
#

Hello I made a death screen in UI and I have a script that enables it when I hit an obstacle but I don't know how to disable it in the first place (before runtime I mean). Can someone help me?

copper trellis
#

You can just disable it in the inspector before hitting play

#

If you want it still enabled but to disable when you play, you can just disable it in the start function

pure cloak
solar wadi
#

Hello everyone, how can I make the text scroll (previously, increasing the content helped, but now it is impossible to resize it)

solar wadi
azure flame
proven lintel
#

if I have a GridLayoutGroup is there a way I can either

  1. Allow objects to snap to a grid but allow gaps in said grid? The only way I've managed to achieve this is to use filler empty gameobjects
  2. Building off the example above, is there a way I can find the appropriate index of where an object will be in a GridLayout based on position without reversing the math?
#

I'm attempting to make icons you can drag and drop around a grid

azure flame
#

You don't have to figure out their coordinates as they will always know it. Actually moving elements would be very messy. When you start dragging something, set its image to none or other, then spawn its representation under the pointer. When you drop it somewhere, assign its image and data there.

proven lintel
#

well I have the drag and dropping functionality done, but the issue is the grid just lays things in order of the hierarchy. So if I want something on the 4th column there's no way to move it there because the grid handles the layout itself. So far my answer is to fill the grid with a bunch of empty objects and swap sibling index positions when an item is moved. But finding the index of the object already at the position of where the new item is being dropped is the difficult part

azure flame
#

it's the child index

proven lintel
#

I know that's what I said

azure flame
#

so if you know that you can set the index to swap it

proven lintel
#

yes

So far my answer is to fill the grid with a bunch of empty objects and swap sibling index positions when an item is moved
that is currently what I'm doing. But finding the index based on positions so far as proven troublesome

azure flame
#

Why do you need position. You raycast the object and get its index

#

Rather end drag event would have that data

proven lintel
#

because due to spacing and such it may not always find an object under its position

azure flame
#

just don't use any padding and extend with invisible image component as background (to raycast against it at full cell size)

#

then you won't have any holes

#

It's also quite trivial to calculate position as well

#

Have to figure out exact size of elements with padding.

still perch
#

how can i add more sprites to my sprite sheet without having to reassign everything??

copper trellis
fluid sequoia
#

I'm trying to make it so that green box always takes half the screen to the left no matter the screen size and i've been messing with the anchor presets but no luck so far. I have canvas with scale with screen size enabled. Any help would be appreciated

mortal robin
pure cloak
#

disabling the canvas in the start function worked but I could see the white outline of the canvas in the game view and idk how to fix it

mortal robin
pure cloak
mortal robin
#

you want horizontal stretching

#

Any of the 4 presets along the right side

fluid sequoia
hollow quail
#

i want to make a background for the text but if the text is long, the background as u can see wil be small. How can i make like that the background matches the sizes of the phrase

mortal robin
hollow quail
hollow quail
hollow quail
#

Why is this happening, i just put a sprite for the image, a vertical layout group and content size fitter

dense egret
#

is it possible to render a text over a sprite in text mesh pro? I am basically searching for a way to have custom texture for <mark> tag or something like this.

rugged schooner
#

You might have some transparent pixels left around from erasing that the auto slicer is registering as separate sprites. I’d just go to Photoshop and erase all around the sprites to get rid of any loose pixels

#

Oh i’m now realizing i’m really late lmao, hope it helps tho

median birch
#

hey guys, I'm having a bit of trouble using WorldToScreenPoint

#

I want to have the circle off to the right appear in front of where the aircraft is heading, where the dot is

#

I just figured it'd be as simple as something like Vector3 adjustPosition = currentCamera.WorldToScreenPoint(transform.forward * 800f); Vector2 screenPoint = new Vector2(adjustPosition.x, adjustPosition.y); GameManager.Instance.lockCircle.anchoredPosition = screenPoint;

#

800f being the position of that dot

#

but I've tried using localPosition, position, anchoredPosition and the circle is always kind of doing it's own thing

#

does anybody have any ideas?

mortal robin
#

It wants a position vector

median birch
#

ah... I need it to be something like "the transform + forward a certain distance"

#

I guess I'll need to assign it to a new position vector? Like Vector3 forwardPosition = transform.position + transform.forward * 800f?

mortal robin
#

Or that

median birch
#

ok sweet, thanks for the heads up!

#

I've closed the editor but I'll give it a go tomorrow

bronze path
#

How i can mask image using multiple objects? (these are vectors btw)

mortal robin
bronze path
mortal robin
#

if you have 5.5 health, you draw 5 full red bars and one half-filled one

bronze path
bronze path
#

ohh

#

thats a good point, thanks

mortal robin
#

something like:

float healthToDistrubute = player.currentHealth;
for (int i = 0; i < numberOfBars; i++) {
  float fill;
  if (healthToDistribute > 1) {
     fill = 1;
     healthToDistribute -= 1;
  }
  else {
     fill = healthToDistribute;
     healthToDistribute = 0;
  }

  images[i].fillAmount = fill;
}```
dusk lynx
#

Hey,
How would I center the image between the card title and the top edge of the card?

mortal robin
#

Give each child a LayoutElement with the appropriate settings

summer vessel
#

Any ideas on what I can do to fix this scaling issue? The problem is scaling from 1920 x 1080 to 1280 x 1024. You can see that I have one component set in front of a 3d object with the rest behind, I want the game to be able to support multiple resolutions

summer vessel
#

Any ideas on what I can do to fix this

lime tree
#

Got the UI to scale according to screen but... what about the background?

mild kernel
#

You can't, not something that has a defined ratio and isn't tiled. Your best bet would be to make it as big as your largest supported resolution and don't scale it at all.

#

Then it just crops for smaller resolutions

mortal robin
pseudo wyvern
#

Hi, I have a problem: I put the canvas on the screen space camera, and I brought it as close as possible to the player, now I do not display UI elements correctly, that is, they become simply huge despite the fact that they are children of the canvas.

mortal robin
#

what are you trying to do

#

plane distance of 1 is extremely close, there's usually not a good reason for that

pseudo wyvern
#

yes, that's the thing, I need the canvas to be displayed so close, otherwise it will be covered by other objects. The problem is that I need to display this canvas on one specific camera.

mortal robin
#

which doesn't render anything else

pseudo wyvern
#

Unfortunately, this method does not work in my case

mortal robin
#

Why not

#

Can you elaborate more on what your case is?

somber granite
#

Any clues on why bloom intensity (URP volume) would be causing ALL my UI canvases to scale down to about 1/2 their desired size?? Most bizarre problem I've ever had

#

2023.3 b10

mortal robin
#

2023.3 is now Unity 6 so you can upgrade to the latest version of Unity 6 since you're in the tech stream

somber granite
#

I was trying to avoid the install fee which I thought was going to be present in 6 and forward?

#

And I updated to 2023.3 from 2023.2 because of a context menu bug that was making the editor unusable

mortal robin
#

Also the fee isn't going to apply to you unless your game is wildly successful

#

If you want to make a game and avoid the new license and have a stable version of Unity best bet for now is 2022.3 LTS

arctic venture
mortal robin
arctic venture
#

Thanks for the help! I left a response on the discussion to clarify how I fixed the issue.

somber granite
primal isle
#

I'm using TextMeshPro for some background UI elements and I can't figure out how to get rid of the anti-aliasing/blurriness

#

nevermind, fixed
changed the Atlas Render Mode to RASTER

limpid grove
#

Anyone have any idea why after I reset my panels in UNITY all my scenes decided to look like they are outside the normal panel for the scene? I just reset the layout, and magically, all my scenes look like they are outside of the panel now. Its bizarre. Sort of frustrating too

mortal robin
limpid grove
#

It looks like the rect transform got blown up somehow.

#

But it shouldnt of.

#

Yeah my rect transforms blew up what the heck. And I cant even adjust it anymore or control it. All of my scenes.

#

Its like "Some values driven by canvas" when it IS the main canvas. On all of my scenes.

#

All I did was set my layouts for Unity. Poof.

mortal robin
limpid grove
#

Ignore my script console errors, silly reference errors non UI related.

mortal robin
limpid grove
#

But once I changed it, yeah it changes the scale, etc. Weird, Thanks

past coral
#

Hello! I have money text and money icon. How can I make them always center regardless of the amount of money?

vapid edge
limpid grove
#

And Im pretty sure the dollar is in front normally isnt it?

#

Its $12390

vapid edge
# past coral Hello! I have money text and money icon. How can I make them always center regar...

I'd love if someone smarter than me figured out an easier way to do this, but here's my solution:
what you need is to add, to MoneyCell in your case, a "Horizontal Layout Group", set child alignment to middle center and disable child force expand
then you need to go to the text component with the money amount, set text wrapping mode to no wrap
and then add this script to the gameobject with the text

using UnityEngine;
using TMPro;
[ExecuteInEditMode]
public class TextExpanderToSize : MonoBehaviour
{
    [SerializeField]
    private TMP_Text _toExpand;

    [ExecuteInEditMode]
    void Awake()
    {
        _toExpand = GetComponent<TMP_Text>();
    }

    [ExecuteInEditMode]
    void Update()
    {
        if (_toExpand)
        {
            Vector2 temp = _toExpand.rectTransform.sizeDelta;
            temp.x = _toExpand.renderedWidth;
            _toExpand.rectTransform.sizeDelta = temp;
        }
    }
}

then you need to go back and play with the spacing option on the Horizontal Layout Group

vapid edge
#

as in the margin between left border of MoneyCell and left border of text, and right border of money image and right bortder of MoneyCell won't be equal

limpid grove
vapid edge
limpid grove
vapid edge
limpid grove
autumn rapids
#

You might get warnings in the inspector that direct nested items with content size fitter isn't allowed, but don't mind that. It works fine that way.

past coral
#

Thank you! It worked

vapid edge
willow prairie
#

does anyone have any starter tips or suggestions for a pixel-perfect ui? only looking for the ui to be affected, not the actual camera

autumn rapids
lime tree
#

Unable to click on the buttons for some reason

#

I've checking the sort order but still the issue persists

azure flame
lime tree
unkempt pasture
#

hello i want make this Ui smaller but it dont works someone can help me (dont work even if i set scale to 1 on all UI element of my empty)

tender night
#

One day I will learn how to create UI

#

🫡

sly zodiac
#

Hey there, I want to create a tab like menu where the player can click on a button to open a tab. That button needs to STAY selected when the player clicks somewhere else (excpet if its another navigation button of course). Unity has a "selected" color, but the selected state gets removed once you click anywhere else. Any help would be much appreciated!

vapid edge
sly zodiac
#

Thanks for the help!

#

I used button.interactable = false in the end

#

works like a charm

vapid edge
sharp belfry
#

why is my character icon mask so scuffed no matter what?

#

if I disable the Icon and make the mask image color white:

#

its masking the icon in a janky way

unkempt pasture
vapid edge
unkempt pasture
tacit jasper
#

I don't understand why can't I adjust the rect transform of the viewport? what is restraining it?

tacit jasper
# mortal robin The scroll rect, no?

already fixed it.. I worked my way around it. Instead of placing the background on the scroll view itself, I placed the scrollview in a background(Image) component so that I could adjust the scroll view to my desired size

unkempt pasture
#

hello i have made a button with a world canva but i cant use my button . why ? (all target raycast are off)

    public AudioSource Click;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    
    public void Button()
    {
      gameObject.transform.localScale /= 2;
      Click.Play();
      StartCoroutine(ClickTimer());
    }
    IEnumerator ClickTimer()
    {
        yield return new WaitForSeconds(0.5f);
        gameObject.transform.localScale *= 2;
    }
mortal robin
#

and third, I think UI event interaction doesn't work with a locked cursor unless you use a custom input module

echo oracle
#

Anyone have a Korean font asset with text mesh pro for me? I can't create one, there is a bug in my version

eager linden
#

Hi, I'm trying to work with nested layouts. Unfortunately on mobile, so I can't a picture, but there's a layout with groups of buttons, and a large image next to it. They both are not the same size, and I'm trying to align them in a certain way. Is there a way to group the child layout and the separate image in a parent layout and have them aligned/position in a way that I want them to, or are the alignments fixed? I hope that my question makes sense

mortal robin
#

Using layout groups and layout elements

#

Your question is a bit too vague to answer more specifically

eager linden
#

I just got home, so I can provide an example now

#

I have a VerticalLayout and a PortraitImage here, and I want to group them into a new GameObject with a HorizontalLayout component

#

Within that HorizontalLayout GameObject, I wish to have the end result to be something like this

#

The problem is that, when I create a HorizontalLayout, I can't define how a "row" is supposed to align for the children GameObjects, so I was wondering if there is a way to do so

unkempt pasture
#

hello I want to make a UI image where the transparency decreases over a certain time (to make a transition) does anyone know how to do it? atwhatcost

quaint mountain
#

alpha controls the opacity

#

anyway, im here to ask something

#

the bottom of the screen theres no definition, the other side also no defninition, just the top and side for some reason?

#

wait a min what

#

nvm its just inspector shenanigans

candid plover
#

Trying to add TMPro Text to a 360*180 resolution screen. The Text gets all blurry. Tried to set resolution on canvas to a higher resolution, played around with worldview settings and pixel perfect...but the Text still appears blurry. What am I missing?

violet jasper
#

from where can i get this device overlay images if i want ???

tired dove
#

hey guys I have a question about timscale and UI, I have a simple restart button and a simple UI for now, when the Player dies, the UI activates and the player gets to press the restart button

#

but when that is pressed the animation are no longer working including the VFX for shooting is there a reason why ?

honest saffron
# tired dove but when that is pressed the animation are no longer working including the VFX f...

do you want ui to have animations when game is paused? then this is how to do it https://www.youtube.com/watch?v=82MgDp8b_ms unless im misunderstanding the question

In this video we talk about how to fix stuck animation when you set time scale as 0. This is a pretty common practice when creating a pause state for your game but can mess with your Animation and UI.

......................................................................................
✔✔ Follow us:
●Instagram: https://instagram.com/tech_vikin...

▶ Play video
tired dove
#

Not really so, the player dies after health is at 0 and timescale is 0 , and UI pops out to restart

#

I press the restart button , the ui does go away but somehow when the scene restarts some components are disabled

honest saffron
#

maybe you are forgetting to set the timescale back to 1

tired dove
#

its back to 1 after the scene is loaded

honest saffron
#

and ur probably gonna have to post that code

rain grove
#

Is there a best approach for handling issues with input fields and mobile keyboard type speeds? If I spam keys and the 'done' button on iOS keyboards, I can go over the character limit and add characters outside of the content type

polar temple
#

whyyy does my masked text in a scroll view reappear over the compass

pure badger
#

Hi. I have a question: I need to make a certain indentation from the center of the text for the text (TMP_Text). As an example, I added a picture of a book, and it is necessary that the text does not intersect in the center of the book, but only on the pages. Is it possible to do this using only 1 text object or will it take 2?

north void
#

okay so im trying to learn some things and there seems to be an outline around the pause panel thats showing the backgrund

#

is there a way to fill those parts?

unborn cradle
#

TMP issue, possibly related to Canvas.ForceUpdateCanvases ()
I'm trying to call a coroutine that implements a typewriter effect on my text, but it's working differently depending on where I put the code, before or after a Canvas.ForceUpdateCanvases() method.

#

It's kind of hard to explain, but did anyone find issues like this or perhaps has any idea of what's happening?

mortal robin
unborn cradle
#

Ah, the problem was not related to this apparently, I'll investigate further

north void
north void
#

:(

#

when i choose any of the first 3 aspect ratio's it shows a bit of the right and top of the panel

rapid ferry
#

I want to change the outline of this tmpro, but dont want to change the outline of the other tmpro's using this font, how?

north void
north void
#

im not fully getting it

#

i think i understand what the gizmos are, but im not understanding how it applies to the outline

#

im guessing id have to deactivate a gizmo to let it just fill the screen?

mortal robin
#

If you don't want to see it, you can disable the gizmo or all gizmos

north void
#

im going to try to remove ones i think are related

#

maybe canvas

#

i dont think its working ;-;

#

it can probably wait

mortal robin
#

But in this case it would be RectTransform

#

Not Canvas

north void
#

i might be the flaw i dont think im getting this

#

im going to bed

mortal robin
#

Just press the main gizmos button

tawdry ferry
#

Making a menu, is it fine to choose a specific aspect (e.g. 16 : 9), a Canvas with Scale with screen size, and make Camera's color the same as Canvas', or is there any better approach?

craggy fiber
#

Hi there! I'm trying to make a little X button for a small alert box, and I want it to be in the corner, but the text stretches the box with vertical, and I am unsure how to make it move with the box. I have attached an image of how i want it to look. I've also attached my hierchay for this object.

honest saffron
craggy fiber
honest saffron
craggy fiber
#

Ok!

craggy fiber
# honest saffron the root of the alert box

I had a layout element on the object already, but i clicked the "Ignore Layout" toggle on it. The close button still doesn't move with the box. Is there any other steps needed?

honest saffron
craggy fiber
#

If it helps, here are screenshots of every element of the alert box in the inspector

honest saffron
honest saffron
# craggy fiber Sure!

oh ok i see, you gotta select the box with the X inside and click this and make it top right instead of middle center

honest saffron
#

and then you would have to add a layout element component to it and enable "ignore layout". this is where i thought you were earlier when i said this but i got a bit confused, you can remove the component from that other thing you added it to

craggy fiber
#

If it helps, i could probably make a demo project

honest saffron
full elbow
#

Hello. Is it possible to place a 2dlive asset inside a canvas?

craggy fiber
honest saffron
honest saffron
# craggy fiber

then give Close the layout element component and enable "ignore layout"

#

and thats it

craggy fiber
#

It worked!

#

Thank you so much!

narrow seal
#

playing with some UI stuff.... what is this faint grey box? I've not been able to figure this out yet

craggy fiber
honest saffron
#

😄

craggy fiber
#

😄

#

Unity's UI system is something i'll need to learn to wrap my head arround

gusty iris
#

The ad button is clickable in testing, but not the game.

azure flame
#

Use logcat to read application logs at runtime

#

or just output debug messages to UI

#

Or run on Unity emulator for the exact device to inspect it at runtime...

vernal ibex
#

Quick question, so I checked and apparently TMP does support little icons in the text, but can I make it use my custom icon provider?
For example: <sprite name="resources.gold"> 5000
and then it calls a function like this one: Texture2D GetIcon(string name)
or something like that?
I already know TMP has links which can trigger custom code, but can sprites be loaded from custom code like this as well?

scarlet ether
#

hey guys. Not sure how to do it. I created an UI and inside it I created just a image and using an image I have done in photoshop. But when I scale the screen it doesnt scale together. and that happem

#

Any ideas?

#

This is like that game border and no matter the size of the window it should stay on the border

#

maybe because I am using 10:10 aspect ratio? should I use instead resolution, like 1280x1280 ?

#

that fixed here but is that a good practice?

heavy jungle
#

is using animators to animate UI really that bad when it comes to performance on mobile devices?

copper trellis
#

Hang on i can’t use unity right now, lemme find a picture

#

This one (don’t mind the red, i took this image off google)

#

Btw if I you want it to be flexible with aspect ratios, you might wanna go dive into 9 sliced sprites (I think that’s what it’s called)

torpid sun
#

If I want to have a dropdown come down and block mouse clicks on buttons behind it, what's the best way to go about it?

#

I'm sure there's an easy way I'm just blanking on it at the moment

#

The dropdown itself also has buttons on it

#

So I'm getting into a bit of UI fighting

scarlet ether
torpid sun
#

scaling 9-slices will only work if the object is larger than its base resolution

#

so if you make the object 500x500 and wonder why it's scaling weirdly instead of stretching properly it's probably too high res

scarlet ether
torpid sun
#

correct, that is what 9-slicing is for

scarlet ether
#

I hate this UI system unity has.. they should improve it. I wish I could code it and control it via code, would be easier prob

torpid sun
#

here's an example video I found if you're a visual learner
https://youtu.be/37q-0oS65LY

How to use Unity's built-in 9-slice utility via the Sprite Editor, and what this help you accomplish.

9-slicing sprites is used primarily for UIs and 2D games. It allows you to stretch a sprite without deforming the corners, and also allows you to tile the center of a sprite while keeping the outer edges untiled.

For more documentation on 9-...

▶ Play video
scarlet ether
torpid sun
#

there are assets which overhaul unity's UI, and you can learn and commit to them, but it is a whole new set of things to learn and usually a bit of money, so I recommend working with the built-in for now

scarlet ether
#

yeah, I will do that. thank you for your time and help. Will check the video and try it now.

scarlet ether
# torpid sun here's an example video I found if you're a visual learner https://youtu.be/37q-...

So after watching all the video. basically this technique is just for you to strech it and not distorce the image. And that is not my prob. Actually my prob is that I want the borders to stay always at the border of the screem and no matter how much I move the window size it will stay there still.. but that is not happening even using 9 sliced as 9 sliced actually is used to another purpose that is not the one I have now.

torpid sun
#

ah, well, maybe experiment with a combination of 9-slicing and using the stretch to fit feature. I'm not really sure sorry

scarlet ether
#

yeah dont worry, but already tried.. just doesnt work. When I try to increase or decrease the window size instead of being like this

#

it stayts like this

#

so the image square never scales together with the window size.. sadly.

#

Fixed it

#

I set all here to 0

#

and used scale to sdjjust the image

#

now it always stays on the borders

scenic knot
#

I have a windowed mode when building on run time. I want my assets to NOT change size when I change the window size. How do I do it?

scarlet ether
#

its crazy how coding is easier than making things work in the UI.

#

Anyone know how to fix that? I just want that when I scale the screen up or down my empty object with an image inside stay same size.

#

Already tried with all ancors etc nothing works. No idea what to do here. Cant find solution online.

scarlet ether
#

Already tried it .. doesnt work. Well it fixed the prob to the sides but it still streches up and down

#

I need it to be always same size.

#

@gloomy marten

#

I already tried so many things. sadly UI is harder than coding in unity

gloomy marten
#

try the bottom right then

scarlet ether
#

same result as the video

#

also using my UI like that dont know if that could be an issue

gloomy marten
scarlet ether
gloomy marten
#

any video?

scarlet ether
#

is the same result as in the video if I record it will be the same.. 100% the same

gloomy marten
#

theoritically it shouldnt
the white bar should also use the same setup (stretch both vertically and horizontally)

scarlet ether
#

the white bar is doing that its supposed to do my prob is the empty object

#

that is not doing what I want.. I wish that I could code everything.. UI in unity is broken

#

now its stretching only up and down

#

but should be fix and not strech at all

#

just wish I could do something to continue my game. I am block on the process of the game as I am not able to do UI. that is sad

#

the thing is that its been 4 days just to fix that and no progress hahaha

#

no one seems to know why also. Crazy

gloomy marten
#

Sorry I misread your question
So you need the empty area under the white bar to stay the same?
Try adding Aspect ration fitter component to that empty area, and use width control height

scarlet ether
#

already tried that too.. trust me i tried everything

#

hahahaha

#

the video you saw.. the first one

#

I already had this component there

gloomy marten
#

you might need to add content size fitter to it's parent with vertical fit set to min size or prefered size

scarlet ether
#

Check first video and you will see..

#

SS from the first video

#

weird thing is that everything that I already found on internet I tried, cant find more information. Might be something with my project or I dont know. Might need to create another proj.. and see if there it works. than if yes I will need to understand why on mine doesnt

hazy smelt
#

why it look like this?

scarlet ether
#

yes. I think I managed to do it I deleted my old Canvas and created another one.. might have been some weird settings. will check if all is working fine and let u know

#

thank you for ur time and help

gloomy marten
#

no problem
yeah, starting over from scratch sometime easier than figuring out an existing one

lofty moon
#
using System.Collections.Generic;
using UnityEngine;

public class CameraSwitch : MonoBehaviour
{z
    public Camera[] cameras;
    public Canvas canvas;

    private int currentCamera = 0;

    public void onSwitch(){
      currentCamera += (currentCamera == cameras.Length - 1) ? -currentCamera : 1;
      canvas.targetDisplay = currentCamera;
    }
}

I use this code to change the targetDisplay of the canvas, i am trying to make it change the display automatically accordingly

vernal ibex
#

can I override TMP sprite renderer? or add custom rendering with tags that would refer to my code to render a sprite? or can I create and load a custom sprite asset for all TMP texts?

faint burrow
#

how do you put UI on a gameobject like i want to put it on a monitor but i cant seem to find how

mild kernel
#

Make a world space canvas

faint burrow
#

thanks

tiny owl
#

discovered you can only have one grid layout group on an object after I lined up the first one all nice. If you want a 2nd one on an imgae do people typically jut break up the image or like add panels in front of the image to take different layout groups?

limpid torrent
#

i'm doing a webGL build and one of my scenes button's dont seem to work in full screen mode but it works fine in none full screen.. I compared the buttons to buttons in another scene which work well in both full screen and normal and the canvas settings and button settings all seem exactly the same...
any ideas why these buttons would not work in full screen?

rapid ferry
#

How would I wake a TMP text equal an int or float of another script?

livid hill
#

myReference.text = otherReference.valueIWant

rapid ferry
# livid hill With an = sign? What is the issue?

This is my code the errer is waveText = waveText.text = enemySpawner.Wave; says I cant convert int to string is there a way I should be doing this

{
    public TMP_Text waveText;
    public EnemySpawner enemySpawner;
    // Start is called before the first frame update
    void Start()
    {
        EnemySpawner enemyspawner = enemySpawner.GetComponent<EnemySpawner>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    void updateWaveCounter(int wave) 
    {

        waveText = waveText.text = enemySpawner.Wave;
    }
}
livid hill
#

Get rid of the first waveText = part

#

waveText.text = enemySpawner.Wave only of course

rapid ferry
#

I did a little bit of changing around that helped thanks

rigid frigate
#

Hi, why does the simulator side (right) looks so different than the editor (left)?

faint spindle
#

can someone help me with a ui problem

round bramble
#

tell us the issue

faint spindle
#

i have a script for hovering over a button

#

but the button starts jittering if i aim the cursor on the line between the button and the other space

#

like its fighting on if should hover or not

round bramble
#

what's your logic for said script?

faint spindle
round bramble
#

problem soon to be solved

faint spindle
#

what

wild pebble
#

What you guys think about the UI design so far? Is the distance animation on the right too much of a gimmick already or cool detail?

livid hill
wild pebble
scarlet ether
#

Hey guys.. why my UI text looks so pixelated?

#

I am using 10:10 aspect ratio

livid hill
scarlet ether
livid hill
#

Now, it could ALSO be something else too

scarlet ether
#

Got it. Thank you!

rare lance
#

Does anyone know if it is possible to add a dynamic blur overlap effect on UI elements?

I've only seen it done on 3D elements using the Opaque Texture and some shaders. Unfortunately UI elements dont write to the Opaque Texture.

My main refference is the iOS blur effects with notifications and control center

hushed bolt
#

has anyone dealt with text turning into braille in webgL? This si the normal unity TMP font. It works properly for other platforms

soft pelican
#

how can i fix my tilemape overlapping my ui text

silk marsh
#

i have just set font in textmeshpro inputfield to my pixel font and it displays like this

#

what is wrong? this font renders fine everywhere else

#

text smash pro

violet jasper
lofty moon
#

Font

heady crane
silk marsh
#

changed in unity ttf import settings:

  • font size: 8
  • character set: custom
  • render type: hinted raster
    and in textmeshpro importer:
  • font size: 8
  • render type: hinted raster
cosmic herald
#

I have a rendertexture i render my scene too and have put it as an image in the UI. The canvas is set to scale along with the height. Is this the best way to go about displaying the render result?

sand sorrel
#

Any tips on how to make my home menu looks better please? (what should the button's looks like)

wild pebble
# sand sorrel Any tips on how to make my home menu looks better please? (what should the butto...

I'm one of the worse UI designers myself but I'll address couple issues that stand out to me the most: **Contrast: **the buttons at the bottom have way too little contrast between the background and the icon color, at first glance I didn't even notice there was icons to begin with. If you squint your eyes the buttons just look like white blocks with nothing in them. **White Space: **there's too little space for the buttons at the bottom, both around them and between them. To add more space sideways, you can make the buttons less wide since the icons doesn't require that much space on both sides. Talking about the icons, I think the buttons are also too low to fit the icons with appropriate amount of space on top of them and below them. As a last note: I assume the highest of the buttons means "maps" or "play" or something but since it's far from self explanatory, I would add a text to highlight the meaning of the button (since it's 2 buttons wide, there's plenty of space to do that and it would make sense too since it seems to be the "main button")

#

Also this last button not lining up perfectly would make all the perfectionists lose their minds

sand sorrel
grand citrus
#

I hope i ask on right channel..
does anyone know how to fix this stretched images? png

sand sorrel
grand citrus
sand sorrel
#

And on the sprite (so your 2D image in your assets), set the clamp mode to repeat

sand sorrel
#

Also change wrap mode to repeat instead of clamp, that might help too

grand citrus
sand sorrel
wild pebble
jovial yacht
#

I'm trying to recreate a chat ui on unity, Ive already separate each chat box into a universal prefab that I just instantiate when I create a new message, the problem is that I'm currently using Vertical Layout Group but it also influence the X axis, contraining every message to be centered while instead I should move each message to the left or right depending on who sent the message

#

How can I solve this problem?

#

Do better alternatives exists for my case?

sand sorrel
wild pebble
sand sorrel
sand sorrel
#

Like this maybe?

wild pebble
# sand sorrel

I like the 3 upper ones more but the shop and settings buttons need some work to stand out and fit in the layout

wild pebble
# sand sorrel

Better although the two button types are so different that they don't seem to blend together all that well. Maybe it would be better if you could either fit them in the same layout or add enough separation between them (the two button types) so that they don't seem visually related. Sorry, I have to get some sleep now, it's quite late here already

sand sorrel
#

Bye

#

And thanks for the help

wild pebble
#

np

hollow quail
#

guys why isn't my scroll rect working? I put it in a canvas set on world space and put the main camera as the event camera. It all works when i just grab the panel inside the scroll from the scene but i doesn't work when i try to grab or scroll in game.

sand sorrel
sand sorrel
hollow quail
sand sorrel
#

Which one's better?

#

I feel like the one with all the buttons on the bottom is better, but the top part looks wrong

#

I'd need to change the logo

ancient vapor
#

Second picture looks neat

sand sorrel
#

Ok thanks

supple vale
#

is it possible to place 3D Objects on UI, in HDRP With transparent background? I tried some stuff using layers but it does not have transparent bg

#

This is camera + raw image

sand sorrel
supple vale
#

How can I achieve that?

#

Masks and layers is not working here well, please can you guide?

sand sorrel
#

And set the canvas to screen space - camera mode

#

That post should help you

supple vale
#

Thanks for your answer but is it still possible, because I have so many UI Views already setup under one canvas?

#

The whole hierarchy is done and well working from code to open/close.

sand sorrel
supple vale
#

Okay, thank you very much, will check that post!

sand sorrel
#

The only thing is that you won't be able to change alpha value of the meshes (in case you want you UI to fade in/out)

sand sorrel
#

Even tho I'm not sure if it'll work or not

supple vale
sand sorrel
sand sorrel
#

But the mesh inside of canvas thing should still work with hdrp, just no transparency

supple vale
#

I have some idea

#

No idea if it will work

#

I did solid bg as green screen

#

can I somehow write a blit shader which

#

discards greens?

#

to make manual cutout

#

But here I am using RenderTexture and no idea how I can achieve that. Is that a bad idea?

sand sorrel
supple vale
#

Yeah, I have tried that one, was asking Claude for help

#

but it was not working. Thanks mate for trying to help, if that helps, will tell you!

hollow quail
low dock
#

Is adding my own sprites into an image component just broken on unity 6?

muted dock
#

So, I have a Scroll Area, and the contents are set up in a grid form and they are spaced out. The scrolling is very difficult to do because I can only scroll on the content itself, not the gap between the content. How do I fix that?

#

I also do have another question for the scrolling area :D

storm kernel
#

Not sure if this is best place. Can anyone help a friend out and post some resources on in game ui/ux for close up physical device interactions? For example: I want to make the controls of a turn table (record player/vinyl record player) interactive. I need to make the pysical "gestures" of rotating, lifting, pushing, etc. accessible via the mouse... what games can I look at that uses this and showcases it zoomed up with similar objects?

silk marsh
#

the problem was that extra padding was on by default in TMP InputField

#

without it everything is ok

pulsar scaffold
#

Hi

How can I fix this ?

sterile wedge
hollow quail
#

Guys im trying to make that the player can interact with UI world space but it doesn't work. I even put the correct Event camera, and im using the new inputsystem. In the scene there is a EventSystem gameobject. I don't know what's wrong

hollow quail
#

nevermind, solved it by putting the crosshair that is in the middle of the screen Raycast Target Off

#

But now i have another problem, if i try to drag with left button the scroll rect it doesn't work but if i use the mouse scroll it works

tribal turtle
#

Does anyone know a font that allows for ascii characters? I'm trying to make some old soviet terminals but all of the fonts I can find just turn ascii art I get online into boxes.⠀⠀⠀⠀⠀⠀
⠑⢶⣄⠀⠀⠀
⠀⢠⣾⣿⡟⠁⠀⠀⠙⣷⡄⠀
⠀⠻⡿⠛⢿⣦⣀⠀⠀⢹⣷⠀
⠀⠀⠁⠀⠈⠛⢿⣦⣀⣾⡿⠀
⠀⢠⣴⢷⣤⣀⣠⣽⣿⣿⣃⠀
⣴⡟⠉⠀⠉⠛⠛⠛⠉⠈⠻⡷

mortal robin
muted dock
#

I would appreciate any and all help I could get :D

somber hawk
#

I have a 2D map and I'm trying to make a minimap for it. I've made a scrip that locks the camera and makes it not go beyond the edge of the map, and I've put a 2D box collider on it.
My intention is for the minimap to show a visual representation of the player, a text with his coordinates being updated all the time and for it to be clickable, i.e. if I click on the minimap it will walk on the main map
Any ideas on how to do this? Any videos or guides to help me?

broken quarry
#

hi. i'm extremely new to the engine. Why isn't the button changing its opacity when i hover the mouse nor when i click it?

ionic beacon
#

(Soviet terminals wouldn't have had Braille icons in their fonts but don't let realism get in the way of aesthetics)

#

You could also find or generate art that has only ASCII characters

proud sandal
# tribal turtle Oh I see that's unfortunate

this has most characters you would need for rendering western monospace terminal text (cyrillic, latin, greek + special characters for box drawing) https://www.jetbrains.com/lp/mono/

JetBrains: Developer Tools for Professionals and Teams

Try JetBrains Mono in your IDE. Its simple forms and attention to every detail make coding a nice experience for developers’ eyes, no matter which IDE you choose.

#

fonts "lato", "noto" and "inter" (the unity ui font) also have practically all (western) UTF8 characters, you will need a very large font asset texture to fit all their characters... just try generating one with the hex range 0-2FFF.

hollow quail
#

I have a problem where i cannot drag the scroll rect with the left mouse button in a world space but if i try to use the mouse wheel to scroll it works. Anyone know how to fix?

harsh furnace
#

why does my image on my UI scale from a weird spot and not the middle of the canvas?

scarlet ether
#

Hey guys, I have a UI Text, and everytime I scale my game screen the text gets bigger or smaller nor respecting the limites I created. I am using same technique and it works for other things in the ui where they always stay same size no matter the scale of the game windows .. but the text depending it is not having a fixed size.. how to fix that?

untold kernel
#

why when I write anything in this text it just doesnt show up?

#

and when I enlarge it and make the font bigger it shows up blurry and black

#

and when I write something its blurry af

copper fox
#

Anyone know a way to make dropdowns able to select multiple values at once like a checklist?

Either a way to natively or an existing asset

compact zephyr
#

Is there a way for textmeshpro to automatically markee if the text is too long?

#

just so we are on the same page, this is markee 😅

vale surge
#

So my Cursor in the unity edit is visible.

#

But when i build the game

#

The cursor is invisible

#

and you cant see it

#

does anyone know how to help wit this?

compact zephyr
compact zephyr
rapid ferry
#

does anyone know how is this kind of loading bar called? like instead of being a rectangle is kind of warped

compact zephyr
#

This made me remember that unity can't skew 🥲

azure flame
#

@fossil crown Don't cross-post

silk marsh
#

how to make buttons accept not only left click, but also right? i also need to know which mouse button was pressed

mortal robin
silk marsh
#

oh thanks

honest saffron
#

whats wrong with default UI? it has RenderTexture (raw image component). or you just dont like it?

wild pebble
sour geyser
#

Hi, I have a PNG image with a bunch of icons in it, and there has been a bunch of sprites created from this 1 PNG.

Question 1: How do I create sprites from PNGs like this?

Question 2: How do I reference one of the icons in the PNG through USS? For example, through background-image?

mortal robin
untold kernel
#

does anyone know how do I make the UI Strech releativly to the screen?

jagged monolith
jovial yacht
#

I'm building up a chat sisyem on the UNITY UI, I have a prefab called chatblox for each message, they get instanciated at runtime when a new message arrives.
Now I'm handling the vertical layout of the messages via code, they get sorted sorted one above the other (like in messaging apps),
the problem is that I'm trying to get the height of the last message to then place the new one at "previousMessageY + someSpace" but when I try to access the last message height, I always get 0, even if in the inspcet its clearly not 0. what am I doing wrong?

#

Since each block has a content fitter component they have greyed out width and heigh in rect, but I dont think thats the cause I always get 0 in return

#

Here's the code

// Get last message rect reference
RectTransform lastMessageRect = contentParent.GetChild(childCount - 2).GetComponent<RectTransform>();

// Calculate the new Y position (rect.height here always returns 0 even if the reference points to the right obj)
float newY = lastMessageRect.anchoredPosition.y + lastMessageRect.rect.height + messageSpacing;

// Move the new message above the last
newMessageRect.localPosition = new Vector2(newMessageRect.localPosition.x, newY);```
#

I can't use vertical group because my messageblocks can have different heights based on their content

grim tinsel
#

hello i don't know if i'm in the right place so sorry if it's not the right one.
I'm making a 2d game with tree and stone sprites but I'd like to use perlin noise when generating the game map randomly to have natural looking environments. If anyone knows of a simple way to do this, I'd love to hear about it.

jovial yacht
lofty skiff
#

hey! im using the font bahnschrift for my game, and does anybody know why it does this? the text seperates when i type certain characters, even though i didnt add any spaces or special characters, and this only happens in unity

urban crescent
#

I'd like to ask what the best way is for supporting both phone and tablet portrait screens:

  • What are the best Canvas Scaler settings and reference resolution to use?

On phones, we can utilize the full screen space. However on tablets, we don't want to expand fully so that there can be some empty space around the sides (except for backgrounds). I can do this by making the main UI content anchors to stay centered and not expand. Though this gives me the issue that on larger phone screens, the main UI content should still expand to the full available size. How do you solve this issue?

Example of what I want to achieve (phone vs tablet):

scarlet ether
jagged monolith
vernal ibex
#

soo, I'm trying to setup my credits.... ummmmm

vapid edge
#

it can also be found in extra settings on said component

vernal ibex
vapid edge
vapid edge
# urban crescent I'd like to ask what the best way is for supporting both phone and tablet portra...

personally, I like to use Scale With Screen Size, and use a typical 9:16 reference resolution, like 1080x1920, for setting up the UI itself
Most of the work then is just putting in all the anchors properly in the actual UI - and you set screen match mode to Match Width or Height, and them play with the match value to your tastes, I tend to use 0.5 but it might not be what you're looking for here, I think height match (so value 1) might be good for the style you're going for

vapid edge
# vapid edge personally, I like to use Scale With Screen Size, and use a typical 9:16 referen...

9:16 is a good middle ground, that's why I usually choose it for ui work for tablets + phones, but it's really important to remember that it's not a be all end all
there are phones with ridiculous aspect ratios, which bit us in the ass a few times
and tablets come in many sizes as well
it's gonna require some iteration, and your ui should work on anything from 9:19 to 3:4 to actually work everywhere

#

thank the gods for unity game view resolution settings xd

vapid edge
lost mirage
#

hi there i got a bit of a problem with my ui. when i change the resolution of my game all my ui buttons go outside of the screen how can i fix this?

vapid edge
# jovial yacht I can't use vertical group because my messageblocks can have different heights b...

you CAN use verical groups despite the different heights based on their content, why not? It's all in the vertical layout group settings
there IS an issue, that if you change the child size from code, it doesn't update everything nicely
but you can run

_layout.CalculateLayoutInputHorizontal();
_layout.SetLayoutHorizontal();  

to forcefully make it recalculate everything if something's off
of course it would have vertical functions for you, my example is horisontal layout

vapid edge
#

they allow you to anchor your UI elements to certain areas of your screen

#

the easy way allows you to anchor them to corners, top/bottom/left/right and middle

lost mirage
#

arent they anchored by default?

vapid edge
# lost mirage arent they anchored by default?

to change the anchor, click the element you wanna do, click this
center middle button and select your anchor! You can hold alt when selecting your anchor to move the element while doing it as well

vapid edge
#

and if you just moved them to the sides, it calculates the amount of pixels from the middle and that's where it displays the UI

#

so if the position of the side changes, the UI element stays in the same place, which might mean outside of the screen!

vapid edge
lost mirage
#

ah i see

vapid edge
# lost mirage ah i see

you can also change the "pivot" - to tell unity where the anchor is placed on the ui element itself
so if you place things at the bottom of your screen, you could just move it up X pixels manually, or you could set your pivot to be X=0.5 and y=0
or x=0.5 and y=1 at the top
and that's where the anchor will be! play around with it
pivot is like a percentage of the whole recttransform, so you don't have to play with pixel offsets as much

#

and if you change the size of your element, it'll just magically work

vapid edge
lost mirage
#

does this ancher ancher them to all the sides of the canvas? or does it work difrently?

vapid edge
lost mirage
#

if i use that anchor the elements just disapair when i change resolution

vapid edge
lost mirage
#

ah

#

is there an easy way to make the elements also scale with the canvas?

vapid edge
# lost mirage is there an easy way to make the elements also scale with the canvas?

click on the canvas, and in canvas scaler, set UI Scale Mode to Scale With Screen Size - and in reference resolution, put in something like 1920x1080 for horizontal screens (PCs/TVs) and 1080x1920 for mobile phones (depends what your project is for)
and then you can set screen match mode to match width or height
and then you can play with the match value how you like, or leave it at 0 or at 0.5, both should work fine for most cases

vapid edge
lost mirage
#

alright thx alot🙂

vapid edge
#

I think the normal unity UI system is miles better than UI toolkit for most usecases
but you need to keep in mind that it will be VERY different than working in JS/HTML/CSS
and it does support rendertexture

vapid edge
#

or your component settings...

sour locust
#

how to make the game be scalled to every screen witout pain
when i full sceen the web game it becomes good

#

by the way thanks @vapid edge for solving the first problem

vapid edge
sour locust
#

this is the frist one

vapid edge
#

you might have to change everything for all of them

sour locust
#

i think 🤔

#

one sec

#

yeb i set it like that because camera

vapid edge
#

did you do it to make an animation?

vapid edge
sour locust
sour locust
vapid edge
# sour locust yes

World space camera is not very good for those things - it won't scale to screen resolution changes or aspect ratio changes
World space camera is for things like some text on a billboard, or an enemy name hovering over an enemy in 3d space
For menus, you should use the Screen Space - Overlay, and then in canvas scaler set it to Scale With Screen Size, and set reference resolution to (in your case) 1920x1080
You should have one main canvas, and move your menus around, using the anchoredPosition component of their RectTransform, from code
the camera should not move at all to animate the UI changes

sour locust
#

Okay thx

vapid edge
# sour locust Okay thx

if you need more help, ask here ^^ it might be a lot of work to rearrange things, but if you do it this way, it should all work nicely

sour locust
vapid edge
# sour locust Screen space- overlay is setting all canvas to center

You need to make one main canvas, and all your menu screens (like main menu, options, credits, mode select) need to be separate child objects
this will make them stuck to the camera, yes, but it will also make them scale with the camera, which is what you need
you need to then reference them through code, and move them around by changing the anchoredPosition that they have

#

as I said - lot of work, and you need to switch your system from moving the camera to moving the ui screens around

#

I don't think there's another way

jovial yacht
vapid edge
vapid edge
lofty skiff
# vapid edge or your component settings...

i figured it out, in the 'Extra Settings' tab for the TextMeshPro, theres a "font feature" setting, and by default its automatically set to "kern", if you change it to nothing it fixes the problem .. well, it did for me anyway

sand sorrel
#

How can I improve my shop UI please?

hushed latch
#

Hi, this is probably a pretty dumb problem.
The clickable area of my buttons is way bigger than the image i'm using as Bttns.
How can I make the clickable area the same size as my bttns?

#

i've marked the clickable areas of the buttons so yu can see what i mean ^^

urban crescent
# vapid edge personally, I like to use Scale With Screen Size, and use a typical 9:16 referen...

Thanks for the answer. After researching, it does seem most common to use 1080x1920 and 0.5 Match Width or Height. However I have some questions:

  • Personally I like to always use Mobile Simulator view instead of game view. This is since it simulates device Safe Area (iPhone notch, homebar gesture), and Touchscreen input code. Since I want to use Mobile View, I can't use 1080x1920. Is it okay to pick something like iPhone 13 device and use that for reference resolution -- or is there some caveat/issues from not using 1080x1920 reference resolution?

  • Have you built UI for both phone and tablet in portrait mode? Did you ever need to make it so that tablets don't expand main UI content fully (padding around sides), but phones have to expand fully? (see examples #📲┃ui-ux message) If so, how did you implement that?

sand sorrel
#

Any idea on how to improve this?

half spoke
#

How to start in game ux design ?

sand sorrel
#

How can I make my icons have the same shadow effect than my text? The icons are just white images

royal solar
#

i'm having a headache, trying to implement a RuntimeInspector (the one made by Yasirkula).

I plan on having a button on the bottom left corner of the screen that you can use to turn on or off the runtime inspector. This button would be also moved by the runtime hierarchy, the image here explains it rather well i think. where the left panel is the hierarchy and the right panel is the actual inspector.

Trying to make it so the button moves accordingly when the inspector pops up, i'm 90% sure i'm supposed to use the Horizontal LayoutGroup and ContentSizeFitter for this, however. when i disable the hierarchy the entire container itself moves around leaving the button in a seemingly random place. how can i fix this behaviour so the object with content size fitter stays in its place and just causes the button to move to the corner?

Here's a gif where i show what i mean by the button just, moving about when i disable the hierarchy
https://i.gyazo.com/7d574dcb320e305f740d3e093a9755aa.gif

sand sorrel
quartz charm
#

hey guys my world space canvas is not interactable the buttons on it. i have checled and it has a event camera

mortal robin
#

(also do you have an event system in the scene?)

quartz charm
#

and yes

mortal robin
#

you need a workaround for it to work with a locked cursor

#

basically the built in input module doesn't work with a locked cursor

#

so you need to override it

quartz charm
#

where should i attach the script to? anywhere?

quartz charm
#

got it

upbeat moon
#

anyway to render a particle system behind a UI image but on top of a UI background?

#

so sandwhiched between two UI images

#

-FOUND A SOLUTION IN ORDER LAYERS-

faint spindle
#

this is when my slider is at its max value

#

and this is the minimum value

#

the minimum value shouldn't look like that

#

instead the slider should be drained because it's at 0

faint spindle
# faint spindle

when I try to adjust the width to match the emptyness at 0 this is the result I get on the max value

#

how can I make it even on both sides?

#

@here

low pike
#

Ooof, never use that @ ..

merry scarab
#

You guys think this is a nice cursor?

faint spindle
low pike
#

You’ve shown the issue, you haven’t give any info that helps someone work out what the problem is.

faint spindle
#

because there is no info

#

the issue is that simple

low pike
#

There is info.
What’s the setup?
How are you setting the value to 0?
Are you sure the value reaches 0?

#

If you can’t ask a question properly , don’t expect help from 18k people 😉

faint spindle
low pike
#

You’ve made changes to the slider

faint spindle
#

the only change is deleting the handle

#

and that's causing the issue

#

the handle is usually covering that part

low pike
#

IIRC the anchors on the slider are a -5, which takes it beyond the rect

faint spindle
#

and what's the fix?

low pike
#

.. set them to 0

mortal robin
#

It's so much less complicated

faint spindle
#

that may be a great solution

heady smelt
#

Hello, I made a world space UI but i can't interact with it at all. Does anybody know how to fix it, I would greatly appreciate it, thanks!

heady smelt
mortal robin
lone night
#

Howdy, I'm writing this here because it's mostly related to UI and TMPro.
When I use TextMeshProGUI and try to scale it, Unity runs into infinite loading.

I tried:

  • Different fonts, including the default font
  • Deleting and re-importing TMPro
  • Deleting the Library folder
  • Waiting 30 minutes tired

I'll send a video soon of what's going on in more detail

#

Of course, in other projects I don't have this problem and text scaling works normally

tawdry bloom
#

hello i have a probleme with my rain
On some phones, the rain works, but on others, the camera is misplaced.

#

with another phone

wide cave
#

I wanted to ask a question, how can you view all UI’s in a scene?

lone night
# lone night Howdy, I'm writing this here because it's mostly related to UI and TMPro. When I...

Smoll update

What I found:

  • PosX, PosY and Height works correctly
  • Everything works correctly when TMPro is turned off
  • It "crashes" only when written 2008-05-03 06:29:35 -0700 AXON BODY 4 D01A0767G
  • A modified version of the text 2008-05-03 06:29:35 -0700 AXON BODY 4 D01A0767G is working correctly
  • Most likely the 'crash' is caused by the space between 06:29:35 and -0700

I've never seen a weirder bug in my life...

EDIT:
I checked more carefully, if there is a <any char> -<any char> in the text and you change the width then Unity starts infinite loading...
Unity, pls fix

Second EDIT:
It crashes other projects too...

heady smelt
#

its got something to do with the project then, but i didnt tweak anything that important tho

mortal robin
#

Hard to say without seeing it

heady smelt
somber hawk
#

Can someone explain me with this looks differente from scene to game? Even when I maximize my screen it looks different

ionic beacon
#

First you'll have to change the game view scale back to 1x and check if it still looks like that. If that didn't work show what the "this" is (select it and show the inspector)

wheat spruce
#

hellooo,can someone help me? my svg file in the unity are removing the text adn some components? I included the message in the screenshot it said that incomplete mesh data in the sprites

#

it was supposed to be like this

mortal robin
faint spindle
rapid ferry
#

if TMP underline is too high up, what setting do i need to adjust in the font asset to bring it down? there's a bunch of settings and i haven't changed any of them since idk what most do

lunar relic
#

Does anyone know why it looks like that?

#

I already put the same resolution of the render texture and the rewimage and it still looks like that

wild pebble
lunar relic
wild pebble
lunar relic
#

Well, forget it, I already fixed it.

wild pebble
wild pebble
#

@lunar relic Looking at your message history, it seems like this was far from the first time this has happened too. Assuming you are not just trolling here and genuinely want to get helped, you should seriously consider putting more effort into formulating easy to understand questions with enough context

urban crescent
#

Is there a way we can set a max width on a UI container? For example, I want the UI container to keep expanding up until a certain certain screen size (tablets), where it will no longer expand more.

scarlet ether
#

hey guys I have this here

#

my fillplayerHP bar is always in front of the HP bar border.. how to fix that?

#

cant find a layer to control

#

the red part is in front of the white part

#

the only way would be removing red part as child and just put it above the white bar in the hierarchy ?

torn marlin
#

One thing that strikes me as strange is, are there any alternatives to Gridlayout groups, when i'm wanting slower transitions than "instant" for moving objects to their intended positions?

#

right now, I'm working on a janky system of using Gridlayout groups to hold "nodes" that other UI elements slide towards, but that feels backwards.

wheat spruce
sharp furnace
#

Hey so if I have a bunch of foldouts in editorgui in a custom inspector
How do i keep those foldouts that I opened open when switching between gameobjects with Instances of the custom inspector

brazen girder
#

Okay so i am literally going crazy

#

So i have a Canvas, and below that i have a object which is "options_menu"

#

and below that i have "close", a ui button

#

okay so no matter what i do, the "close" object cannot go above "options_menu"

#

i've tried so hard but no

#

and idk how to solve it

#

overly specific for google and chatgpt couldnt understand it

#

i have only 1 canvas

vapid edge
# brazen girder

You're doing UI wrong:
You're not supposed to use sprite renderers and transforms. That's for the gameplay. Never for UI.

You need to use RectTransform and Image components instead. Try right clicking in the hierarchy, and selecting the ui dropdown. I'd recommend watching a unity UI tutorial, as that can get a bit complicated. To properly build a UI, you need to have all childobjects of canvas to have a recttransform

And leave the z position alone! You don't touch it when doing screenspace UI.

brazen girder
#

thank you ill try

brazen girder
brazen girder
#

Figured it out!

scarlet ether
#

Hi guys.. I have an UI Text. Even if I play around with anchors or use Best fit. as you cna see in the video. when I move increase or descrease the game window everything stay same size but not the text..

scarlet ether
#

anyone?

stoic hull
#

hi
how to make a loading animation? i have frames of my animation, i just made an animation clip and animation controller but i don't know how to put it on my canvas

spring raft
#

the screen space camera should add perspective to UI elements on the canvas no?

urban crescent
#

How can I have a world space canvas (enemy healthbar for example), but have it appear flat and consistent size despite distance from camera?

I tried using a normal UI canvas and WorldToScreenPoint, it gives the desired effect, but for some reason it's either jittery, lagging behind, or lagging in front when enemy is moving (tried all the different Update loops). I'm using Cinemachine camera if that effects anything.

edit: fixed by using CinemachineCore.CameraUpdatedEvent.AddListener(OnCameraUpdated) instead of Update loop.

rapid ferry
#

Hi sorry I asked about this the other day but will admit I was still lost. If someone can give me a indepth explanation on how to make these and what I need to do I am willing to draw art in return

#

I made a empty parent and empty child then a Text-TextMeshPro

#

and I truly dont know if thats the correct thing I am meant to do?

#

I tried to drag the InGameText to the game manager part on the inspector and it just wont let me it comes up with the ❌ sign not allowing me

#

the tutorial I am following for this did not show me how to make the canvas with all the attached things they already had them so I am just confused on how to do it myself especially with it not working for me

urban crescent
rapid ferry
#

ahh I see yes this is what mine is right now

#

so I should change Text to TMP_Text for all of the instances of Text ?

rapid ferry
#

Oh but it is giving me this error now?

urban crescent
rapid ferry
#

thank you I will do so !

#

should this also be updated? cause my new error I am assuming is referencing this

#

i forgot to mention thats line 66 and it says 66 in the error

urban crescent
tender mountain
#

how do i change the opacity of a ui element when the mouse is hovered over it

#

like p:hover in css for example

low pike
#

OnPointerEnter / OnPointerExit

tender mountain
low pike
#

Script

tender mountain
#

alr thx

#

how do i make the transition smooth

#

so its not just instantly more translucent

low pike
#

Same as anything else, lerp / tween it

#

I use DOTween, because is easier, but it's an extra (free) plugin

tender mountain
#

idk what any of those are 😭

low pike
#

googleable keywords

tender mountain
#

chatgpt carrying

hoary kindle
#

does using more canvas eats performance

low pike
urban crescent
#

Questions about designing UI:

  • Is it possible to use grid snapping when moving UI elements on the canvas?
  • Is there a way to get proportional snapping, like ensuring 2 different buttons are equally spaced out, etc.
  • Is there a way to enable snapping guide to center
    Any other UI designing tips are welcome. If Unity doesn't support much, is there any good packages that help extend UI designing functionality?
mortal robin
urban crescent
# mortal robin Have you looked into UI Toolkit?

I have, but seems like it's still lacking features that normal UGUI has. For example, playing particles in UI, advanced shader effects. Especially since I'm using 2022 LTS as recommended for stability, there's not even built in placeholder text for input fields until version 2023. The resources and tutorials available for UI Toolkit is also lacking in comparison to UGUI, and most GUI asset kits only provide UGUI prefabs and not UI Toolkit versions. It might be a choice in a year or so, but I don't think right now for my project.

urban crescent
#

At the very least, is there no way to have grid snapping enabled for canvas UI objects? I know it's possible for world objects.

wide sorrel
#

@urban crescent

#

You are a Unity programmer

lone blade
#

hello while trying add post-processing on the ui via a separate camera on the Screen Space - Camera it does not seem to. It does work on the main player cam but I want different post-processing effects on the ui then on the main cam. does anyone know any better way or how to fix this?

hollow echo
#

Hi,
I want to do a gradient black from the edge to the middle of the screen when my life is under 20 hp.
Is there a tool to do this or I need to do this with an image but I don't think the result will be very beautiful ?

low pike
stoic hull
#

hi
why scrolling doesn't work sometimes? (when anything isn't moving that means i can't scroll)

low pike
stoic hull
#

it fits all buttons

low pike
#

You're gonna have to show the setup, I'm not going to keep making random guesses.

#

Also, from the vid, it looks like it only scrolls when you use the mouse wheel ?

stoic hull
devout hearth
#

hey guys, I'm kind of confused as to how the TMpro's preferred values work. Can someone explain to me? Does it prioritize keeping original width or height?

#

I'm trying to get the width for the text, while keeping the height unchanged, but it tries to get more height instead

honest saffron
# stoic hull

where does scroll work and where it doesnt? or is it completely random?

outer dune
#

Does anyone know of a good crash course for building UI that includes a Tab system(& ideally works for console environments)? paid or free doesn't matter. SasquatchB studios tutorials are GREAT but I need something more in-depth.

stoic hull
hollow valve
#

hi guys, I am kinda confused because the text objects in my game are getting sized down when in play mode? (The one with the grey background is in editor mode, and thats how big I want the text, but the white one is the actual game screen)

atomic fox
#

I'm facing a bit of a strange problem myself. In my startup scene, there are two canvasses. They both need to have Screen Space - Camera as their Render Mode. One of them is DDOL.
Now when I press play, the DDOL Canvas loses the reference to the camera, and even when paused doesn't see the camera available in the scene. The other, non-DDOL Canvas still has a reference to the camera available. When I try to set the camera through code, it doesn't do anything, but I don't get an exception either.

Anybody knows whats wrong?

hollow valve
atomic fox
hollow valve
#

tysm!

honest saffron
stoic hull
honest saffron
honest saffron
# stoic hull what should i do?

try adding a child to Scroll Area (and make it above Levels in the hierarchy) and set its color to transparent. and then make it stretch to fit the entire scroll area by clicking on this and selecting the right option (do you know how to do this?)

#

this happened cause you didnt use Create > Scroll View to create a scroll view i assume? you just created an empty gameobject and added the scroll view component to it yourself?

stoic hull
honest saffron
stoic hull
honest saffron
honest saffron
#

you can put all your levels into here and everything should work then

stoic hull
#

but how to delete horizontal scroll bar?

honest saffron
stoic hull
#

@honest saffron thank you

#

@honest saffron last question: how to disable scrolling with cursor (as on sensor screen but with mouse)? and should i?

honest saffron
#

oh you should also specify in that google search that it's unity

pliant anchor
#

I have a question
lets suppose i have an image that acts as a viewport
and i have some other images inside it

#

its more like a scroll rect
like where the content size fitter fits itself for the image it is in
i want a content size fitter that fits itself based on the images inside it
anything like that possible?

azure flame
#

Yes, content size fitter is made to resize content rects

pliant anchor
azure flame
#

When adding items inside fitter controlled object through script it may require additonal forced redraw calls

pliant anchor
#

you see content size fitter

#

when i add it to something

#

lets suppose a UI.Text

#

now whatever i will write in that text

#

according to the size of the text

#

the rect transform's width and height will change

#

but lets suppose i add a child gameobject

#

inside a gameobject controlled by content size fitter

#

then it doesnt work

#

how to make it work?

azure flame
pliant anchor
#

or examples?

#

its my first time

#

also thanks for the guide

azure flame
humble turtle
#

I feel like this is super easy but, how do I get a canvas/text to display over a object instead of the screen

jade halo
#

I have an UI image, in which I want to display a sprite. I want to display it with the pivot point of the sprite in the center of the image, but it seems like it wants the center of the sprite in the center of the image. Any ideas?

mortal robin
jade halo
#

I probably just don't understand what I'm doing 😄

mortal robin
jade halo
#

When I look at the sprite in the inspector, it's still the full size of the image

#

Is it possible to "cut away" the canvas outside of the defined border of the sprite?

#

Or am I supposed to do this outside of Unity maybe?

#

Hmm I sorted it by cutting away the edges of the image outside of unity. But if anyone has the time to explain why the borders "doesn't work" or how it works, I'd appreciate it, or where I can read up on it

scarlet ether
mortal robin
jade halo
tight jackal
#

When I disable the canvas' graphic raycaster, the OnPointerDown event on my Image stops triggering.
But when I reenable it and set the Blocking Mask to Nothing, the OnPointerDown gets triggered when it shouldn't! Does anyone know why this is happening?

stoic hull
#

hi guys, how to add frame by frame animation to ui object? (Image (not Sprite))

tight jackal
#

Select the UI object, open the Animation tab and press "Create"?

stoic hull
tight jackal
#

It is working on mine

stoic hull
# tight jackal It is working on mine

Screen space - Overlay canvas doesn't show Sprites, only images, i found out that i have to use script that change source image to make this animation but it make Unity lag

#

and animator just doesn't work

#

or i am doing something wrong

tight jackal
#

Well, the Animator definitely allows changing sprites in UI Images...

tight jackal
stoic hull
#

and i don't know why it didn't when i tried before...

tight jackal
#

No matter what value I set for the Graphic Raycaster's Blocking Mask, nothing changes!

I have two overlapping images, each with its own layer.
If I set the Blocking Mask to:
(1) one of the layers, the front one detects the click event, instead of the one with the same layer as the blocking mask.
(2) nothing, the image in front gets clicked, instead of both images ignoring the click event.

What am I missing?

stoic hull
#

i have several images on one canvas, how to set order for each image to fix hiding of image that shouldn't be hidden?

tight jackal
upbeat moon
snow junco
#

I've been trying to get my ui indicators to track world space objects using WorldToScreenPoint and finally realized it works perfectly if I set my game window to fixed 800x600 matching my CanvasScaler settings. but if I resize the window the tracking falls apart. I feel like I need the canvas scaler to keep my font ratios the same across resolutions. Is there a way to make WorldToScreenPoint work with a canvas scaler?

tawdry ferry
#

Having a Button, how do I make its child, TMP Text, reveal the objects behind the Button?

#

Having a blue background and a black button, the text's color should be blue

stoic hull
#

guys why text on buttons has different color than it should be?
(it has to be almost black (#323232) but it's grey (#7a7a7a))

tawdry ferry
stoic hull
#

yes

tawdry ferry
#

Does it affect their opacity?

#

The default one does, if you haven't changed it

tawdry ferry
#

The default source image affects the opacity

stoic hull
#

but on another scene same button looks as it has to

tawdry ferry
#

Other objects may have the opacity reduced

stoic hull
tawdry ferry
#

I would check the sprites

stoic hull
#

bc i don't know

tawdry ferry
#

Each

#

Also, supposedly, EndLevel is a canvas?

stoic hull
stoic hull
tawdry ferry
stoic hull
#

and i just removed texture of the button

tawdry ferry
#

I'm not sure what is the opacity of your button

tawdry ferry
#

Could you put the text outside of the button and show it again?

stoic hull
#

so button covers it

tawdry ferry
#

Remove the button

stoic hull
#

i moved button

#

it has same color

#

grey

tawdry ferry
#

The same color as before?

stoic hull
#

yes

tawdry ferry
#

So, not the expected one?

stoic hull
tawdry ferry
#

Maybe, you could send the full scene to me?

#

Just remove everything not related

stoic hull
#

in dm i guess?

tawdry ferry
bright plaza
#

Anyoneone why this happens?

#

This is my game in game view

#

But in exported version looks like this

ionic beacon
#

Set the game view scale to 1x

snow junco
#

I have an asset with multiple "frames" I want to turn into 9slice sprites. Is there a way to carve them out of a single image/asset, cause I can't find it. I can make it a multiple sprite, but then I don't think I can run the sprite editor on an individual sprite?

snow junco
tawdry ferry
#

Hello. I found this answer on Unity forum about inverting the UI Mask by changing the image's material, but I'm not sure how I can achieve this on a text, since changing the text's shader to UI/Default Font or TextMeshPro/Distance Field gives the result below, when characters are perceived as rectangles

scarlet ether
#

I want the text to keep the same size and as u see its not or I dont know

stoic hull
#

does anyone know how to fix loading animation lagging?

urban crescent
#

What's the best way to be able to use Canvas Group alpha fading without having topmost elements blending alpha with the background elements? Essentially fade everything out as if it were one whole image, rather than made of individual UI elements.

From researching the 2 methods:

  • Manually masking elements to hide the portion of the background they cover (but it's too time-consuming).
  • RenderTexture the whole UI popup into an image, and fade out that image.

I wonder if anyone has picked a solution for this problem, and their experience. I don't know if having to RenderTexture is good for performance. I hoped there would be an easy way since this seems like a common problem.

torn marlin
#

are there ANY pieces of code that can be used to force Text Mesh Pro text to always be pixel perfect? I have the font set up correctly, and set to the correct font size, and everything else, but it STILL looks corrupt and wrong, due to things like Layout Groups and parent scaling and all that stuff altering the position of text.

mortal robin
torn marlin
low pike
torn marlin
#

Yes, that is all done as expected.

vapid edge
#

Is there a way to deal with this, in TMPro?
I'm trying to add an outline to my text, but above .55 thickness it creates those weird dark backdrops around the text

low pike
# vapid edge

IIRC that's caused by not enough .. spacing? in the SDF

torn marlin
low pike
#

It might help if you show the issue too..

vapid edge
torn marlin
#

When the width of the object changes, the Horizontal Layout Group overrides any sort of pixel-perfect displaying, and the text distorts accordingly.

#

The text is hinted raster, point filtered font, set to the correct font size and sized correctly for the render resolution

#

The only thing I can think of that it could be, other than the horizontal layout group, is that there's somehow non-pixel-perfect spacing between letters in the font asset itself, rather than the font, and I have no clue how I'd fix that,considering I've poured over the font asset and font and font material settings.

#

I've tried just making my own Layout Group from inheriting from Horizontal Layout Group or HorizontalOrVerticalLayoutGroup, but Unity throws a fit and bricks if I try to make anything inherit from those classes.

fluid helm
#

Hello, How I can make curved UI like in content warning?

wild pebble
# fluid helm Hello, How I can make curved UI like in content warning?

You can just place the UI elements in that curved pattern and rotate accordingly but making the elements actually curve is something unity doesn't support. If you are not afraid of handling the inputs (button clicks etc.) yourself, you could consider either rendering the UI into render texture and rendering it then as a texture on top of curved surface or using custom shader for the UI elements to make them appear as curved (could be implemented as projection of vertices to that cylindrical shape + potentially a pixel shader to distort the UVs correctly)

vernal niche
#

idk why its not showing in game

mortal robin
#

You should be using a UI Image component

midnight helm
#

Hello, I need help with making sure my design does not break or majorly get affected when I am swicthing from smartphones to tables for a mobile Unity game. How will I fix this problem and make sure assets do not break when I am making this switch?

#

I have set up my canvas to scale with screen size and I have set anchors in appropriate positions, however when I am using the tablet simulator, all the assets are breaking and being stretched alot

low pike
#

Take great care with the anchoring, layoutgroups, etc

#

The more complicated a UI, or the more UI there is.. the more likely you are to be better off just having two UI's and enable the correct one for the screen size

mortal robin
low pike
hollow echo
#

Hello
I create a 2D game and I want to create an inventory like in zela Ocarina of time. Is it possible to do this in 2D or I need to "turn" the canvas in 3D or something else ?

boreal ferry
#

Hello, Im not sure if this is the correct channel so let's hope so. I was wondering, how could i prevent the background video from going completely black when it loops? It's a Video Renderer with loop enabled, the video itself doesn't go black when it ends but in Unity it for some reason goes black for a split second before it loops. Is there any way to prevent that?
"Also sorry for low quality on the video"

celest pond
#

Is there any way to use UI in 3d?

#

Like I have a tablet in my world, which has a canvas and a UI button on it. I have set it to world space

#

But I do not want the player to use his mouse to interact with it, (as it is a first person game) but rather use a raycast to detect the button and "simulate" a cursor

#

I thought about locking the cursor to the middle of the screen, but that would disable interactions with UI elements

celest pond
mortal robin
#

depending on your input system it's either StandaloneInputModule or InputSystemUIInputModule

#

The link contains some code that you can use to create your own overridden version of the input module

#

you will then replace the existing input module with this special input module

#

then you can interact with world space UI while the cursor is locked and invisible

celest pond
#

is there any possibility that that change might break something I have already done?

#

In that case I would prefer to just leave out that gimmic

mortal robin
#

break something such as what

celest pond
#

idk, anything? Movement, Interaction Systems, UI that I have already done. I have just gotten pretty paranoid as I have been working on this game for quite a few years sad_cat

mortal robin
#

Anyway if you've been working for years surely you're using version control right?

celest pond
mortal robin
#

is that a yes or a no lol

celest pond
#

unfortunatly a no

#

never understood how it worked so I always just skipped it

mortal robin
#

Sounds like an emergency that you should fix right now

#

If you're scared about losing your work, that's the #1 way to avoid losing your work

#

Invest a few hours to learn it

#

it's well worth it

#

A useful skill for the rest of your life

#

I recommend Git

copper monolith
#

i have a toggle button that is set to false by default when the scene loads but i have it set a public static bool to true and when i load back the scene i want it to still be true instead of reseting to false however when i try to access the isOn bool in the same way that i access pretty much any other value it doesnt work and i even tried to do getComponent<Toggle>() and it didnt work, does anyone know how to fix this?

frigid bone
#

Anyone know why I might be getting these artifacts in my textmeshpro objects?

midnight helm
jagged monolith
midnight helm
#

Okay thank you

#

And you recommended having different assets for different screens? Because currently I am building it on a Samsung andorid phone 16:9 aspect ratio, however if my games are played on a Samsung fold, the entire UI is out of place

wild pebble
frigid bone
#

Hmm, I already adjusted the padding but I'll see about turning it way up

finite portal
#

Does anyone know latin?

jagged monolith
toxic mural
#

Hello, how do I render sprites above 3D mesh? (No I don't want to physically move the sprites ahead of 3D meshes)