#๐Ÿ“ฒโ”ƒui-ux

1 messages ยท Page 54 of 1

dense terrace
#

I have a ui element with a few buttons that I activate/deactivate in multiple scenes. In my first scene, everything works perfectly, however, in another, the buttons don't react to anything. I've made sure there's a eventsystem in both scenes, I've copy and pasted my ui canvas from another scene into another, with no avail. It only happens in this one scene. What could possibly be happening?

#

This is such an agitating bug...

dense terrace
#

Just tried using DontDestroyOnLoad on the canvas that works in the first scene to see if it carries on to other scenes. It doesn't fix the problem.

radiant oracle
#

Have you tried using a separate OnClick method for the new scene? @dense terrace

#

or are there any aspects of the OnClick method that dont have access to data within the second scene

dense terrace
#

What I'm doing is instantiating a button prefab, with a script that has a function that is called with the OnClick() event. It works just fine in the first scene, but more importantly, I've noticed that the buttons don't even REACT when I hover or press them (like the default color tint effect I put on the prefab)

#

So it must have something to do with my event system... maybe?

#

If theres any screenshots I can send to help, let me know.

dense terrace
#

The craziest thing, is it works just fine in my editor (most of the time). But in my build, the buttons NEVER work.

rapid ferry
#

How do I remove the white outline around the dropdown menu?

mortal robin
rapid ferry
#

Ah ok cool

#

Thanks!

#

Also how would you set a default option for a dropdown?

mortal robin
rapid ferry
#

These are my options for the dropdown menu, but I want it to default at 1920 x 1080

#

Is there a way to do that?

rapid ferry
#

Ohhh ok I'm so stupid thank you so much xD

sour arrow
#

Ayone have a good tutorial to UI objects? Nothing i do is making this damn elements stay where i put them,

#

Its starting t piss me off, so I figured id ask here, if anyone had a good Youtube video or written doc somwhere that explains how to force these things to stay where i put them

#

My canvas scaler is set to Scale with Screen Size...but its not working all the way down on eveything

#

This is what its supposed to look like:

#

But this is what i get:

sour arrow
#

Im reviewing it again now, ty

#

ok SO i was doing it correctly...but it didnt like my Free Aspect resolution

#

made a setting for HD 1920x1080

#

youd think setting Stretch and match would...ya know do what ya told it to do

#

working now.

safe hull
#

that looks awesome @sour arrow ! ๐Ÿ™‚

fathom rune
#

So i have a scroll list. and i have 2 buttons

#

in the scroll list there is a viewport and scrollbar

#

in the viewport i have 2 panels

#

i use the buttons to change the selected panel

#

howeaver

#

though the panel which scrolls changes the other panel still shows in the back or fron depending on hierarchy

#

is there a way to set visibility of the other panel to false?

azure flame
#

Use CanvasGroup to manage visibility

fathom rune
#

Whats that?

azure flame
#

Something you should look up in the manual if you encounter something you don't know.

fathom rune
#

so its. component

#

thanks

bright dagger
#

I have a hopefully pretty simple question, maybe I'm just missing something - I have a grid layout group to which I keep adding Prefabs at runtime. now, the Prefabs are all children of the panel with the grid and as such being displayed as a grid, with their order in the hierarchy being the order they're drawn in the grid. Now I have the problem that each prefab has a small menu you can open and it opens up on the right side next to where the prefab is on the grid. unfortunately, the menu slightly overlaps the next object in the grid and is drawn BELOW it and I am looking for a way to make it draw above it instead

fathom rune
#

Could you send a screenshot of your hierarchy please

bright dagger
#

here is a visualisation (I want the grey box to not be cut off by the adjacent panel)

fathom rune
#

Ahh

bright dagger
#

SessionTemplate being the prefab in the grid, OptionsPanel being the grey box

fathom rune
#

So the problem is with hierarchy

#

the things towards south will be displayed above

bright dagger
#

I know

#

the problem is, the lower object in the hierarchy will also be drawn later in the grid

#

but I need the objects in the grid in that order

fathom rune
#

hmmm

#

Reverse your hierarchy such that 10 is the first 9 is the second and so on

#

and make it so that the order of drawing them is reversed?

bright dagger
#

I have no idea how I would do that, I'm not sure it's even possible to control that

fathom rune
#

hmm

bright dagger
#

that's exactly why I'm asking here :D

fathom rune
#

lell

#

uh

bright dagger
#

it's also the kind of problem where I'm wondering what the hell I'm supposed to google for

fathom rune
#

Yeah i know that feelng

bright dagger
#

hardest part of game development tbh

fathom rune
#

lmao yeah

#

Thank god for discord servers

bright dagger
#

so if anyone actually knows a solution for this hit me up ๐Ÿ˜

azure flame
#

@bright dagger If you want something to pop on top, put it in a container that is lower in hierarchy always.

bright dagger
#

mh and how do I fix my grid layout group element order?

azure flame
#

You don't have to move the entire object, just the thing you want to show

bright dagger
#

but... the thing I want to show is always a child of the object in the grid since they're part of the same prefab

#

I think I got a solution though

#

kinda random question but is there a simple and elegant way to make a panel disappear when a click somewhere not within the panel is detected?

azure flame
#

Use canvasGroup to control visibility

fathom rune
#

I feel like i heard that before

azure flame
#

It goes around. It's a method with no overhead in comparison to disabling objects.

fathom rune
#

idk why i find that funy

rapid ferry
#

I have a question.. how do I make my ui elements smaller when resolution is changed?

azure flame
#

When people don't know how to use UI components properly, you end up like BattleTech , opening scrollable list of 100+ items and almost halting your PC.

azure flame
warped nimbus
#

Has anyone been able to get the new UI toolkit system working with the new input system, i.e. with local multiplayer splitscreen?

warped nimbus
# warped nimbus Has anyone been able to get the new UI toolkit system working with the new input...

Alright, figured it out. It's not officially supported (https://forum.unity.com/threads/feedback-wanted-new-input-system-support.963111/#post-6920885). But it's possible to have a UIDocument on each Player prefab, then split them like this:

    rootVisualElement.style.right = new StyleLength(Length.Percent(50));
if (myPlayerID == 1)
    rootVisualElement.style.left = new StyleLength(Length.Percent(50));```
bleak violet
#

Hey everyone, I'm doing a main menu and when I add buttons with textmeshpro and press play, I'm not able to get a selected and clicked feedback (change the colors), does anyone have a solution for this?

low pike
#

Do you have an event system loaded?
Is there anything in the way blocking it?

sour arrow
analog citrus
#

Does anybody here have any experience whatsoever with XmlLayout on the asset store? I've got a couple of questions if any of you do!

vestal nest
#

What is an equivalent of a uGUI's prefab of specific type which is Instantiated at Runtime and added to UI, but in UITK's Runtime?

#

Do I need to create custom C# VisualElement for that or using just UXML Template Instances will be enough?

wooden mortar
#

can someone help me: VisualElement.worldBound.width returns NaN. How can that happen?

minor mulch
#

why does the buttons get smaller when i change the size of the window

#

and how do i stop it

bleak violet
bleak violet
#

I think

mortal robin
#

that will tell you what object(s) your mouse is over

#

it should show your button but it might show you some other object that is blocking it

low pike
#

have you changed the colours to obviously different colours?

#

the default colours are too similar

bleak violet
#

Its not about not being able to differentiate between them, is more about none of them are working lol

#

I will try that

low pike
#

... it just makes it easier to tell while you test

bleak violet
#

I am able to click the buttons and they do what they are supposed to do

low pike
#

do a screen recording .. showing the whole editor

bleak violet
low pike
#

someone had this issue the other day

#

disable this component and try again

#

I think that devs fix was to delete and remake the event system

mortal robin
# bleak violet Here

Ugh - the preview window is useless for the EventSystem in the new input system unfortunately

bleak violet
#

The whole UI module or "deselect on background click"?

mortal robin
#

the checkbox in the top left

#

the whole module

low pike
#

"deselect on background" isn't a component, it's a field

#

so, just this tick box

#

I've never seen this component before, I'm wondering if it's the cause

bleak violet
#

Now the click events don't work

low pike
#

but mouse over does?

bleak violet
#

Nope

mortal robin
mortal robin
low pike
#

bleh - the new input system is shit, but haven't used it with UI, so.. I can't help further

bleak violet
#

Well I had an error in the event system and thought that was it, and I think It added that thing there

mortal robin
#

yeah your input module looks fine

bleak violet
#

Standart styff

bleak violet
mortal robin
#

instead of the image

#

you don't really.. have a visible image background for your button as far as I can tell

low pike
#

how big is/what is UISprite?

#
  • that recttrasnform
mortal robin
#

it's the built in rounded rectangle sprite

#

that unity uses by default

#

and they have the alpha set to 0

#

so it's invisible already

#

so the color tint isn't going to be visible on it

low pike
#

the alpha doesn't stop it from being raycastable

mortal robin
#

it's not a problem of not being raycastable

low pike
#

oh, I see what you're saying

mortal robin
#

the raycast is working fine

#

the tint is not working

bleak violet
#

And not sure what I did for this to happen? lol

mortal robin
#

wait so what is that play thing

bleak violet
#

Yep

mortal robin
#

is that text?

#

Or an image?

#

what is it

bleak violet
#

Play and quit are images, the others are text

#

Buttons actually

mortal robin
#

I mean the actual visible thing

#

that says "play"

#

it's text?

bleak violet
#

Yes

#

TextMeshPro

mortal robin
#

And that's the thing you set as the target graphic on the Button component?

bleak violet
#

Yes, although its not meant to be the text but the area around it

#

To be selected and clicked

mortal robin
#

try seting target graphic back to ui sprite

bleak violet
#

But i did, still nothing

mortal robin
#

and set the default color of UI sprite to have full alpha

#

(right now alpha is 0)

#

I know it's not visually what you want yet but let's see if that works

bleak violet
#

changed the colors so it would be noticable, nothing happens

bleak violet
mortal robin
#

what does the rest of the hiearchy above these buttons look like?

low pike
#

are you using the new input system / do you need it in this scene? -> if not, use the old event system

bleak violet
mortal robin
#

you're using different inout systems on different scenes?

#

In project settings what is your setting for Player -> Active Input Handling?

bleak violet
#

In my game scene I basically followed a tutorial to implement a zoom feature on cinemachine. I have no clue how the input systems work I just followed something that worked lol

bleak violet
mortal robin
#

just search project settings for "input"

#

with the search bar

#

I don['t rememebr exactly what it's called

#

but the setting for new input/old input

bleak violet
#

Yeah, on the player tab there's nothing with that name

mortal robin
#

it's there

#

under other settings i think

bleak violet
#

Ohh found it

#

Its "both"

bleak violet
#

Got it to work, somehow lol. Thanks for the help guys

dim mulch
#

hello

#

i wanna ask

#

how can i fade a panel in?

#

like its not active

#

i want to fade it into active

#

like SetActive(true);

#

but with fade animation

vestal nest
#

Just change Image alpha over time

dim mulch
#

how

#

so i have setactive and change the alpha into 0

#

and when use while loop and make it into 100?

#

(or any other loop like for)

vestal nest
#

It won't work just with a loop, you could use coroutine for that

ripe hemlock
#

Hi, I'm trying to do a drag-and-drop for some of my UI elements, in this case dragging a string of variable length into a box that then will change size to fit the string inside, so ordinarily I would place them at the 'anchoredPosition' of the box, but at the same time, I need these boxes to be anchored to one side so they don't expand off-screen when a big word gets put in them

what can I do to refer to the centre of the object without being able to use the anchoredPosition?

vestal nest
#

@dim mulch
Here's an example how to do it with a Coroutine:

StartCoroutine(Fade(1, 1)); // fade-in
StartCoroutine(Fade(0, 1)); // fade-out

IEnumerator Fade(float end, float durationSeconds) {
    var start = panel.color.a;
    for (var elapsedTime = 0f; elapsedTime < durationSeconds; elapsedTime += Time.deltaTime) {
        FadePanel(Mathf.Lerp(start, end, elapsedTime / durationSeconds));
        yield return null;
    }
    FadePanel(end);
}

private void FadePanel(float alpha) {
    var color = panel.color; // Image panel
    color.a = alpha;
    panel.color = color;
}
dim mulch
#

hmm

#

oo

#

i will try

#

so i have set active first

vestal nest
#

Yeah, and when you need, you SetActive at the end or start

low pike
#

โค๏ธ DOTween

wooden mortar
#

DoTween should be a standard lib within the UnityEngine namespace. Its just that useful. Writing all those tween functions and sequenzing yourself would be too much work and somebody else already did it for you

west oyster
#

Does someone know how to make my text box bigger? from UI > Text?

#

scale seems weird since hten size 14 is huge

#

and a bit blurry

#

I don't even mean dynamically or by a script I just want to change the size of it myself

jade dirge
#

Hey guys, any idea how can I "disable" the selected trigger of a button

#

I need it to be either normal or highlighted whether or not it's been pressed

west oyster
#

thanks runningvlan

#

I would have never found that lol

signal tinsel
#

not sure if this is best place to ask really, but im just working on a card game prototype and ideally I want cards to sit at bottom of the screen and be played by dragging them towards a target, be it a target in the world or a UI element which acts as a drop target of some sort.

Now given I want the cards to have front and backs it seemed easier to represent them as 3d objects rather than 2d UI elements, but it seems like this is a sort of common thing for people to do, so is there any pros or cons to doing the cards as a world layer vs a ui layer? as I have seen people say that having UIs that are draggable and interact with world content can be problematic but no one ever says why.

odd falcon
#

Hello can someone please help me? I have tried 9 slice a sprite for interface design but I can never seem to get the slicing to work, here is my sprite and

#

here is my ui and sprite settings

#

as you can see the gray border what is sposed to be there is completely out of wack

dense terrace
#

Try seeing if changing this value helps at all

wind rock
#

I am working on a short unity game based on a writer reading out a script and you going through the story in your imagination, but my main menu is super boring, anyone got any banger ideas/tips for making a good main menu?

odd falcon
dim mulch
#

Screen position out of view frustum (screen pos 0.000000, 0.000000, 10.000000) (Camera rect 0 0 1024 1024)
UnityEngine.StackTraceUtility:ExtractStackTrace ()

#

what is this?

#

everytime i move my cam

#

it keep spam appear

#

i started my unity just now

#

and i have 475 of it

#

error alr

#

(it doesnt affect me to start game)

dim mulch
#

uh

#

anyone

mortal robin
dim mulch
#

i made it very big

#

is that caused this?

mortal robin
dim mulch
#

scale is 30000

#

i now made it 10000

mortal robin
#

Your game is just... not going to work well like that

dim mulch
#

hm

mortal robin
#

almost deifnitely your error is related to it

dim mulch
#

what should i do

#

its an ocean

#

i want to make it infinite

mortal robin
#

but, Unity uses 32 bit floating point numbers which start to get unworkably imprecise around 5000+

dim mulch
#

player will never able to each it end

mortal robin
#

you certainly don't define the whole infinite ocean up front

dim mulch
#

so i set to it 5000 or lower

#

the error will gone?

mortal robin
#

I don't know, try it

#

but. if your near clipping plane is that high - your camera can't even see anything anywhere near the camera

dim mulch
#

i think it stopped

mortal robin
#

so idk what the point of that is

dim mulch
#

i have 999+ on the error list

#

but it doesnt spam appear now

frank jewel
#

Hi. Should I use the new UI system or the old one?

frank jewel
#

what is editor UI

#

making custom editors?

low pike
#

yes

frank jewel
#

ok, well I guess I should stick to the old UI

#

The new UI system looks good though

low pike
#

its ok - really shit documentation though

frank jewel
#

is it easier to use?

#

Why is there no text mesh pro room? or is this the text mesh pro room?

low pike
#

TMP is UI

low pike
# frank jewel is it easier to use?

This is relative. I prefer the old UI, and find it easier to use.. but I've been using it for 4 years. And have only used the new UIToolkit a bit for an EditorWindow

frank jewel
#

Yeah I'm not sure if i need to know CSS or something? I'm sticking to the old way because i am a little bit familiar wit it now

wooden mortar
#

How do I override settings for stuff I dragged in from the Library in the UI builder

vestal nest
#

You mean style? Just change it

wooden mortar
#

Its all greyed out

vestal nest
#

You mean elements inside Unity controls?

#

You want to change their style? Click on them and you'll see their classes, then you can override their style using css selectors

#

You can't change the hierarchy though

#

But you can extend this Control (extend the class, like MyElement : VisualElement) or create your own custom controls

wooden mortar
#

I'm a little confused

vestal nest
#

For example, unity-label is the css class of that element

wooden mortar
#

So why can't I change what css class it uses

vestal nest
#

You can try doing this

.unity-label {
  position: absolute;
}

You can't change the css classes of greyed out elements, but you can add your css class to the control and try doing this:

.my-class .unity-label {
  position: absolute;
}
wooden mortar
#

Ok thank you so far. But it doesn't even let me add a style for the greyed out elements

vestal nest
#

Yes, that's on purpose, because these elements are created dynamically

#

For example, I wanted to change the image (and other style) of Unity Toggle Checkmark and did this:

.my-class .unity-toggle__checkmark {
    width: 20px;
    height: 20px;
    border-width: 0;
    background-color: initial;
    background-image: url('project://database/Assets/Sprites/pin.png');
    -unity-background-image-tint-color: var(--color-gray);
}

.my-class .unity-toggle__input:checked .unity-toggle__checkmark {
    background-image: url('project://database/Assets/Sprites/pin2.png');
    -unity-background-image-tint-color: var(--color-white);
}
wooden mortar
#

So what I wanted to do was use that controls library as basicly blueprint I can drag in to customize but apparently thats not the intent?

vestal nest
#

You use it when you want the functionality
And you can customize the look with css selectors

#

If you want some custom functionality that isn't provided out of the box then you create your own custom controls

#

Almost everything is a bit different with UITK compared to uGUI ๐Ÿ™‚

#

How to get element's center position in UITK?
In uGUI we could center element's pivot and when calling transform.localPosition we'd get the correct position, how to do it in UITK? transform.position returns position at upper left corner (and I haven't changed Pivot Origin).

wooden mortar
#

well I'd just give it a parent and use align-items and justify-content ๐Ÿ˜„

#

but yeah I'm new to this and I guess I have to do more research. A walk through by Unity to build something simple but individually styled would have been great.

vestal nest
#

And it doesn't work anyway, child's transform.position returns (0, 0) ๐Ÿ˜ฆ

wooden mortar
#

Try getting it 1 frame later

vestal nest
#

I checked, it's always zero

wooden mortar
#

oh :/

vestal nest
#

Found that is can be achieved using worldBound.center

merry wing
#

can anyone think of a reason why my VisualElement would not be getting calls I've asked for with RegisterMouseMove? PickingMode is set to Position, and there are no elements on top of it.

uncut folio
#

When do layout groups update? Should I be disabling the component after the first frame of activity to save performance if i dont need it to order position afterwards?

mortal robin
uncut folio
#

because i have sliders, toggles, buttons, texts that change

#

none change the "overall" size of the controls, but they do change

#

maybe i should just make a script OnEnable that turns it on and off after a frame to reorder once

waxen yacht
#

newbie question: Im fooling around with UI, and I want to use an icon that matches an object in the game world. The lazy part of me was hoping I could slap a prefab variant on the canvas, and it would look like a 2d variant on there. However, it dosent render on the overlay. I have a text UI element next to it as a control step, and it shows normally.

Why dosent the prefab show?

trim bear
#

hey i want to access the text & the button components using script what do i type after public

#

?

mortal robin
trim bear
#

cancel that

#

i found it

#

sorry

odd falcon
#

Hello can someone please help me, I do not want to set the color of my UI Button, Instead I want to change the color of the text inside that button when that button is selected.

uncut folio
#

easiest way i can think of

waxen yacht
mortal robin
waxen yacht
mortal robin
#

Or just get a nice PNG of it and use that as a sprite directly

#

Up to you

chrome kettle
#

3D objects can be rendered as 2D with rendertextures as PraetorBlue said, or with overlay cameras
But neither of those solutions are "simple"

waxen yacht
#

yeah, that figures. using 3dpaint to create a png out of a screenshot takes 3 seconds, so guess thats a bit easier. Thanks for your replies!

mild kernel
#

You can also use a RenderTexture to render a model to the UI.

trim whale
#

Hi I am new to Unity and was wondering why when I add a CANVAS it appears at the bottom left instead of at 0x 0y 0z it seems like it is the only UI element that does this can anyone help or tell me why ??

mild kernel
#

Screenspace Canvas' are their own space. It doesn't have a world position.

#

If you want it to be in the world, you can change it to be a world space canvas on it's Canvas component.

trim whale
#

So it is not going to matter its size or location it only needs to be present in the Hierarchy

#

I just dont know how it will affect the menu or ui I am setting up

azure flame
mild kernel
#

Well, you want to do a little learning on how screenspace UI works with regards to resolutions and such.

trim whale
#

Ok I will go and try to find some more information on this thanks for your help @mild kernel and @azure flame Sorry if it was a stupid question just didn't know the verbage for what to look up and get a good result

#

I tryed a few searches but seemed like most of the stuff I was looking through was old and wasn't sure if it was relevent any more

#

the unity docs are good but were very confusing on a lot of the information there

mild kernel
trim whale
#

Ok thanks @mild kernel I am watching the ui for canavs on unitys youtube site if anyone wants to check it out it is here : https://www.youtube.com/watch?v=OD-p1eMsyrU&t=118s
I also am comparing the information in the docs as well to the screens and options I want to make sure i understand it before I continue on in my class I am taking

Watch on the official Unity learn pages here -

The Canvas is the root component for rendering all UI objects in Unity.

โ–ถ Play video
mild kernel
#

The important part to remember for screen space UI is to create your UI to scale and stick with that resolution.

#

Then set your canvas scaling to Scale with Screen Size and set the reference resolution to the same.

#

That way it'll be a 1:1 scale with your imported UI.

#

Then of course, proper anchoring of your UI elements so that when the resolution changes, remains where it should.

trim whale
#

Ok Very helpful thanks for the information I will keep this in mind @mild kernel I am trying to learn this stuff for a Udemy course I am taking hopfully it will start making more sense as I go but thanks for all of the helpful tips and usfull information I really appreciate it

odd falcon
#

Hey guys can someone please tell me if I am going insane or not?

Does it look like that second time the bar goes across the screen is faster than the first time?

vestal nest
#

UITK
Is there documentation for custom VisualElements?

ripe igloo
#

Hey guys,
does anyone know, how to get a panel like in my picture on the Screen of the Computer Object, so that i can interact on the Computerscreen and not only in the UI panel i can enable and disable?

low pike
#

set the canvas to world

quasi phoenix
#

this text refuses to get any bigger than this

#

no matter how high i increase the font size

#

it stops at like

#

5

low pike
#

Press T , to change the gizmos to the UI ones.. and see how big the rect is

#

would also recommend changing to TextMeshPro

fluid ginkgo
#

How do I make changes to the TMP_SDFShaderGUI.cg that survive Unity restarts? Or... how do I make a custom version of this that's unique and somehow works? New to editor customisation and Unity shaders... as material editors of the underlying shader's accessible bits and bobs

ripe igloo
# low pike set the canvas to world

but for that my objects are to small. When i get them bigger then nothing works anymore. if i set the canvas to world and size it down you cant read anything becuase the buttons are to small

#

ah got it thanks ๐Ÿ˜‰

low pike
#

๐Ÿ˜„

daring scaffold
#

Hello. I made a script to put what a character says on his top:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class CharacterDialogBuble : MonoBehaviour
{
    public TextMeshProUGUI dialogBubleLabel;
    public Image backgroundColor;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //if (dialogBubleLabel.GetComponent<Renderer>().isVisible == true)
            Vector3 pos = this.transform.position;
            pos.y += 1;
            Vector3 bublePos = Camera.current.WorldToScreenPoint(pos);
            dialogBubleLabel.transform.position = bublePos;
            backgroundColor.transform.position = bublePos;
    }
}```
but when I watch exactly 180ยฐ back I see the text that comes back to my screen
how to avoid it?
please
cold plinth
#

Anyone know any reasons for a UISlider not sliding?

#

I don't see anything in front of it, like overlapping colliders or such things so it's very strange

uncut folio
#

How can i have scroll views scroll to the selected item in dropdown menus?

daring scaffold
#

I finally arrived alone

fluid ginkgo
#

Where/What is the file that generates the Builtin GUI in Editor Inspector for shaders like Particles? How does one find, access and edit this file?

fluid ginkgo
mortal robin
fluid ginkgo
#

There's something I'm missing in how this works. A part of the process I'm failing to do, or even know exists. If I create a new shader, that's a copy of an existing one, and then start modding it to be unique (unique name, a couple of extra features/changes), how do I then get this to access the same path of hierarchy to UI presentation of the Material's properties? It doesn't seem to just work.

#

For example: I want to change the TMP_SDF shader, making my own version that has a stronger glow falloff, and a slider to control this falloff. I can do that, and can do it in the existing shader... and this works. the problem: it changes the appearance of all my existing TMP objects, so I want to make a unique TMP_SDF shader, TMP_SDFmine...

#

Making this requires that it know of TMP_SDFShaderGUI, the part of the TMP package that draws the GUI of the Material in the Inspector, for the shader.

#

Customising TMP_SDFmine with new properties doesn't automatically draw them in the Inspector, I have to modify TMP_SDFShaderGUI to do that... however, those modifications aren't saved between Unity restarts, because the package Manager forcibly resets the TMP_SDFShaderGUI file between restarts.

#

Attempting to make my own TMP_SDFShaderGUI_mine, leads to layout problems and many other issues in the Inspector, as there's some kind of hierarchical descendency going on that looses its flow when I use mine...

#

What am I missing in how this works?

#

I've read about the npm cache and the global cache, and unpacked the TMP version of this, and modified this... as another effort to work around this problem. This only leads to much bigger problems. Sorry to bother you with this. There's an issue that I don't know, in a system that I know of, as to how the whole system works for creating custom shaders that descend from TMP

#

TMP = TextMeshPro

silk coral
#

why cant i push buttons? when i click, it doesnt do anything

mortal robin
silk coral
#

oops

#

wait yeah i do

#

@mortal robin

mortal robin
#

you have an input module on the event system?

#

(and is it the right module for the input system you're using?)

silk coral
#

i have a standalone one

mortal robin
silk coral
#

the default one

mortal robin
#

Ok and:

  • Does your canvas have a Graphic Raycaster?
  • Do your button graphics have "raycast target" enabled?
#

If you select the event system and play the game, can you see your button in the "Pointer Enter" section of the preview window for the event system?

silk coral
#

yeah to both, ill check the third one

#

wait nvm they work now...

#

they used to just be like images

#

whatever, thanks

wicked cairn
#

Anyone here familiar with how to make TMPro's links work? I'm talking about the Rich Text ones mentioned here: http://digitalnativestudios.com/textmeshpro/docs/rich-text/#link

The docs really don't help. They mention linkInfo but not that linkInfo is accessed via textObj.textInfo.linkInfo. But even past that, I'm not sure how to watch for clicks. Is there an event handler I can attach a method to? Do I need to watch for mouse clicks and then check if it was on that link?

I found a forum thread (https://forum.unity.com/threads/clickable-link-within-a-text.910226/) but there's no code fragments to point me in the right direction.

pearl marlin
#

I have this same issue with canvases z-fighting even when one if physically in front of the other https://forum.unity.com/threads/world-space-canvases-sometimes-appear-behind-further-canvases.357809/

"So the most likely issue is that they are all sorted by distance to the camera. The distance is taken from the center of the bounding box."

does anyone have any workarounds for this?
The only suggested options I have found is to change the order in layer or the spacing but niether of these will work for VR where the camera angles are dynamic.

rustic moat
#

how can I edit the textmeshpro in script?

#

[SerializeField] private TextMeshProUGUI text; I'm trying to do this but TextMeshProGUI seems to be missing

mortal robin
heavy jungle
#

Hey guys, how would I go about creating this style of text in Unity using with text mesh pro system?

fluid ginkgo
heavy jungle
fluid ginkgo
#

Argh... I see... a "cutout" effect, like paper with holes in it from the letters....

#

Fake it: I think you'll have to put a texture on the TMP, in the Face part of the shader, that matches the background (pink and white lines in this case) and then size that texture so that it matches the pattern on the background, "underneath" the blue.

#

In the TextMesh settings, above the shader, there's an option to set the width of the textures used based on letter, line, paragraph. Choose paragraph, as this will give you a consistent scaling across both lines.s

#

Then you'll need to fiddle with the scale of the texture in the shader's face texture slot, as it's highly unlikely that just dropping it in there will match the background.

#

If the background has both a horizontal and vertical pattern, it will be more difficult.

#

If you really want to "sell" the effect, use Underlay on Internal Mode (again, in the TMP Shader) to fake an internal shadowing on the background.

rustic moat
mighty oar
#

I'm having a few problems with the text in my game and was wondering what the issue might be... this is how it looks when in the inspector and the game isn't running

#

and then it does this when the game is run, and shrinks...?

merry wing
#

I've done CaptureMouse on a VisualElement and registered a mouse down callback. I was getting the callback twice, so I figured, that's trickle down and bubble up. But actually the phase is AtTarget on both calls. Other elements aren't getting the callbacks at all. How can I say "ok, I'm not interested, carry on doing the default?" Is that possible?

wet bolt
#

I have a toggle component here, I need to change the target graphic's tint manually

#

is there any method or property I can set to change which of these is currently set

mortal robin
#

however - one thing you can do is change that set of colors to anything you want.

wet bolt
#

Not what I need to do here I don't think

mortal robin
#

for example you can change the "normal color" to what would normally be the "selected color" in order to simulate selecting it without selecting it

wet bolt
#

I'm making a mod for a VR game which has it's own code for selecting things. There's an odd bug with it where if you select a toggle, and then select another toggle in the same group it'll deselect the old toggle but won't change the tint back to normal

mortal robin
#

man that sounds so familiar. Playing with friggin toggles and the event system and trying to get color tints to work right

wet bolt
#

Starting to hate Unity's UI system lol

#

some of it is pretty intuitive and great, other times you'll accidentally add a layout group to the top level and watch it permanently reset all the transforms and scales of every child and then auto save the prefab

#

Just can't figure out this thing with the toggles

#

I figure I'll probably just end up controlling the tint manually by setting the toggle.targetGraphic.color

#

I just don't want to lose the pretty fading transition or waste time doing all this

#

oh!!

#

Found a fix

#

Just disabling the button gameobject and re-enabling it on the next line resets the toggle color. Just have that running in a listener on the value changed event

#

Mm.. doesn't seem to work if I press the same toggle to turn it off though

lethal moon
# wet bolt some of it is pretty intuitive and great, other times you'll accidentally add a ...

This is why I design all my UI using only layout groups, with no manually-positioned elements (well, except for dropdowns, since they don't play nicely with horizontal layout groups - I just add a layout element and set the preferred height to 30). The learning curve is pretty steep but once you figure it out, only using layout groups makes everything a LOT easier to work with.

wet bolt
#

Yeah I figure that system's probably better

#

still can't figure out this toggle thing. I assume it's due to how the game is doing it's selection stuff

lethal moon
#

With that kind of thing I find it very helpful to draw (MS Paint, Photoshop, paper and pencils, a whiteboard, whatever) exactly how you expect the UI to look. You'll figure out a lot by doing that (including sometimes helping to figure out a sensible way to store the data internally). Work out what should happen when the user clicks each option. And then if you post that here I'm sure someone can help you figure out how to achieve it.

There's also tools specifically designed for that called "wireframe" or "wireframing" tools but I've never been a big fan of them.

granite oar
#

Does anyone know if it's possible to create buttons in a windowed build of a game, just like the buttons you have at the top of unity?
Or do you have to create those manually?

lethal moon
granite oar
#

Mmmh, might look into that. Or just recreate it with unity buttons. Thanks

lethal moon
cold plinth
#

how does one add boarders to a 2D image so it can be sliced?

mild kernel
#

Open it in photoshop or a similar program and add to it?

mortal robin
#

you can do it with any image

cold plinth
#

god damn it I keep forgetting to remove my messages once I'd found a solution, thanks anyway guys

#

turns out I didn't even wanna slice, I just needed that 9 square boarder thing which is even easier lmao

livid canopy
#

Hi. I have an issue where the first textbox in my scrollable list is wrongly placed. all the other are appended on top.

#

is someone familiar with this?

#

but if i click on the GO in the hierarchy, it refreshes and is in place (however this is not doable in build ๐Ÿ˜ )

#

if anybody needed more info about my issue:

livid canopy
#

so i solved it with the below code, probably a bug or something.. (calling one rebuilder is not enough ๐Ÿ™‚ )

lethal moon
#

@livid canopy Sometimes I find doing Canvas.ForceUpdateCanvases or whatever it's called is necessary. Not sure why

pseudo apex
#

So, I'm looking for some tips, I have a mobile side scroller, but when I press one of the menu buttons I want it to seem like the camera pans away from the character.
Just move to the right/left instead of having the UI move.
So my thoughts was to have the UI in world space, scale it to the size of the screen and then move it to the exact position I need it to be in based of the screen width.
I have done this one a previous project, but I kind of want to hear if people have any other ideas or best practices for how to make this effect come to life?

lucid latch
#

Your issue...

pseudo apex
#

It's not exactly an issue, I just want some advice on how I should do this in the best way. I want the camera moving instead of the UI. And the UI needs to be scaled to the screen size but moved to the sides.

lucid latch
#

okay..lemme think

lethal moon
mild pilot
#

Hi all. Im trying to get my TextMeshProUGui (world space canvas) to render in front of everything, but even changing the material to DistanceField or Overlay, it still doesn't work
Any hints?

#

Oh wait, actually it DOES work!
But the TMP <sprite> (the fire icon) doesn't as seen in the pic. Is there any way to do this?

pseudo apex
lethal moon
lethal moon
mild pilot
#

It works, edited the default TMP/Sprite shader a bit

My bonus question is, it seems i cant make a new material for TMP sprite? Hence why i gotta edit the default shader (that is used by the default material)

#

Ah ok it seems i shouldnt change the "default material" that's already assigned, and double click and edit that directly (the shader n all that). It's hidden, and any sprite asset's default material got the same name, but apparently they're different..

merry wing
#

I'm using the URL of a Texture2D asset as the cursor property in a USS file. The import settings specify it as a cursor. The image is 16 x 16, however when I mouse over the element it scales it up to 32 x 32. Any idea what I've done?

torpid stone
#

Hey all, any ideas on how to set a single word to a different colour using TextMeshPro?

wary swallow
#

Can someone help out @sonic coral he is sayi g that his sliders not working its working if he makes another scene but in the same scene it doesn't

mild kernel
wary swallow
#

Sorry

#

I was tryinna help him

#

And i pinged him to let him know that he can ask dedicated ppl about that topic on this chanell

#

U just target meh all the time u dont like my name or u dont like my pfp?

#

XD

mild kernel
#

I don't even know who you are. There are hundreds of people who pass through here a day.

wary swallow
mild kernel
wary swallow
#

Aa?

#

I learned another lesson today

#

Trying to help others is Bad

mild kernel
lofty nova
mortal robin
#

definitely not a video

#

animations probably created in some external software

#

and orchestrated in-game with some kind of Timeline thing

#

afaik blizzard uses their own internal tools so there may not be 1:1 equivalents in the Unity world

chrome kettle
mighty oar
#

I'm not too sure why, but buttons aren't responding to being clicked in one specific scene...

#

they work in one, just not this one and I can't quite figure out why

mortal robin
mighty oar
crisp marsh
#

I am not a programmer so this is a bit new to me. Is there an easy way to control animation with keyframes of the material/shader values of textmeshpro?

Basically we have this big timeline animating a bunch of materials & objects in a scene and want to have some text reveal through the dilate effect in the shader

marsh cliff
#

Can I use another button to change between these 2 onclick events?

chrome kettle
pseudo apex
rapid ferry
#

how to convert an image to sprite2d ?

#

i dragged and dropped it in the assets folder from canvas but the texture type doesn't show up in the inspector!!

mortal robin
rapid ferry
#

thanks i figured it out ๐Ÿ™‚

swift veldt
#

so

#

what can i do?

#

on scene is the button

#

then on game is not the button

low pike
#

it's positioned off screen

#

this white line is the canvas, if you put something outside of it.. then the camera won't see it

swift veldt
#

and why the camera see the other button?

low pike
#

keep the scale at 1,1,1 and change the size of things with width/height

low pike
swift veldt
#

i dont have any canvas

low pike
#

RectTransforms are for canvases.. UI is for canvases

#

Those are just names, not components

swift veldt
#

okay

low pike
#

Just Dance must be a canvas

#

"Quick Play" I suspect is a SpriteRenderer.. so is done incorrectly

swift veldt
#

quick play is just an image

#

there is the button on game part but on scene is super big

low pike
#

Yes, the UI in the scene view is huge - it's supposed to be

#

Select the "Just Dance" game object, then put your cursor over the scene view and press F

swift veldt
#

but

low pike
#

but what?

swift veldt
#

i cant make the canvas like the background size?

low pike
#

that white box is the canvas.. it is the correct size

#

it resizes to the size of the camera as needed

swift veldt
#

oh

#

and i cant change that size?

low pike
#

no..

#

go and do all those

swift veldt
#

oki

#

tysm

low pike
swift veldt
sweet harness
#

Anyone got tips on where to start with UI in a new project? What's the latest from the Unity team? Are we supposed to be using the new UIElements package ?

mild kernel
#

Nope, currently, you should continue to make your UI as normal. The UI toolkit isn't production ready.

sweet harness
#

when you say UI as normal.. what do you recommend?

mild kernel
#

Using the built in UI system. Creating a canvas object, putting child elements into it. The usual.

spring hawk
#

Hey everybody, i'm having this weird issue where one of my Sprites is only a fraction of the size of all the others, but appears in normal size in my game view. When I make it normal sized in the scene view, it disappears in the game view because it gets too big. Any idea where this issue is coming from?

crisp marsh
mortal robin
#

sorry for the delayed answer there.

#

Everything else in the scene is a UI element - e.g. Image, Text, etc...

spring hawk
karmic osprey
#

Is there no channel for discussing the Unity editor interface?

chrome kettle
shut hull
#

hello everyone,i am making 2d andoid game and i have problem with screen resolutions

quasi phoenix
mortal robin
quasi phoenix
#

i fixed it a couple minutes ago and forgot to put it here, my cursor was being locked by another script

obsidian yarrow
#

Is there anyway to make textmeshpro objects toggle on and off with the gizmos tab?

mortal robin
#

(editor only)

obsidian yarrow
#

ah interesting, ok I'll try that

#

thank you

rapid ferry
#

In certain games theres lines of text that are highlighted, and you can click on them for extra information, how could I do that in unity?

rapid ferry
#

excellent thank you so much

woven lava
#

Hi i tried the ui builder out and in the tutorial they added a ui document to the hierachy but i cant do i still have to add it or how can I add a ui

#

look there is no "UI Toolkit > UI Document"

wicked cairn
#

@sterile wedge this is how it looks

low pike
#

your text isn't a child of the canvas..

wicked cairn
#

umm in the scene it is

#

but thats not whats the trouble the text works

#

the button doesnt

#

@low pike

sterile wedge
low pike
#

"Doesn't work" is vague

wicked cairn
#

it doesnt appear or doesnt do anything when clicked

#

at the spot i mean

low pike
#

so it's not a problem with the prefab, by the looks of it.. it's however it's setup/positioned in the scene

#

doesn't appear -> either game object is disabled or positioned off canvas
doesn't click -> there's something blocking it or you don't have an event system

wicked cairn
#

might help u this is when I double click it

#

where do u get event system?

low pike
#

event system is on its own gameobject - check the hierarchy.. if you cant see one, add one

#

probably easiest/ best to just type "event system" into the hierarchy search

wicked cairn
#

oh I have it now

low pike
#

isn't 0.45 is less than half a pixel?

wicked cairn
#

does that matter?

low pike
#

if it IS less than half a pixel.. do you think it would be visible?

wicked cairn
#

yes

#

but wait I tried removing the canvas in the prefab

low pike
#

half a pixel would not be visible

wicked cairn
#

and the button appeared I did this before but they wouldnt appear but now they work cos u told me to add event system

#

so now it works

#

but wait how do I make it show on top of other things?

#

oh I had to add material

low pike
#

add a material to what?

wicked cairn
#

no it didnt work

#

how do u layer buttons?

#

the button is on top of my text

low pike
#

the order of the hierarchy matters

wicked cairn
#

ohhhh

#

ok

#

another problem now when I try to click the button it doesnt work bc of the text being on top of it

#

btw ty so far

low pike
#

because the text isn't a child of the button (like usual), the click events don't get passed up to the button

#

turn off raycasting on the text

#

it's under extra settings

wicked cairn
#

it works perfectly now ty so much

low pike
wicked cairn
#

yeah thanks I dont use UI that often

rapid ferry
#

when i add vertical layout group my ui contents are mixing up!! what to do?

#

it was like this before adding vertical layout bar

low pike
#

you need to group them first

#

the layout group is going to affect everything that's a direct child below it

rapid ferry
low pike
rapid ferry
silk sierra
#

Hi guys! May I ask, I want to make this picture bigger, but I can't do it without making the border bigger as well. Is there any way I can do it while the square white boarder stays the same? Thanks!!

#

(picture meaning the button)

silk sierra
#

it works with ui images as well?

#

thanks!

#

ill check it out

mortal robin
#

Oh and SpriteRenderer too

silk sierra
# mortal robin that's the main thing it works for

sorry for asking again but I think I am not doing this properly. I am guessing, that when you go to sprite editor and you put the borders around your image, then when you insert the picture, the borders will be around it correct? Well for some reason they are still not around it which sucks. But even if thats not the case, I guess what I have to use is the sliced mode, so I can make the picture bigger. But still it also makes the boarder bigger. Im sure im dumb and its something really obvious, but I cant see it so again sorry for sending a message

mortal robin
#

you have to use sliced mode, yes

#

how are you making the image bigger

#

you should be using the anchors and such

#

not using Scale

silk sierra
#

anchors are changed with the rect tool right?

mortal robin
#

they can be yes

#

that doesn't change the anchors it changes the offsets from the anchors

#

which is fine

silk sierra
#

yeah im using the rect tool and it makes the boarder and the picture bigger as well

#

ill do it from the start maybe I didnt do something correctly

mortal robin
#

You set up the borders in the sprite editor?

#

Like this?

#

And saved/applied everything?

silk sierra
#

You know what the problem was? I am guessing at least. Because the pictures pixels were 3k*3k, when it was so small they were scaling together. But when it reaches that size, the boarder sticks to the image and when you make it bigger it works as intended. Thankfully that's all I need right now so it works. Thank you so much for your time!! <33

crisp oxide
#

Hey there got a probleme where my UI image show itself only in scene view and not in game view

crisp oxide
#

After further investigation, it looks like HDRP does not support custom UI shader on Screen Space overlay

near folio
#

Is it possible to import the same image file twice, using different import settings, without needing to duplicate the file itself?

I have a custom cursor, but I need to use it both as a custom cursor and in an Image in the UI (the latter is used if the player is using a gamepad rather than a mouse). Using Texture Type โ€œSpriteโ€ works for the UI Image, but it causes Cursor.SetCursor() to generate a warning. Texture Type โ€œCursorโ€ fixes the warning, but now the UI Image can no longer use the texture.

low bone
#

Hey guys. How would I go and make some Pre Combat scene like this one? See that when you change from the Armory to the World Map they are different 3D models involved and there is not loading extra scenes.

#

I was thinking putting everything inside 1 scene and place it in different locations with different cameras? And then you activate the camera you need?

#

What is a good approach to this?

crisp oxide
low bone
#

@crisp oxide hi, thanks for the answer, when I said multiple scenes I meant, loading and unloading... this could be some additive stuff for sure, but for the mechanic of switching menus I assume everything is already loaded

#

Is there a better way of achieving this than putting everything far away and switching cameras? Never had to deal with something like this

#

Was looking around and found nothing

crisp oxide
#

Another approach would be a single camera and put everything under a different empty gameobject at the same place. Then you just activate and deactivate the gameobjects to switch your scene.

#

I would go for this one

low bone
#

I see, yes that's another way

#

I like that also

flat violet
#

Guys

#

I have

#

and this sprite

#

I want to do :

#

How can I do?

mortal robin
#

you need the white part at the top of this to be transparent

flat violet
#

oh ok

#

and?

mortal robin
#

and then you just overlay them?

buoyant ravine
#

Anyone has any experience using scroll rects in code, I have a scroll rect that we have set up to display items for a storage, and we have a custom navigation tool created for navigating menus and whatnot. And the scroll rect is set up like so and expands and works as intended. However, When navigating the menu using this code https://hatebin.com/bikqipsinp It does work when using this value for specific resolutions, but on changing the resolution it loses value, and it's likely because we have a scalar on our canvas to scale with screen size, matching x and y with a 0.5 value.

I know I likely need to determine the resolution and figure out some special mathematical calculation to do, how would I go about finding that information? I've messed around with it for awhile but no luck

flat violet
azure flame
rapid ferry
#

question about UI... I made my UI and it is working but I am not sure how I will make it deal with changing the resolution... any idea or help on the topic?

quasi glacier
#

If I set "default is native resolution" to true in build settings, does it perfectly scale the game to whatever size? I know if I set a resolution that is smaller than my screen like 1280x720, the screen gets blurry when I fullscreen. I'm wondering if this still happens if I do default is native

rapid ferry
#

question about scrol views... I want the content to change its size when a prefab (prefab is instantiated into it) .. because my problem is that I can't scroll through it correctly unless its size matches the number of the objects I have parented to it (it has a vertical layout)

#

any help on what I should do to fix it

rapid ferry
#

so far I have managed to make the size of the content change.. but i am not sure how good it will work on a different resolution .. so I am still open to any suggestions on how I can change the size of the content game objects in the scrol view...

second.. when I change what button I am picking in the content, if I go out of the currently seen range of the view , the scro;l bar doesn't follow... how do I change that please

rain knoll
#

What's a good way of storing text for UI elements? Having the text in a script feels... weird.

#

Or like dialogue and such.

#

Is ScriptableObject the way to go when the text isn't Game of Thrones length?

mortal robin
#

Sure that, or a field on a MonoBehaviour. Or in a file, or in a database. Up to you really

#

localization files are a thing too ๐Ÿ˜›

azure flame
#

Scriptable objects are perfect when you need them to have additional logic together with holding dialogue data, otherwise keeping it in Json would be just fine.

neat steppe
#

Is there a way to render ui elements behind world objects using the Screen Overlay canvas?

#

I have a script that will keep a marker above an object when the canvas is in screen overlay, but changing it to world space or screen camera messes up the position of the marker. It no longer stays above the object

trim bear
#

hey ive made a canvas but in order to add a button in thee corner of my screen i have to move the button outside the canvas is this normal?

#

i have to do an afk ill be right back

#

....

trim bear
#

cancel that i solved it

hollow cape
#

Hello everyone can someone tell me if it is Possible to make a sprite renderer appear On The UI canvas while its not under the Main Camera ?

chrome kettle
hollow cape
chrome kettle
hollow cape
mortal robin
hollow cape
hollow cape
# mortal robin of course

Ok thx im gonna try that (i tried to use an animator i made for a spride renderer on an image but it did not work ) im gonna try again !

jade crater
#

the canvas doesn't scale with the camera

chrome kettle
jade crater
chrome kettle
#

You could use the Canvas Scaler if it was screen space

jade crater
#

i needed it like that for a specific transition, but i worked around it by moving all the menus inside the canvas

#

its screen space now

#

but its still kinda off

chrome kettle
jade crater
#

does it have to be Scale with screen size?

chrome kettle
#

I don't know what your intended result is

jade crater
#

i just want the UI to scale with all resolutions

#

so the buttons dont go on top of each other

chrome kettle
#

So why not scale with screen size

#

There's options in Canvas Scaler, and you also have the option of using anchor points
Experiment

jade crater
#

yes i have those correctly

#

when the resolution was 100x100 it was all over the place

#

so i made it 1920 x 1080 and now its alright

chrome kettle
#

Prioritize resolutions that your users' devices will likely have

marsh cliff
#

How bad does this look? I was able to reduce re draws by 6 just by making sure ui elements don't overlap

marsh cliff
#

I was reading somewhere that text mesh pro is better on performance. I just havent switched over yet

jade crater
#

instead of the normal unity pixelated text

#

and gives you more accessibility

marsh cliff
#

Not stressing over the look yet. Trying to make sure it preforms great on a variety of devices. Yeah TMP is insanely flexible

ornate mesa
#

Is there any ready-to-use asset that provides dropdown UI element with searchbar?

#

something like this

summer trout
#

Hello I've just begun learning UI and have a query about the sizing of the UI in the game/scene view and in the actual game- they seem to be inconsistent

#

I added 3 buttons and an image just for an example, here is the game preview:

#

however when I maximise the game screen on play, the UI stays the same size.

mortal robin
untold meteor
#

Hi! I just need a bit of help for the inputfield, I want the placeholder text "//" to stay and be unable to be deleted when I type and not disappear like it normally does-- for example:

// text

is there a setting or script for this?

jade crater
#

there is some ways around it

untold meteor
rapid ferry
#

question... when I get the available resolutions of my screen, to put it in a dropdown .. I get each of the resolutions a couple of times.. why is that happening? does anyone have a clue?

digital heron
#

i want to make chess.I grabbed this chess board from google , made a canvas , made an ui image , and assigned its source image to the board

#

but it looks like this

#

how would i make it a square?

mortal robin
#

use simple, and there should be a "preserve aspect" box

vestal nest
chrome kettle
low pike
chrome kettle
low pike
#

He's got it set to sliced, it doesn't have the preserved aspect option

#

It does need cropping though, you're right. Expanding the image, I couldn't tell there was wasted space around it until putting it in PS

signal tinsel
#

Not sure if I am being an idiot here, but I am wanting to have some cards in my game, much like common card games where you have some in your hand. The thing is I wanted the cards to be 3d so you can turn them round etc, and historically ive only done 2d UI style things, so is there any gotchas with doing 3d uis? as I basically want a 3d object and then put UI elements on it like text/images etc, any best practices/gotchas?

low pike
#

Always have the scale set to 1,1,1 on everything, but have a parent transform that you set the requried scale on

#

ScalarTransform - > scaled at say 0.002, 0.002, 0.002
|- Canvas -> set to world
|-- everything else

simple olive
#

From the 2019 Unite video about UIElements the speaker says, for ListView, to populate it, he just needs to call it the right thing here https://www.youtube.com/watch?v=t4tfgI1XvGs&t=1650s

How does this work? How do I populate my listview with buttons?
YouTube
Unity
Building UI for games with the new UI Builder - Unite Copenhagen

A single, unified, UI editing tool in Unity โ€“ that's our goal for UIElements. In this session, we cover what's available now, share what we're working on, and give a glimpse of what's coming in the future. Learn about UIElements for runtime, new UI authoring workflows, and how we're building the tools to benefit artists and creators.

Speaker:
...

โ–ถ Play video
rapid ferry
#

question in buttons... I want a button that has a picture instead of a text, the button has an image component, I put my picture in the image component BUT IT IS NOT SHOWING ... do I have to add another game object and give it a sprite component or what?

low pike
#

nope, just add the sprite to the source image on the button.. and it should show

simple olive
#

Is it posible to do something like map pins using UIToolkit?

orchid flicker
simple olive
simple olive
#

For pins on a map, is it better to spawn game objects to the corresponding world position, or to use UIToolkit & create the element & find the correct screenspace?

All pins are 2d.

surreal oxide
#

hi all,
i'm trying to create a grid snapping system for UI objects i'm creating. i'm doing it by Mathf.rounding their position. Since an objects position is based on its center, my objects never line up. is their a way to base their position on the far left of the object?

mortal robin
#

You can change the pivot in the rect transform

surreal oxide
#

i changed the pivot and it didn't seem to make a difference

#

all the objects are children if that makes a difference?

surreal oxide
#

to expand: i have a system that creates x amount of buttons for the user. if there is 0 spacing between buttons i have no issues. it seems that creating space between each button makes the widths variable and then they stop lining up correctly

late hedge
#

how do i add a .ttf font to my UI? when ever i apply the font my text disappears

echo cape
#

I downloaded a ttf font and I'm trying to change it in stylesheet:

-unity-font: resource('Assets/Resources/Fonts/Coda-Regular.ttf');

that doesn't seem to work, is there an extra step I'm missing?

#

I can see it defined in the UI Builder but the font appearance doesn't change:

last monolith
#

Guys, I need help, I have a multiple canvas system in my game and there are also buttons in these canvases, how should I make it so that I can navigate with a controller (I'm using the new Input System) the buttons even if they are in different canvases?

median iris
#

Not sure, but I think you'd have to program it yourself
You could create a simple component that holds references to the things you want to navigate to on left/right/top/bottom

last monolith
#

Thanks, I thought I could do it without code

median iris
#

You definitely can within a single canvas, but idk how the situation is when navigating between childs of different canvas objects

#

Very much possible that I'm wrong and there is an easier way for your situation, did you look it up on Google?

worthy karma
#

guys how to apply png to a button?

#

๐Ÿ‘‰๐Ÿผ ๐Ÿ‘ˆ๐Ÿผ

median iris
#

You have to import it into unity (drag it into your project window), make sure it's a Sprite in the import settings, and then you should be able to assign that sprite to the image component of your button
But you should Google simple questions like that before asking them here

worthy karma
#

let it try

#

lmao how could I know I am not even aware of difference between png and a sprite

#

but ok

#

nvm thanks

median iris
#

You're welcome ๐Ÿ‘

chrome kettle
worthy karma
#

hm

#

yes I've made this UI thx to your advice

#

icons are self made btw

small ether
#

looks great

#

so i have this stamina wheel type thing, but I want it to be a much higher resolution, do I need to find higher resolution images or is there another method

chrome kettle
small ether
#

its an image i downloaded from google

chrome kettle
#

The resolution judging from that image seems fine, rather it seems to have no filtering or mipmaps

small ether
#

idk what that is lol

#

how do i add that

chrome kettle
#

Can you show the import settings

small ether
#

import settings?

chrome kettle
#

Import settings of the image asset

small ether
#

oh yeh one sec

#

this?

chrome kettle
#

Enable "generate Mip Maps"
See if that helps

small ether
#

okey dokey

#

will that drain on the gpu

#

like in runtime

chrome kettle
#

No

small ether
#

kk

#

which settings do I select under mipmaps

chrome kettle
#

Does it suggest anything by default

small ether
#

no but dont worry Ive figured it out

#

it works thanks

chrome kettle
#

๐Ÿ‘

small ether
#

final quick question, where do you think I should place this wheel? Its like the ammo charge level for the gun

chrome kettle
small ether
#

i did try that but i felt like it blocked the view of enemies

#

i need to add a healthbar too

#

i looked at the one in breath of the wild which is in the middle with an offcentre but I feel it would look weird

last monolith
sullen stratus
#

How do I make a UI element always automatically stretch to fill the screen

sullen stratus
#

Ah, it wasn't working earlier but now it does for some reason

#

Thx anyway

jade fern
mellow flare
#

does anyone know why my canvas doesn't allow me to press buttons or use input fields?
I have a graphic raycaster

mortal robin
mellow flare
trim hollow
#

I have a sprite but i cant see it on the camera how can i fix this?

chrome kettle
trim hollow
#

I fixed it already ty

upper narwhal
warm canyon
#

Not sure if this is the right channel to ask, but I have a font Sprite sheet (.png) and i'm trying to figure out if I can convert it into an actual .ttf file

#

Anyone know how I could go about doing this ?

low pike
#

never done it before.. but I don't imagine you'll get good results..easily. Aren't fonts vectors? PNG's aren't.. so converting a png to a vector is going to result in... imperfections

warm canyon
#

Well yes, found a nice font on itch.io that I wanted to use but the person who published it published as a .png file

chrome kettle
#

Text Mesh Pro converts fonts from vectors into signed distance fields
It can't do that with pngs as well?

warm canyon
#

Couldn't figure out how to do it, I'll look around a bit more

chrome kettle
low pike
#

The 'Font Asset Creator' for TMP wants a font file

chrome kettle
#

...possibly
the dev there constantly goes back to talking about importing ttf files so I'm not even sure it actually concerns bitmaps

warm canyon
#

I think it's not worth my time to even continue looking for a solution to this

#

Might as well just find another similar font

chrome kettle
#

Certainly

low pike
#

there are websites that allow you to upload an image, it'll scan it and tell you what the font is /suggest similar

chrome kettle
#

There probably are similar services that let you create font files from images

#

Who knows how they work with pixel perfect fonts though

dim surge
#

does anyone know why my screen space canvas works in play mode, but not in a standalone build?

dim surge
#

hang on the screen space canvas isnt the issue

#

i have a screen space canvas in my scene, and theres a background image with an aspect ratio fitter

#

but the background image doesnt appear in a build

#

the issue is the aspect ratio fitter

#

i removed it and it appears, but i still dont know why i cant use that

mortal robin
#

try setting your game window in the editor to the resolution of your target hardware

#

see if you can reproduce the issue

dim surge
#

i tried that and also changing the player to/from fullscreen and the issue always appears in the build and never in the editor

#

i tried changing the sprite to one that does appear properly and the issue wasnt the sprite itself

#

something with the aspect ratio fitter

minor pumice
#

I'm creating a companion app for a game and one of the things I want to do for it is to have an interactive map of the game world. I know the game was made with Unity. I've been trying to figure out a way to export the 2D maps of each world (the maps in-game are 2D but the game is top-down 3D). Other people must have figured out how to do it because there are maps online but I don't just want to rip someone else's map. Is this possible and how would I go about it? I've tried downloading a few Unity asset explorer type applications and so far all I've been able to export is texture maps for 3D models which isn't what I'm looking for.

mortal robin
lofty holly
#

I'm trying to implement UI item dragging using OnDrag() but the problem is that when my image is in "dragging state" it is invisible. My code and settings:

toxic mulch
#

hi guys I have a problem why is the back button overlayed with the quit button

#

i have made a script but it doesnt seem to work

#

why isnt it working

lofty holly
#

Maybe void Start, capital S ?

mortal robin
#

Also that yeah ^ Start needs to be capitalized

toxic mulch
#

okay well that sorta fixed the problem

#

however

#

how when I click the options button the back button is now gone

lofty holly
#

Can we see that other script?

#

I guess another script is handling button press

toxic mulch
#

there is the main menu script

#

theres the options script

lofty holly
#

What happens when you click "options" button, do you switch scenes?

toxic mulch
#

the guys is saying to add the option script to the option menu unless im wrong

#

a couple problems

#

the text is still there and when I go to the options menu and press the back button it works but then I go back into the options menu and the back button is gone

lofty holly
#

One question, do you switch scenes when you click options button or are you using different approach (for example enable/disable buttons)?

toxic mulch
#

im using a diffent approach

#

on click

dim surge
#

Does anyone know how to make a rectTransform do this through code? (basically make it stretch to fit the parent)

dim surge
#

ah i got it

#
            rectTrans.offsetMax = Vector2.one;```
#

this did it

sharp ravine
#

How do I anchor my UI to the bottom of screen (or any side for that matter) so it adjusts depending on the device? I am setting the anchor and using the simulator but it doesn't keep within the size adjustments?

#

Nvm I had the UI under a panel and needed to set the panel to Stretch...

rapid ferry
#

ui element following the object. how can i do this ui?

low pike
#

either world space or WorldToScreen

signal tinsel
#

The churn is too much in main chat

#

is there any scenarios where a TMP text element would only have a really thin thickness even though you have like 70% ratio

#

i.e SP 46, Padding 32... thats over 60% ratio and I still get super thin lines like

undone sandal
mortal robin
undone sandal
obsidian crag
obsidian crag
undone sandal
#

@obsidian crag Yeah I had those settings and it still doesn't work

obsidian crag
#

it is probably an issue with the anchoring, since 1440x2960 and 9x16 are different aspect ratios.

#

You can do its anchor at the middle right (like it is), but I recommend setting the pivot to X 0 Y 0.5

#

This way when animating you just need to put it X position to be its Width (but negative)

#

Also, the width of the object seems to be not adapting to the aspect ratio, making it thinner on 16:9

#

and not filling the entire screen

undone sandal
obsidian crag
#

Pointing it out would be easier than describing, sorry if it seems confusing haha

undone sandal
#

hmm i'll figure it out tomorrow thanks for the help @obsidian crag

obsidian crag
#

Decided to make a quick video about it running on 3 different Aspect Ratios with the same animation clip. Hope it helps. Also no need to adjust on runtime*

lavish stump
#

What are the reasons why UI wont show up in the Scene & Game view?

undone sandal
lavish stump
#

Never mind I found the cause of the problem, my hand must of hit a key and zeroed out my UI's scale...

signal tinsel
#

So I wasn't sure if there was another issue causing it to not act like it should.

#

here are some settings I was messing with to get the image I showed before

#

So there should be more than enough padding to get a decent outline

signal tinsel
#

also for some reason when I go to play mode and show the element containing the text it looks awful

#

Looks fine in scene though

signal tinsel
#

oh fixed it, I needed to set it from SMOOTH to SDF

signal tinsel
#

Are there any good approaches to managing prefabs that contain UI elements but dont contain a canvas? i.e to reduce draw calls there is a single canvas which contains all instances of the prefab so there is a containing canvas, but at prefab level it doesnt have a canvas, so its difficult to actually do anything in isolation

signal tinsel
#

I assume you would need some form of translater right? in most cases you have a localisation database and translate them manually, unless this is some sort of puzzle game and you just want to change one character to another

#

oh in that case it would just be string replacement

#

unless you wanted it animated in some way

#

simplest would be just get the text element that contains your stuff and just do a string replace of each character or position

low pike
#

that's not a problem, and isn't relevant to the question

signal tinsel
#

Anyone have any experience with trying to put UI elements over gameobjects heads? I assumed it would be a simple world to viewport style calculation, but I am using URP and have layered cameras and it doesnt seem to work as expected. i.e one camera for game objects in the world (in-game) one camera overlayed for just UI elements

obsidian crag
#

If might generate some more extra draw calls for each Canvas, I dont remember if they are on the same Sorting Layer they are batched.

signal tinsel
#

I did think about using a world space thing, but problem is the cameras may change slightly, i.e there is a top down and a chase style cam, and I would need to rotate the UI bits to simulate a billboard style approach between 2 cams

#

so it felt simpler to have a camera/screen canvas wrapping them and just have it get the world position and show it on screen/camera so you avoid the needing to make it always face the camera

obsidian crag
#

Well, you can simply attach a script "LookAt(CameraPosition)" on the Canvas, like some old sprites games do

#

And they will act as a billboard

signal tinsel
#

oh right I didnt know you could do that

#

I will keep that as a backup

#

but I assume there should be a way to do it via a camera/screen approach right? as I can see them moving about on the canvas but it seems to be really far off the screen

#

I assume if it was one camera it would be fine, but as its multiple they just have no idea whats going on

obsidian crag
signal tinsel
#

yeah its just not displaying as expected, but I dont really know which camera I should be using tbh, I assume I should be doing world to viewport on the in game cam

#

but as its rendering on another cam (to avoid post processing and other stuff)

#

So I can see they are shown on there and seem to have been moved around

#

but then the in game camera is like that

#

so as you can see the top picture has the camera (selected object) not showing the elements correclty but not sure where it all is going awry, I assume its because there are 2 cameras at different positions

#

but unsure

obsidian crag
#

These icons were supposed to draw above the characters right? If so, it makes sense to have the 2 cameras at the same position. Since you get the character position to update the icons.
The UI Camera one should have a higher Depth and on Clear Flags you can use a Depth Only (to avoid clearing what the 3D Camera draw)

signal tinsel
#

they unfortunatley live in different scenes ๐Ÿ˜ฆ

#

I can make a script to make the cameras mimic the same position

#

(oh and yes they were meant to draw on the char, not fussed atm if its on their head, as long as its roughly where they are, as they will need resizing and other stuff)

#

(also worth noting in URP you only have a base and overlay camera, there is no specifics to Clear flags etc)

obsidian crag
#

Ah yeah URP, forgot about that part hauauh

#

I was looking at my built-in project as a parameter guide :p

signal tinsel
#

I have botched it to make the camera a child of the existing camera, so its in exactly the same position but the stuff is still drawn on the canvas miles away, but not sure how it translates that to camera view

#
public void SetUnit(Unit unit, Camera gameCamera, Camera hudCamera, Canvas canvas)
{
    _gameCamera = gameCamera;
    _hudCamera = hudCamera;
    _canvas = canvas;
    // other stuff
    
    _canvasTransform = _canvas.GetComponent<RectTransform>();
    _canvasOffset = new Vector2(_canvasTransform.sizeDelta.x / 2f, _canvasTransform.sizeDelta.y / 2f);
}

private void Update()
{
    // Unit Transform Cache is a handle to the GO transform
    if(UnitTransformCache == null) { return; }

    var viewportPosition = _hudCamera.WorldToViewportPoint(UnitTransformCache.position);
    var proportionalPosition = new Vector2(viewportPosition.x * _canvasTransform.sizeDelta.x, viewportPosition.y * _canvasTransform.sizeDelta.y);
    _localTransform.position  = proportionalPosition - _canvasOffset;
}
#

That is basically the logic atm

#

incase you see anything awry, its based off someone on the unity forum

#

oh I htink I may have solved it ๐Ÿ˜„

#

ok so one extra bit of info was that the prefabs seemed to have their own canvas, so removing that seems to fix it, as tbh I dont know why they needed it as they are all under a root one anyway

#

oh well it works as long as its in the same location as the game cam, if its at another location it doesnt, but thats something new I can work with

#

thanks for your help Alan

rapid ferry
#

Hey everyone, Im doing a side project and was wondering if anyone knows a way for me to have the same resolution on all phones ( I don't want to deal with anchoring shit ), what I want is my game to always be in 1080x1920, but if a phone is smaller or bigger the size of 1080x1920 proportionally gets scaled up or down

copper shard
#

my button hitboxes are super weird

#

is there any way to adjust them

mortal robin
mortal robin
pliant turret
#

yo guys i designed a UI thingy in blender

#

how do i get this to work in unity? i've been completely and utterly failing for the past 2 days with zero clue how to find answers for the tiniest issue

#

i tried googling or reading documentation or tutorials and nothing is working... i feel stupid

low pike
rapid ferry
#

Hi Guys, i have following question: I have a Canvas with Screen Space - Camera and i want to have a rect transform from another canvas with Screen Space Overlay to be on the same position as an other element in the Screen Space Camera Canvas. How convert screen space camera rect transform position to screen Space overlay position?

ashen basin
#

how do i change the colour of the text of a button instead of making the entire button highlighted

#

like