#📲┃ui-ux
1 messages · Page 37 of 1
ok tysm
i want to make a bitmap font for use with tmp and i have a .fnt file (text based) and the atlas png. i also have an XML version if that's better. How do I create the font? I'm stuck and trying to right click on the .fnt file to create a tmp bitmap font asset but nothing happens
hey chat, how can i make this better
why is the text black?
Maybe you have no lights in the scene?
Note you're not using the UI version
i was told to go here for it so yeah
The 3d text uses a lit material by default afaik
Why would you post this in a channel that's not related to 3d ?
Besides, this server doesn't allow job posts. see below
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
when i make the scale of Goals (circles) 1 then it looks like at photo 1 like i want. and when i want to make scale 0.1 of circles, i have to make the cell size of gridlayout X from 3 to 30 but now Arranged vertically (downwards) what i dont want and when i add another circle which the size is bigger then there is a problem because it looks like shit can someone help me?
you usually don't (shouldn't?) scale ui components iirc?
wdym irrc?
what should i do then?
"if i recall correctly"
you would adjust the height/width
you might need intermediate objects to work with the grid
im not super versed in UI stuff so i couldn't tell you what exactly you'd need to do, sorry
ty for your help ^^
Hey erm i am extremely new to Unity UI and I have a question
so I have this Panel in a canvas
my panel has a FFFFFF set as its colour
Transparency is 0 as well
and yet it looks gray
I changed Rendermode to Overlay as well
iirc the default image it uses isn't pure white
you can change what the image is tho, the bits in the create menu aren't set in stone components - they're just templates
you can yeah or there might be one included in ugui
Oh i just changed my sprite to none
that fixed it
Thanks for the help!
This was erm interesting
i recommend you make prefabs for it so you can change it project-wide, it'll save you a headache later on
Hey, i tried to do something with layout groups, and content size fitter), I want the three white square to be in the middle of the purple square. However with a vertical layout group on the purple rectangle, and i increase the padding of it, it increases the size of the purple rectangle, i don't know how to fix that
ok so like I just generated a font using the Font asset manager thing and when i scroll out the text has this werid gray ackground thing which disappears when i come closer
Ah nvm fixed it had to change the shader
ok how do I fix this though
cannnot find the alias related features
Are you using legacy Text or TextMeshPro
TextMesh Pro
I have 3 Images for my pumpkin's mouth, eyes and nose. I also have an image for the inside of the pumpkin that I want the mouth eyes and nose to show. I know outside of UI you can do it but I'm not entirely sure about how possible it is in UI.
you would use masks
yeah but I don't want to see if there's an alternative from having 3 different pumpkin insides or setting up sprites for each different variation of pumpkin
what do you mean? you obviously need to have 3 different images for the insides if you want it to have 3 different insides
I only need one inside I want to remove them. But I ended up making a custom reverse mask by combining the 3 textures and removing it from the base image and allowing the inside to show
You could do this pretty easily with a shader that essentially takes the shape from one texture and the colors from another
how do i make a font out of a sprite sheet? I've tried every tutorial I can find, and caligraphr is not an option as i need around 115 characters.
im on unity 6
dont understand what im doing wrong here
also I absolutely need to use png because its a handwritten font, and I want to keep that texture, it wouldnt rasterise well + would take too much time to manually trace.
biting the bullet and vectorising every single character, but now it does this
I mean if the font isn't supposed to look cracked. Whoops, but does look cool on its own.
- you should ideally use TMP text instead of the old legacy text.
- with tmp text you can choose not to use SDF which will look like legacy text again
Why is making Blur UI this difficult. There should be an inbuilt feature to make it blur just like apple ui. It should be ameture friendly atleast...!
UITK has no such option provided and still doesn't support custom shaders yet (to my knowledge).
There was an old unity example project that had a UGUI blur shader. However there is this third party package that you can use instead
https://github.com/lukakldiashvili/Unified-Universal-Blur
Thanks buddy. I have used some paid and some open source packages for blur ui. But Having an inbuilt features is more convenient for newbies than configuring an external package. Hoping that official unity team could add this in URP. Just a toggle to enable blur ui.
I'm using an image as a cursor for a project and am manually setting the position of the rect-transform to the position of the mouse minus a hotspot/offset Vector2, however depending on the scale of the play-window (in editor), the image is set to a different position for some reason.
I'm using Unity 6000.2.7f2. My canvas scaler is set to Scale With Screen Size at 0.5 Match. The image has a pivot of (0, 1) (top left corner), and the anchor doesn't seem to change anything.
My code:
CursorImage.rectTransform.position = mousePosition - cursorOffset;
The attached image is an example with the top being the smallest play-window and bottom the biggest, the blue box is the cursor's actual position (in this case the cursor is suppose to be in the centre of the image).
Anyone have any clue what's going on here or how I can remedy this?
transform.position (which is what you're using here) does different things depending on the Canvas render mode
generally you shouldn't be touching it for UI stuff
directly getting at screen space coordinates can be tricky
You want something like:
public static void SetRectTransformAtScreenPoint(
RectTransform rect,
Vector2 screenPosition,
Camera canvasCamera = null // null for Screen Space - Overlay
) {
RectTransformUtility.ScreenPointToLocalPointInRectangle(
rect.parent as RectTransform, // convert into the PARENT rect space
screenPosition,
canvasCamera,
out Vector2 localPoint
);
rect.anchoredPosition = localPoint;
}
While this is helpful, even with this, the offset is still changing based on the play-window size. I think the cursorOffset is somehow not scaling properly with the parent RectTransform.
lets say i have an UI here, where the part circled can be zoomed in on phone
how can i do that?
to be more exact, i want to do something like this
- only the blue zone can be zoomed, other part cannot
- grid will not show anything when far apart
- each grid will show detail if zoomed enough
Hey, i have a lot of slots in my UI, and i have multiple slots, which have a script that implements IPointerClickHandler.
The method is the following :
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("test");
if (currentItem == null)
return;
Debug.Log("we have this item " + currentItem.itemNameLocalization);
}
If i click on a random slot, it says "test" and the item in it, but if i click again, or i click on an another slot, the methods is not called.. Does anyone have an idea ?
Make sure you don't have Collapse enabled in your console window
you may also want to print something when currentItem is null
I don 't have collapse, but the "test" print must be printed in any case, right ?
Yes - assuming you have set up the scene properly. I asked about collapse because it could make it seem like it's not being printed
Check your event system - you may have some object(s) blocking things
By that, u mean check the selected object each frame by the event system ?
i mean check the event system in the inspector to start with and see if it shows you which object you are mousing over and whether that meets your expectations
you can also do a manual RaycastAll with the EventSystem in your code for debugging purposes if it comes to it
and no not the sleected object
the object your mouse is over when you click/release
It's probably because my left click is binded to another action which is not disabled when the canvas is opened ?
And also, i don't know how can i see in the inspector, my event system is only showing the first selected, and some values, but not the one I expect
I tried to figure it out because the empty slots when i click on them, there is the "test" in the console log. However, when there's an item, it's not working at all. Currently, my slot has the white little white dot as parent, which has raycast target set to false, and a child for the sprite image, which has raycast target set to true... I don't know if it explains something
Ok i found... The selection sprite (the 4 yellow arcs) had raycast target set to true, my bad
I don't understand, how does the image for the fill in slider works? I already cut it into 9 pieces so that it won't stretch out
i don't think you're supposed to slice the texture2d for a sliced rendering type, those are different kinds of slicing
I realized my mistake late...
Hi is there anyway i can move a small section of the maps with all the layers at one go?
As in i want to move a specific section but the move tiles only does it layer by layer
Or what maps? Maybe describe what your "map" consists of and what defines ab"section"?
Also is this s UI question?
Let's say i have a house. There's a few layers such as ground, walkinfront etc. I want to move all the tiles at one go instead of 1 layer by layer
I think so? Isn't this a UI thing
No, this channel is for the creation of UI using UGUI
Hey all, does anyone know if there's a way to prevent canvases from sitting over each other when they get created, in the scene view only, or is hiding the above canvas the only real option? Behaviour wise I'm thinking like Photoshop Artboards.
This looks like your game world, not UI.
If you actually mean to edit the tilemaps then you can ask in #🖼️┃2d-tools .
If you want to just move the whole Tilemap, you can put all the objects under a shared parent and move that
Okayy thanks
no you can't move a screenspace overlay canvas
Make them prefabs so you can edit them in isolation easier
Cheers Rob, I am but for really complicated scenes with cameras, 3D on too of UI etc it’s not always possible to get that final context without the canvases all sporadic and overlapping.
do you need multiple canvases? do they all need to be in the scene from the start? anyway you can hide the others with the scene visibility controls or do like I suggested
is there a way to put a game object over ui objects?
Use a screen space camera canvas and set the plane distance farther away than the game world GameObject
thank you for the advice,
for future people reading i guess.. i ended up getting help from a teammate and changed my game object to a 2d image and used a script for having it follow the mouse
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ImageFollowCursor : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
// Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
transform.position = Input.mousePosition;
}
}
Hi guys, I don't know if it's here that I should write.
It's been a long time that I don't create on Unity. I use Unity 6 (6000.2.6f2), for a mobile game.
I heard about UI toolkit, but sometimes I like it, sometimes it's pain of ass...
For example I tried to create a Pannel with a list view of players. Take me few times to understand it, it works.
Items generated by Unity are grayed out. So, I thought like website I needed to search or create class or ID to change them.
I found the class .unity-scroller and in my UXML, I want to disabled it. So in my custom USS I added this class, and change the value of display. I launch the game to test it, wrong, I still see it.
Edit : i'm dumb, I forgot to save my USS, and I change the display & visibility, it's work now. But I still ask the question, because it's interesting to see how you works
So I'm here to talk about the UI today, should I use the UI Toolkit because it will be the future, or should I use the "old system" and maybe need to recreate all of my game in the future (because it will be mostly a UI based game).
Thanks in advance ❤️
If you want to use UGUI then just use it. Nobody's going to come and take it away in the middle of you working on the game.
Tbh, I'm not a good at create game, it's just a hobby and UI it pain of ass for me. So it's why I asked to see how guys you works, UI toolkit seems to be cool for responsive. But harder to find some ressource for me to learn. Btw thanks for your reply.
#🧰┃ui-toolkit will hav pinned msgs to things that will help
Thanks I'll stay in alert to see the content in there
wot the hell, is this how it's supposed to work?
yes
you've presumably placed that ui element at a specific position without using layout options. Changing the reference resolution changes where that specific hardcoded position lies on the screen
Hello i have a question why when i use 2d sprite image in my canva and i click play the image do not appear ?
Sprite renderer is for the game, not UI.
You need to delete that game object and create an image. Right mouse click -> create -> UI -> image
then assign your sprite to the sprite field on the image component
ahh ok thank you man
UI isnt really well suited for gameplay though. You should probably keep the gameboard as a sprite renderer and just position it correctly
how to positiion it correctly ?
put it in front of the camera
ok thank you
Is there a limit to how many canvases you can have on screen before it impacts performance? I ask because of the whole "Everytime a UI Element updates the whole canvas updates"?
the more work being done, the more time it takes. every canvas being dirtied technically impacts perf
the limit is whatever the hardware is
The idea was to have all of the frequently updating canvas bits on 1 canvas, and the stuff that doesn't update often can be on another.
So in a Diablo like game the healthbars / Mana bar / floating damage numbers are on 1 canvas along with cool down indicators, but other elements of the HUD are on another.
I would use UI Toolkit but trying to reason with a sane way to do an inventory is hurting my head right now.
keep in mind there's also stuff like batching draw calls and such...
i'm not super familiar with this stuff tbh, so i can only really give vague guidance
balancing batching and canvas dirtying is a very situational dependent problem to solve afaik
but imo, as with all things perf - just make something that works and makes sense and worry about perf when it becomes an issue
The idea was to have all of the frequently updating canvas bits on 1 canvas, and the stuff that doesn't update often can be on another.
This is the recommended solution
https://unity.com/how-to/unity-ui-optimization-tips
This page also links to a very interesting and informative video about UI optimisation and best practices
though canvas stuff is one of the few things that has wrecked my fps in pretty barebones prototypes, it's easy to be pretty problematic
I'm having a really weird issue with buttons. I have a button of type animation, and when I click on it and move my mouse away, it does not switch to the Normal state properly.
Did you see what is happening in the animator when this happens? Maybe your triggers aren't set up quite right.
Idk what the issue is. But when i click elsewhere, it returns to normal.
Open a tab with the Animator for the button next to the game view and watch what is happening to triggers and transitions to help see what is wrong.
when you click a button, it remains "selected" in the event system.. so it's in the selected state
Ive no idea how to use animator...
it's not the animator, I beelieve
Is there a way for it to not?
Dunno, something for you to google
One way to cheese that is to change the "Selected Trigger" to the same as your "Normal Trigger" in the button transition settings. Most likely you would be changing "Highlighted" to "Normal".
Well, I have an animation for the button when you click it
That should fire with the "Pressed Trigger" still. It's the Selected state that seems to be giving you issues.
Also, why is it if I hover my mouse over or off it, it plays the selected animation at lightspeed?
These are all things to be controlled in the Animator. If you want it to look as good as possible, you'll have to take some time to familiarize yourself with how it works and make adjustments. The generated controller for the buttons with the default words is a good setup to poke around in and see what is happening.
I have every state connected to any state, would that do unusual things?
There are a lot of factors. That on its own isn't a problem.
Im not able to be on my computer until tomorrow. Anyone using buttons, do you have the same issue with the animations?
If so, do you know a fix?
Wait its not just for animation
Its with color changes too
Saw somewhere that i need to disable "Send Navigation Events" on the event system gameobject, or whatever its called. Will that really work?
ok. It didn't really work
had to make a script on the EventSystem
i want to change this label to something like
this
i can't set it to have curved corners
umm dunno what you mean by that but i am editting it from inspector
oh ok
this channel is for ugui, the game object based ui system
oh!!!!
Hey everyone! I’m building a mobile game in landscape mode, and I’ve been thinking a lot about the best Canvas settings for different device layouts.
I’ve seen many people on forums recommend using Canvas Scaler → Scale With Screen Size (1920x1080, Match = 0.5) as the “best” setup. But does it really have to be that way?
My current settings are 1920x1080 with a 0.5 match, and everything looks fine when I preview different iOS layouts in the Game view. However, when I switch to tablet layouts, I start to see some serious overlapping issues.
So my question is: what’s the best approach to make a single build work well on both phones and tablets? Should I focus more on fine-tuning individual UI components (anchors, layout groups, etc.), or is it better to handle these differences via code (e.g., layout adjustments at runtime)?
i want to use a starry background for my 2d spaceship game. any ideas as to how i would be able to make one?
open photoshop and draw some stars i guess?
D: don't have photoshop
then any other photo editor/drawing app
oh wait...i do have photoshop
thing is, i want the stars to you know, move a bit
a static background might not be that immersive....
then draw a single star and instantiate and move a bunch of them in unity
not equipping them with collliders right?
i mean do you need anything to collide with them?
nah
yes
wait a sec
i don't want the stars to somehow move out of the background
but if they were to bounce off of the boundary, that would look weird too...is there a way to somehow loop the animation so that if a star does touch the boundary, it gets destroyed and another star pops up somewhere in the background?
well if it's just a rectangle then you can do a simple bounds check and then delete it if it leaves
how would i respawn it though?
O_O
lemme try that then i guess...i will ask for help again though...rn trying to load up photoshop
yeah but might wanna do it in a different channel next time
like i guess #💻┃code-beginner
this isn't for particles?
well you aren't really doing particles right now are you?
oh no
if you want particles go to #✨┃vfx-and-particles
damn i was there a few moments ago
@alpine goblet if you need UI particle you can use UIParticleSystem.cs from UIExtensions repository it converts particle system into UI particle system
Pray tell, is this where we ask questions, like how to make an HUD (Heads-Up Display)?
I mean, you should have a more specific question than that probably.
How specific exactly? Just making sure.
general questions like that would work better in google
if you then encounter an issue, you'd then ask about that (errors? can't find a menu? doesn't work like the tutorial says?)
Hi, is there a way to crop an image with in unity? I have tried using the filled image type method but I'm looking for something closer to a traditional cropping.
i don't think i will be making 3d stuff so...might not use it rn. but thanks for the option!
i checked it out...it converts 3d ui into 2d if i am not wrong?
You should do cropping outside of Unity.
im using traditional UI, is there any existing new components or classes that can force a Button double click only?
or i need to make one myself
Think you'll have to make it yourself.
mask works but preferably you'll crop it in another program
idk how to make good menus
you can see the one that i made in this video, anyone got any tips?
I decided to make a horror game that exploits YOUR phobias… and instantly broke the main menu.
Welcome to Phobic EP.1, where I try to make a simple menu and end up fighting Unity itself.
Subscribe before my sanity disappears completely.
-LINKS-
Discord: https://discord.gg/9QDjPsE7bQ/
Website: https://pxsl.dev/
TikTok: https://tiktok.com/@...
Look through sites that have lots of game UI images, like this one (https://www.gameuidatabase.com/) or look at similar games you thought had nice UI setups for a similar theme.
If you're just game jamming or something, using a decent font and free button assets in place of the default Unity ones, that can make it adequate for a jam. Otherwise, it will take some research and iteration.
Hey I got 1 last issue For some reason my Textmeshpro button doesnt highlight no matter what (I am using a physics raycaster on the camera but even when removed i get the same results) wondering if anyone had the same issue and Im using 2022.3.19f let me know if this is just an "update and youll be fine" issue
is it supposed to show double?
the worldspace is the one that doesnt highlight
Its just to show that simply changing it is enough to make it not react
it looks like the screenspace one is reacting fine though?
are you trying to get the world one to highlight or what exactly?
Yeah but I NEED the world space one to work
because I have other buttons in the game that use world space
is there perhaps something blocking it?
what if you disable the screenspace canvas, for example
did you try disabling the screenspace canvas
also check if those errors are relevant
Holy crap that worked
Thanks for the help
I think I need to move the canvas back
hmm, it's screenspace, not sure that'd work
yeah I jsut realized that sorry lol
Now the next issue because I do need the screen overlay AND the worldspace ui
not sure about that, then
Thats fine Ill try to just adjust my game so that it ONLY uses worldspace
Hey, I am using a prefab for my settings. The prefab is a bunch of UI elements on a canvas. Since the menu in our game is supposed to be playable the prefab is used too, but on a world space canvas. In the actual game, it is used on a screen space canvas. This forces me to aggressively scale down the prefab on the world canvas, to 0.0025 actually. I think that's the reason why the TMP is having a hard time rendering and is actually a bit fuzzy. Do you have an idea how I can keep the prefab alive? Or do you think the only solution is to create a second prefab that is smaller and works in scale 1?
What is it that you're scaling? The WS canvas or the individual menu objects?
My settings prefab. So in world space its like in the screen shot, in the in-game UI its scale 1. The world space canvas is scale 1, too.
I tried scaling down the canvas instead, still bad quality. Especially when I zoom away the quality really goes bad noticably.
I think in the past, I've had to have the parent scaled similar to what you have (~0.002), but then done some wacky inverse scaling on the text to get it to look right. That was probably all with Unity text, though, but seems like it's acting similarly.
Only the worldspace canvas should have the scale changed, all child elements should have their scales at 1,1,1
Any prefabs you spawn at runtime, need to be spawned with their parent passed in with the params. Do not spawn it with an empty parent then assign a parent, it won't be scaled correctly.
I don't instantiate the settings prefab during runtime.
Right now the world space canvas is scale 1,1,1 and the settings prefab is 0.0025 and looks ugly.
If I scale the world space canvas to 0.0025 and the settings prefab to 1,1,1 it still looks ugly.
leave the worldspace canvas at 0.0025, the prefab at 1,1,1 .. and investigate further
what font size are you using on the TMP's?
Nothing out of the ordinary, I think it's around 32 (I checked it's 36). In the screen overlay canvas everything looks fine.
Its just that I need to scale it down to work in world space and this is where the problem occurs
I always have the canvas at smaller scale and the contents at 1,1,1 like Carwash says. This is how you should do it, or you'd be using a tiny amount of a huge canvas
I agree with all of that, but have had to make an exception for text in the past. Making the font size really large and then scaling the text down as I recall. I kept this funky scaling localized to only the text elements themselves.
I didn't like doing it, but it was the only way I could overcome text blurriness.
In my ~decade of using TMP with worldspace cavnases, I have never had to scale the UI.
worldspace canvas - 0.002 is my goto
everything else - 1,1,1
font - whatever it needs to be
change width/ height where needed
TMP doesn't like font size/ scale < 0.0x (i forget the value exactly)
Curious to see what @misty lagoon figures out as a solution.
This is a super simple example. The prefab just has an empty parent, 2 children - 1 with an image, 1 with TMP. Scale on everything in the prefab is 1,1,1
I don't understand why does my slide move like this????
Isn't supposed to be like.. filling up the bar instead of moving thebar itself?
have you set the image to fill
hm actually, i don't remember if it uses that
Can u show Fill object inspector
for some reason, these particular buttons from my ui shrink to what I assume to be their original size when I load a build of my game. I do not know why they are shrinking as I have set the canvas to scale with screen size. the other buttons are not shrinking, as you can see with the 3 large ones above. If it helps, the 3 small ones are inside of a horizontal layout group because i need them to be that way.
They are presumably not anchored correctly or configured correctly.
Show details of your UI layout if you want a better idea
Inside "Dice" is where the 3 little buttons go.
The "SampleDie" is the prefab for the little buttons
The final image is of a layout group that is inside of the little button (when you hover over it, the HoverPanel appears which has a layout group in it so the tooltip scales properly)
The screenshots are too cropped to easily tell what's really going on here. Which object is that RectTransform inspector for?
it is for the buttons that are little
What you should do is drag your prefab into the scene under Dice and resize the game window a bit
See how it behavres
you can debug this easily in the editor that way
i don't know why but it behaves like it should
i mean the buttons don't turn small
they are small only when i build the game
have you tried resizing the game window while you do this?
(assuming you are on Free Aspect mode)
if you're ona fixed resolution you'll need to either switch to free aspect or switch resolutions to test
i used free aspect mode yes
and did resize a lot
Hello, i can't find any mentions if it's possible to set all new canvases to scale with screen size automatically since i keep forgeting to do so and then all my ui shrink. Does it possible? And also is it possible to scale my old ui back to normal size with new scaling?
for making it automatically do that, you'd want to make a custom menuitem to create a canvas with it set to scale size
for making your old ui stay normal size, you need to set the reference size to be the same as what the size of the canvas was before you changed it to scale with screen size
or if you don't wanna make a custom menu item, you can make the canvas a prefab and add that instead
Thank you, will try it later
Also check out the Preset Manager, though it might not work with the UI context menu items
Will see, thank you
Managed to make new canvases to scale with screen size thru Preset Manager, thank you again. As of restoring ui size, its either not working or i am missing something as "Reference Pixels per" set to 100 as it was on Canvas with default scaling but its not changing scale in any way
you need to look at the actual width and height
in the rect transform
or just set it to something close enough
The canvas scalar component needs changing to 'scale with screensize' and then the slider setting to the weight for which axis to scale with (width/ height)
Hey! I have a quite advanced topic and It involved the URP pipeline and UIs:
My UI is very blury and I need the UI to render at a different internal res then the game.
The issue I have is that , I can't edit the URP settings because I always want to internal res to be lower than the res set by the user .
SO I need a way to make the UI overlay camera that is in screen space - camera render at a 1 or 2 render scale and the main camera at 0.5 or half
the core issue I also have is that I do not want to use a render texture if I can avoid it
your best approach would be to render the game to a smaller render texture and UI at the native app resolution. You could also do the low-res as a post effect.
Is this the only most viable approach. All I really need is for the UI to look like it's in the world and not just floating above everything .
you can also use "camera" mode for UI and render game/ui to separate cameras at arbitrary resolutions and compose them as you like
you cannot render world UI with depth-sorting in a different pass
your UI would have to be "on top" only
This is what I have tried but because the main URP pipeline is set to 0.5 using the UI camera as a stack or standaone seems to inherit that internal resolution
you need to render to a texture
sads!
alright
This has been quite a consistant reccomendation
otherwise you render to the backbuffer and that will always have one specific resolution
Guess there is no easier or better way around it
easiest way is to do the low-res as a post effect
if your graphics aren't fill rate sensitive, that would make minimal performance difference
Ya I got that set up already but did not like the outcome Just seemed very much different to acctually dropping the res. it becaome artificailly pixelated and did not capture that PS1 asthetic I am going for
meaning if you aim for PSX/PS2 era graphics and effects, your raw resolution is irrelevant
there is more to the PSX look than resolution, all of which is easier to implement as a post effect
to make an actual PSX pipeline is a fun project, but low value
you kinda need the actual PSX pipeline to add the various vertex jitter glitches, but do you really want/need those?
you can probably approximate those in post too
agreed but the res is a very big one . My textures are all set to no higher than 256 with 16 or 32bit colors.
The idea is to get a modern feeling game but with the psx look and feel minus the jittery and wobbly textures ..
Modern tec meets retro feel
got it, then do post
but Ya, I get you. REs is not that big of an issue. It's just trying to keep the UI clean and readable while keeping the psx res look
unless you want raytracing/GI, then fill rate will be bad
GL is needed I think
so I will have a look
so you want to make a low-res HDRP project?
The game is already super low as I am texture packing a lot and only using albedos with near no Polys for pretty much all the geo in the game
what resolution would your ideal UI be rendered at?
1080p but support for lower or higher
imo, try the render texture approach, see where it fails and if its actually too complicated to get it to work
you can always drop the render texture approach later
Fair. The reason I am against is it because I initially had the render texture setup and for the life of me I can not recal why I stopped using it .
And for context this is what the game looks like so far. (without the new UI design)
fwiw, multiple cameras eliminate many performance optimizations in the SRPs
you can stack cameras in URP such that they can reuse passes of previous cameras, but its a bit tedious to get right.
I am trying to get this look
and usually the multi-cam setups exist precisely because the previous passes don't yield the needed data
you wont
you can't get that look, way too much goes into that
or do you mean just the 3D UI?
I mean the 3D UI .. I can design the Ui however I want. but this is the main issue. I can get the 3D look but it's blurry to Hell due to my Internal resolution set to 0.5
the UI is a standard camera UI with a distortion post effect
For real ?
Post?
no way
its rendered to a separate camera that uses a different post processing stack from the game world
post for the subtle curvature, the perspective is actual 3D, you could make a custom camera that does the curve projection
I would love that! that is all I am stuck with. I could then keep the camera in screenspace overlay and the resolution issue just dissapears
Any links I could look at ?
no links, its just what i would do if you gave me that as a spec.
Well it's an avenue I have not looked at yet! So let me investigate . Thanks a bunch
Found a stupid cool and easy fix!
I just switches the order of opperation . Instaed of setting the entire render stack to half the res. I keep the render stack at full res but use a render feature to half the resolution on the camera I want.
silly fix .
The result:
This fix works not as a post process but as a render pass by just halfing the res or I could set a fixed resolution
nice
I am trying to have the ObjectiveText, and EnemyCountVisual, stack on top of eachother by applying a Vertical LayoutGroup on the ObjectivePanel. I am using a Vertical LayoutGroup because the content under Objective Panel might change during run time, and I want all the child objects to fit. However, the content doesn't seem to be stacking correctly.
Try add layout elemen on each child game object . Set their max width amd height .
Make sure the panel has the appropriate padding and space
Hey! I'm having an issue with TextMeshPro. For some strange reason, the letters have turned into these black squares. I've checked and the Font Atlas is correctly applied. What could be causing this issue?
Have you got the TMP essentials imported?
What scale is the TMP recttransform set to?
What font size are you using?
Hey everyone! Not sure if this is the right place to ask, but I’ll give it a shot.
I’ve been using Screen Space - Camera for my UI for a while, but I recently switched to Screen Space - Overlay. That change ended up breaking some of my mouse position logic.
From what I understand, I should now be using Input.mousePosition, which seems to work, but I’m not entirely sure if that’s the correct approach.
I also have an icon that follows the cursor with a set offset, but the offset now seems to be in pixels, so it changes depending on the screen resolution.
If anyone has some advice or resources on how to handle this properly, I’d really appreciate it!
What are you doing with the mouse position?
What are you trying to accomplish
I have a tooltip that appears when I hover over an item in my inventory, and I need it to follow my cursor, with a bit of an offset.
Same when I pickup an item - the icon of that item should be next to my cursor.
Not sure if it changes anything, but I am using a canvas scaler on my canvas as well.
This is how that method looks right now (and works with screen space camera)
I am a bit rusty by the way, haven't worked on this project in a bit (or in Unity in general) and I'm trying to rediscover it.
Also this is what I have for the item in hand:
Has anyone ever heard of or figured out a way to pass-through events on Unity UI?
I need to have a Graphic overlaying the whole screen and detect events, while letting those events still pass-through when detected to regular UnityEngine.UI.Buttons beneath it. My setup is essentially a transparent raycast target Image + my own IPointerDownHandler Component, and that would need to still allow other elements behind it still receive those PointerDownEvents.
Been like hitting my head on a wall:
- EventData.Use() implies that not calling it would leave the event still bubbling through, but there's no difference whether I call it or not in my case; I understand that GraphicRaycaster hits the Image and the event is only sent to its GameObject and nothing else.
- Removing the Image Component or setting raycastTarget=false obviously makes GraphicRaycaster ignore my event catcher IPointerDownHandler Component
- GraphicRaycaster.BlockingMask doesn't seem to work: I set my IPointerDownHandler GameObject on a "UI-Passthrough" layer, then made sure to disable that layer on the GraphicRaycaster.BlockingMask, but nothing changed. The raycastTarget Image is still hit and blocks all clicks, making any Buttons or other UGUI elements behind it unable to receive input
I would just use InputSystem to detect the Mouse/Touch pointer down action events, but I need to know whether the regular UGUI is blocking the view at time of clicking... hmm. Maybe I could workaround to somehow poll the EventSystem on whether there's a UI element currently overlapped by the GraphicRaycaster... But it would still be great to hear anyone who knows or is on the UI team to answer the issue specifically with UGUI tools (in discussion/forum groups all over there were many people asking similar questions, none truly answered, all worked around their problems and UGUI).
there's no builtin way to propagate the event down to lower or "blocked" elements. You essentially will have to fire off another raycast manually in your handler code for the "top" element.
Can you explain the use case?
Compacting my use case: Rotateable 3D globe with interactable header and footer UI and some buttons in the center. It feels bad that interacting with the UIs (which have ScrollRects and naturally invite drag motions) simultaneously rotates the 3D globe "behind" the UIs.
The solution I was seeking for was to have an UI element that detects the UI system's events for PointerDown/PointerUp, so I could then sort this detector UI element in front of or behind whichever other UIs based on whether I want those to prevent the globe rotation or not, then check my detector for whether I allow the globe to rotate.
I'll probably have to workaround by polling EventSystem.IsPointerOverGameObject(), but that won't allow me to pick and choose what UI elements count as blocking the drag-rotate and which don't (some UI buttons overlay the globe and having the drag input over them actually cause the rotation does not feel bad unlike interactions in the header/footer which visually obscure the globe and have their own ScrollRect drag elements).
Minimal hierarchy example of my use case:
- 3DGlobe
- Canvas
- SmallCenterScreenButtonWhichCanAffectGlobeRotation
- Detector
- Header
- ScrollRectThatShouldNotAffectGlobeRotation
- Footer
Only presses that can reach the Detector should be allowed to start a dragging input for 3DGlobe. Presses that are blocked and used by Footer or Header don't reach Detector and globe won't rotate. Pressing at SmallCenterScreenButtonWhichCanAffectGlobeRotation and dragging is allowed to also drag the globe as its visually set to be clearly part of the same thing and it's obvious to user they're simultaneously dragging both the button and the globe.
Well, at least I got the compromise-workaround using EventSystem.IsPointerOverGameObject() to work.
Explanation below, sorry for bad big-server etiquette not replying/pinging clearly before - will be more careful next time.
What do you mean by firing off a manual, second raycast? Like somehow do that via GraphicRaycaster? How would you propose the second graphics raycast goes past my Detector GameObject/Graphic on this second raycast (especially when GraphicsRaycast.BlockingMask seems to do nothing)?
yes with GraphicRaycaster or EventSystem.RaycastAll
All of those raycasts give you a list of all the hit objects
you can sort/ignore them any way you choose
Yeah, okay, that makes sense. Kind of like writing my own GraphicsRaycaster to do its work.
Thanks for the pointers, have a good one! 👍
Hello
I want to render a VFX effect on top of UI element
I did kind of solve it by creating another camera to only render the VFX
save output to a render texture
use raw image with that texture
But now the issue the the scaling and make it anchored like UI elements
and honestly all of this feels like fighting the engine
I've also ran into inconvenience of animating sprites (on the Image component and such)
Should I convert to using sprite and normal 2D objects instead?
raw images are ui elements so you can scale and anchor them like an ui element, cant you?
but it might be a better idea to not use render textures. with a screenspace camera ui you can just add the particle system (if thats what you mean by vfx) onto the ui, for example
Another option is to use a screen space camera canvas for your UI and literally put the VFX in front
Hello, does anyone know why my UI moves off-screen after I change the resolution? I'm trying to make the UI responsive for all devices. I have already set the canvas scaler to fit the screen size.
Without seeing the setup, it's only guess work. Usually UI doesn't stay in place with resolution changes because the anchors aren't setup correctly.
Also, if you're developing for mobile, don't use the 'game' view. Where it says 'game' is a button, click it and change it to 'simulator' then you can select from loads of different mobile devices
I dont have rect transform
that is not UI, that is a sprite renderer
I have an issue, where my text is going to that one standard unity font texture. but like the whole alphabets i dont know how to explain.
probably cuz u didnt create it properly? why do you have a probuilder mesh on this object
In uiextensions there is UI particle script that converting particles effect into UI space
the text keeps dissapearing at different angles. idk how to work with UIs forgive me
You need to create billboard script that will rotate your world space text to face your camera always
no
i dont want the text to look at me
nvm i changed it to world space
but thats for trying to help me
If you just need word space text it should work fine
yea
It should be visible from good angels
yea
shader issue
get a fresh TMP package
if you see 2 messages below, it was fixed.
Hello, I have updated the map to use a UI with a screen space camera since my player was behind the UI elements. However, I have encountered a new problem and would appreciate some suggestions.
When I activate a panel, my player does not move behind that panel. I created my player using a 2D object sprite in the shape of a circle. How can I resolve this issue?
also I'm having an issue with my base map. when I change the resolution to a different size, the tiles become slightly misaligned as the player moves.
I'm setting all the tiles with a transform reference. How can I fix this? Do you have any suggestions?
Can you show a better picture of what you're talking about because I don't notice anything here
I've already solved my previous issue, but can you help me? I have a button achievement under a canvas, and it seems my base map is blocking this button. Can you give me some suggestions?
I use sprite for my base map
You're kind of cropping lots of important details out here
And you'd need to show the settings on the canvas too
A sprite renderer on its own will not interact with the UI event system in any way
It's not a UI element
More likely it's whatever your "canvas panel" object is
can you show your EventSystem object
Also the Canvas object
Is your project using the new input system or the old
the new one
In your game view can you disable this "low resolution aspect ratios" thing
your game view is currently zoomed in 2X
not sure if that's affecting things
tried that and it still isnt working
From what you showed I'm not seeing what the problem is. I will say that it definitely looks like it's not an issue with the code or the button, your mouse input is just not interacting with the event system at all
the normal checklist is:
- Make sure nothing is blocking the button
- Make sure raycast target is enabled for the image
- Make sure there's an event system in the scene with an appropriate input module
- Make sure there's a GrahicRaycaster on the Canvas
ive tried reinstalling the project, changing version, opening a new scene and trying the same thing there, and changing my mouse cursor to the default one
you seem to have all those as far s I can tell 🤔
Do you think this is an issue with unity?
hey, I have some small issue. I have object with grit layout group. Cell size are 75x75. That object is inactive on scene. I instantiate new elements as children of that grid. When I get the size of their rect it returns 100x100. But when I SetActive(true) that grid, then they update to 75x75
can I somehow update that when grid is inactive?
Why keep the grid inactive?
cuz I'm initializing inventory procedurally. I don't want to show it to user
inventory shouldnt be open by default
You could keep it active just not visible
but let's get back to the root of the issue here - why do you need the size to change before activating the UI?
In fact why do you need to even add elements to the UI when it's not visible?
to generate invtory and add starting items
But... this is the inventory UI
not the inventory itself
The actual inventory itself should be separate from the UI that displays it
oh true true
yeah, I'm not using my brain currently
thanks for pointing that out
I like to overcomplicate stuff
I think the simplest things would be:
- Never deactivate it, just hide it, e.g. with CanvasGroup alpha settings
- Activate and deactivate it immediately
Never deactivate it, just hide it, e.g. with CanvasGroup alpha settings is this actually a good solution?
performance wise
It most likely would have little to no performance impact on your game
Hi guys.
I'm having an issue, not sure where it is.
But, I'm creating a card game, but the card visual (inside a Canvas) is getting jagged edges/pixelated.
I already tried to change the configurations on the Image Import Settings, and on the Canvas, but none made they clean or correct.
Maybe I'm forgetting something to change, or I made some changes incorrectly, not sure.
If anyone could help me figure it out, I would be glad.
Example here, but the print is a little worse than in live.
@shadow delta Maybe try to use preserve aspect of image but I'm not sure if it helps
need help in attribuutions.
I have this 3d model i got in sketchfab and i also got the credits, my question is do i still need to mention that i changed some part of the model or not in the credits?
Depends on the model's license. But it would be very unusual if it required to specifically mention modifications
also wrong channel
its cc attribution
wait what channel should i be asking tgis
#🔀┃art-asset-workflow. This has nothing to do with UI
None of the CC licenses require mentioning modifications. Either you're allowed to modify or not
my mistake i was asking here because im working on my Credits Screen my bad
Hello, I am a new unity developer
I want to know , is there any blending mode, package or any script to apply in unity screen space overlay ui?
Like multiply, darken, lighten etc.
Not really sure what this has to do with this channel. It seems like more of a #💻┃code-beginner problem.
You should understand what a NullReferenceException is https://unity.huh.how/runtime-exceptions/nullreferenceexception
and if you are going to post screenshots of code (unadvisable), don't cut off the line numbers, as that's an important part of the error.
but alright thank you
InventorySlot newSlot = Instantiate(_inventorySlotPrefab, transform).GetComponent<InventorySlot>();
_slots[x, y] = newSlot;
_slots[x, y].Init();
public void Init()
{
RectTransform rect = GetComponent<RectTransform>();
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
_slotWidth = (int)rect.sizeDelta.x;
_slotHeight = (int)rect.sizeDelta.y;
}
for some reason, the sizeDelta is 100x100
i tried with rect.rect.width and its also 100x100
why?
does anyone know how to fix this?
textmeshpro has ui text and 3d text.
what are you using? the default unity text? don't.
use the 3d textmeshpro text for this which doesnt require a canvas
ForceRebuildLayoutImmediate is rebuilding your slot and all of its children, so I assume not rebuilding using the parent's grid layout parameters.
You should just get those parameters after the entire grid is populated and you do one rebuild. Running a rebuild command like that with every "slot" is going to be a big burden when instantiating. You could also just pass the grid parameters to the slot if you need those stashed on the slot for whatever reason instead of doing a rebuild and reading them in.
yup, thank you. That works :)
im using a 3d textmeshpro for this with an image background (the image is within a canvas)
im just going to remove the background thing, i dont need it there
you can just have a simple mesh there with a transparent material, no need for a canvas here at all
i have 1 player canvas with 2 different screen. When i try to show one, both of them are shown at the same time. Help
it makes sense to me why this is, but i just don't knnow how to fix it
you would have to give us more details
When i try to show one, both of them are shown at the same time
How are you showing them?
showing your code might help
alright, give me a second.
I was looking through my code and realized it was a stupid mistake on my part. Thanks for replying tho
is there any direct way to turn a traditional UI button (i mean UGUI button , this one) into double click only
or i need to make an integer, increments it and reset it to mimick double click
that is not an inbuilt feature
thats okay, because i just want to see if theres a better and direct implementation to that
before i code my solution
as direct as
Button.onDoubleClick();```
or it can hook onto input actions from input system with just a specfic function call
That code would be an 'inbuilt' feature, it does not exist.
I doubt the input system has it either, but that's a guess I don't know for sure
i just did the research , it does not, so im planning to implement my own function now ,ty 👍
private List<int> plotValidClicks = new();
button.onClick.AddListener(() => { CurrentSelectedGrid = slot; });
private BatchPlanSlot CurrentSelectedGrid
{
get => currentSelectedGrid;
set
{
plotValidClicks.Add(value.SID);
if (plotValidClicks.Count < 2)
{
return;
}
if (plotValidClicks[0] != plotValidClicks[1])
{
plotValidClicks.Clear();
return;
}
if (currentSelectedGrid != null)
{
previousSelectedGrid = currentSelectedGrid;
}
currentSelectedGrid = value;
Plot();
plotValidClicks.Clear();
}
}```
it does work, for now
i have a unique ID for each buttons, so i record them into a list, maybe a int tuple in the future?
if list.count = 2, it means double clicked, so i will check and reset
requiring two clicks != double click
A double click is 2 clicks in a short space of time.
This isn't something I'd be doing in a property either
i think i will do it on a function instead
I am trying to make a slider however when my slider value is 0 there is still some of the filled area inside the slider how can I make it nothing 😭
Open the objects that make up the slider and adjust their RectTransforms as you please
I usually set fill object to zero in rect transform and set fill area object suit background
So how can I take this slider in this component inspector and
• Control its length
• Hide the bar component of the slider
How can I prevent clicks interacting with my world for movement etc through UI Toolkit Visual Element
Best to ask in the #🧰┃ui-toolkit channel.
Is there a reason the width of graphRect displays differently from the EditorGUI.Slider's width despite using the same parameter?
Rect graphRect = EditorGUILayout.GetControlRect(false, 150);
testScript.timeToApex = EditorGUI.Slider(new Rect(graphRect.position.x, graphRect.position.y, graphRect.width, 0), testScript.timeToApex, 0.1f, 4.9f);
if (Event.current.type == EventType.Repaint)
{
Handles.BeginGUI();
//Draw container
Handles.color = Color.white;
Handles.DrawLine(graphRect.position, graphRect.position + Vector2.right * graphRect.width);
Handles.DrawLine(graphRect.position, graphRect.position + Vector2.up * graphRect.height);
Handles.DrawLine(graphRect.position + Vector2.right * graphRect.width, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height);
Handles.DrawLine(graphRect.position + Vector2.up * graphRect.height, graphRect.position + Vector2.right * graphRect.width + Vector2.up * graphRect.height);
Handles.EndGUI();
}```
I found a discussion from unity where it ask to set the anchor point of the rect transform to 0 for left and right
then viola it works
feel like the ui is a bit bad and wonky. Any ideas on how to fix it?
Ui looks like from different environment and km text looks bad in grayish color
Solid start, you've got the base design requirements in place. To improve it I would recommend exploring what some other UI of this genre are doing and then use that as inspiration for making a subtle improvements!
I created a Youtube video recreating part of the New World UI using Photoshop, it's hard to tell from the game screenshot but that type of style might suit.
☕ If you enjoy my work and want to see more, consider buying me a coffee—every bit helps keep this going!
https://buymeacoffee.com/warrenwinters
Sharpen your blades and let's step in to a New World.
In this speed build we get a preview of a full tutorial where we go through various different tips and techniques to achieve a UI in Photosho...
I think there is a problem with this section of code.
new Rect(graphRect.position.x, graphRect.position.y, graphRect.width, 0),
testScript.timeToApex, 0.1f, 4.9f); ```
Right but what part of it? The goal is to have a slider that doesn't have a bar (or appears to not have a bar) and covers the length of the graph (or has a length dependent on that) positioned at the top of the graph
you might best asking in #↕️┃editor-extensions
Thanks
hey any tips to make the TMP look smoother and less pixelated? I tried messing with the Canvas Scaler but no luck there
First change the game view scale back to 1x
I know, i just zoomed in for the screenshot, it's really noticeable even when at 1x scale
Don't do that, it makes it look worse than it is. Show the inspectors for the elements (text, canvas, scaler etc)
Does the text look better if you move it out of the image and make it a direct child of the canvas?
Maximise the game view, you'll find the text looks fine when it's not being shrank to fit
Tried that, no difference in the Game view
it does look better but still weird, notice "i" being very squishy
could this be an anti-aliasing issue? any way I can check that?
make sure the scale of all UI elements in the hierarcy are 1,1,1 (canvas can be whatever its set itself too, you can't change it anyway)
And as a test, just try the default font
does look better, maybe the problem were in the font creator settings?
Scales < 0.1 can cause rendering issues with TMP
If the default font looks fine, then try re-making the font asset for the font you're using.. tweak the settings, it could be packed too tight or something
All the scales are at 1,1,1 so I'll try messing with the font creator settings, thank you
How do I generate a drop shadow .mat for my custom font here?
Hey! You can do it this way. Depending on how long you want the shadow you might need to adjust the font atlas padding (shown in the video). If you want to create a new material preset then just ctrl+d on the material and it'll duplicate it.
This took some time, but i finally manage to decently understand anchors and some UI, this first week of unity has been rough on me haha
Awesome! Glad you're getting the hang of it.
Thanks, now im investigating how to make the game to be centered and to scale the content/camera acordingly, but its harder than i thought haha
What is the easiest way to display dynamic icons for inputs based on your bindings?
Do you need icons or letters?
I'd need the icons, I know where to find the graphics, but I need a way to display them correctly
Just give me sec I will open my project, I will have a snippet for you
Oh thanks that's neat
does anyone know whats causing this
private string GetKeyLetter(InputActionReference inputActionReference)
{
if (inputActionReference == null) return null;
var interactionBindings = inputActionReference.action.bindings;
foreach (var binding in interactionBindings)
{
if (binding.isPartOfComposite) continue;
if (binding.path.Contains("Keyboard"))
{
return binding.path.Replace("<Keyboard>/", "").ToUpper();
}
}
return "";
}
This returns an exact key value for a binding that is a key e.g. "E", but similar way you will get bindings for e.g. controller but the values won't be single letter, you'll need to debug what you will get.
Things you will get for controller will be like "<Gamepad>/leftStick" - so, you will have to create a mapping between the 'value' and the 'sprite' with the icon.
Thanks that helps a lot
Give me a couple of minutes, I will try to write something becasue I will actually need it too - I was supposed to make it tomorrow :D
I am used to working in other engines where I have my trusty plug-ins doing these things for me ^^'
thanks you a lot^^
what am i doing wrong here its causing it to not scroll
Give me a sec, I will have a look in a moment :)
So to get the sprite I would do something like this:
private Sprite GetGamepadButtonSprite(InputActionReference inputActionReference)
{
if (inputActionReference == null) return null;
if (_gamepadButtonMappings == null || _gamepadButtonMappings.Count == 0) return null;
var interactionBindings = inputActionReference.action.bindings;
foreach (var binding in interactionBindings)
{
if (binding.isPartOfComposite) continue;
if (binding.path.Contains("Gamepad"))
{
// This one is the thingy I talked about before that checks if mapping is for gamepad. It will be like "<Gamepad>/buttonSouth" -> "buttonSouth"
string buttonName = binding.path.Replace("<Gamepad>/", "");
foreach (var mapping in _gamepadButtonMappings)
{
if (mapping.ButtonPath == buttonName)
{
return mapping.ButtonSprite;
}
}
}
}
return null;
}
The mappings would be stored in:
[SerializeField] private List<GamepadButtonMapping> _gamepadButtonMappings;
and the mapping class itself:
[Serializable]
public class GamepadButtonMapping
{
[field: SerializeField] public string ButtonPath { get; private set; }
[field: SerializeField] public Sprite ButtonSprite { get; private set; }
}
im having some isues where idk why but this scroll isnt working
Let me send you how I set it up and it works
whats goin gon with it tho
its not scrolling
its the same setup as the text
This is how I set it up and it works
Let me convert the file to mp4 so you will be able to watch it without downloading
Here you are
oh ok thx
Thanks that's exactly what I was searching for, you're a life saver
My pleasure! :) Good timing haha
any idea why this ui panel is stretching when i change from 16:9 to free aspect in the game view?
like the aspect ratio is increasing
but why would the button stretch
If the buttons anchors are not together horizontally then it will stretch as its parent stretches
again... go read and learn about how anchors work:
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html#anchors
Is there a way to get the text from the current TextMeshPro page?
Tried finding it in the documentation and on the forums but had no luck with that so far.
Putting a debug statement with the text value of TextMeshPro only gives me the first two lines, skipping the third one, even if I've changed the page.
"page" isn't a term I've seen anywhere, so I'm not entirely sure what you're exactly asking about. But to get the text from a TMP component, you just use .text
string someString = myTmpComponent.text
In TextMeshPro, you can choose an overflow mode called "page", then any text that either overflows or is after a <page> tag gets put on a new "page"
As you're using rich text, you might need to add the \n so the deebug log knows there's a carriage return
oh, but that won't be the case because you get the first two lines
ignore me, I clearly didn't get this at all - sorry !
No worries, it's an annoying and confusing issue lol
I think the issue is that Debug.Log doesn't support the <page> rich text tag. So you are probably retrieving the string fine, but Debug.Log doesn't know what to do with that tag so it just ends the string there. You could remove and replace the <page> tag with some kind of acceptable symbol for your logging.
I meant that I want to get the contents of a page into a script
Couldn't find an option for that, and the debug log did not help
As I'm working on a dialogue system, where the writer who doesn't really do unity stuff can write dialogue of arbitrary length, and it then splits the text he writes into pages automatically (or if he writes down a tag)
Looks like the TMP_Text.text will return the whole string. So you'll have to parse the text and look for <page> in your code if the writer adds one in. Then split the text string into pages yourself for whatever you've got planned next. So if you want just a particular page, just split the string up into a List<string> (or whatever you choose) and then you have access to each page individually.
That however does not take into account new pages created due to overflow
Ah, well, if you want that sort of info too, you can use the .textInfo to figure out what you need.
https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TMP_TextInfo.html
could you elaborate what you mean by this? im not seeing how carriage return fits into this
Hi, I'm making prefabs for UI elements that use png sequences for the animations. If I select all the files of a png sequence and drag them into the scene, unity will automatically make me a game object with a sprite renderer and an anim controller and an anim clip that animates the png sequence.
But I don't want a sprite component, this is for UI. I want an anim controller on the top object in my prefab, that animates child image components but I can't find a way for unity to automatically populate my anim clip with the png sequence keyframes? Using a clip that Unity generated for the sprite object doesn't work. The sprite component doesn't exist so the label for it in the anim keyframe editor window is yellow.
I swear years ago I could edit the anim clips in notepad to make them find the image sequence but it's all disguised with GUIDs now
Ah, don't worry, I asked Gemini and it told me the answer. All I have to do is select the images and drag them directly into the 'image > sprite' property in the keyframe editor.
there is a way to get last and first character index in a page, so I should be able to get the needed text from that, thank you
... unless they did change that in some newer version and forgot to document it as it does not show up
nvm I'm stupid, it's an array of pages
there's no need. See my msg after where I realised I was wrong with some assumptions.
oh sorry - i meant regarding rich text in general, under your initial assumption
(unrelated to the original question)
I was thinking maybe the debuglog was missing the carriage return that can be seen in the text box. and adding a \n would allow the log to see it and print it.
It wasn't that because I missed that the log was seeing everything upto <page> which is on the 2nd line already
im not seeing a carriage return there, are you referring to the newline/line ending
yes, it is across three lines. Enter was pressed after the . and >
ah ok. thought there was some interaction between newlines and carriage returns in a debug log or something that you were referring to 😅
With my first reply I thought the log was just doing the first line. I know for sure that \n works in a debug log - so adding that to the next would get it into the log.
Isn't needed because that wasn't part of the issue and I'd just failed in reading the problem correctly
How can i improve my current inventory screen? I'm mostly happy with it but it feels a bit to clean and lifeless. With items of varying rarities in the stockpile, backpack, slots, etc. there will be a bit more color, but what can I do with just the base menu(s)? I dont want to lose the clean, modern aesthetic but I would like it to have some personality if that makes sense.
you've got a massive amount of empty (wasted) space
why does my UI disappear when I try putting it in screen space camera?
I have the camera assigned, scale and resolution seem correct and I have the culling mask of the camera set to "everything"
what does it look like in the scene view ?
nothing, there just isnt anything
everything becomes invisible
That view isn't useful. Take 2d mode off, and make sure the canvas and camera are visible
also, do not crop the screen - you might be cutting out useful information that you're not aware of
Console only says this
The project currently uses the compatibility mode where the Render Graph API is disabled. Support for this mode will be removed in future Unity versions. Migrate existing ScriptableRenderPasses to the new RenderGraph API. After the migration, disable the compatibility mode in Edit > Projects Settings > Graphics > Render Graph.
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadMethodAttributes ()
which is unrelated i believe
it just kinda disappears
yeah that warning isn't related
where's the camera? -> select both camera and canvas
are you 100% sure something is enabled to actually see on the canvas?
I don't know what this is supposed to be showing.
Sorry i had to move so it took me a while to respond, the first image is the ui with overlay, the second is with screen space camera
Yeah I didn't change anything from active to inactive, just set screen space camera
but you can't see the UI in the scene view for either render modes
Not sure right now why it couldn't be seen in scene mode for Overlay canvas, but the Ui is done anyway I just need it to appear in screen space camera so I can apply post processing to it
record a video - go through and select each UI gameobject that should be visible so I can see the inspector
Alright give me a minute
You've also go the sort order on the canvas set to 100.. doubt it'll make a difference for this issue, but that's rather high for no reason
For the video, also show the scene view and select the canvas and the camera - i wanna see for certain things are where they should be
Okay it turns out I don't have the right unity version on this device, so I'll message this channel again in a few hours when I have access to my main machine again 
Sorryyyyy 
Okay well I am back
and my UI is also invisible on scene view for some reason I cannot fathom
(it is still fully functional in the game view though)
The objects are there and apparently not hidden as far as I can tell
so I have no idea where it went
the UI layer is visible and UI and transparent fx are both assigned to URPs transparent layer mask...
What do you have selected in this control?
Everything except always update
I cant for the life of me get windows to take a screenshot while the menu is open
so skybox, flares, fog, post processing and particle systems
Oops, I meant the one without the sparkle. Just on the other side of the eye ball
Everything in the layers is set to visible
hiding UI hides the big rectangle that my screenshot shows
but unhiding it doesnt show the actual elements in the canvas
Do you have a CanvasGroup in the hierarchy and the alpha set to zero?
I am not sure what a CanvasGroup is
Oh, well you probably don't have one then. It's a component that you can put at a level in the hierarchy and ime mainly used for fading in and out.
That still wouldn't explain why scene view isn't showing but game view is.
turns out this does matter
for some reason my UI does not render with compatibility mode active on the render api
but only for scene view
separate issue to what you're having - your scale isn't uniform.. you're gonna have a bad time trying to get the children looking right when changing their size.
Always keep UI scale at 1,1,1 and change the size with the height/ width fields
Going back to this, as it turns out the stuff I tried below that absolutely did not work.
So, gonna try asking again:
Is there a way to know what the contents of a page are in TextMeshPro when using the "Page" overflow mode?
<page> just inserts a page break
there isn't really much more to it than that AFAIK
hmm I guess this is relevant? https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/TMPro.TMP_Text.html#TMPro_TMP_Text_pageToDisplay
I know
The issue is, that I would like to know the contents of that page
Changing the „pageToDisplay” changes what the textbox displays, but I would like to know what text is shown
As getting textmeshpro’s text component just gives me the full thing
TextInfo gives you PageInfo: https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/TMPro.TMP_TextInfo.html#TMPro_TMP_TextInfo_pageInfo
(an array, presumably one per page)
Yes
But pageinfo does not have any text variable
it gives you first and last character index, presumably used to sample the full text
it has first and last character indices
First and last characterindex kinda seem to not work too
As when changing pages firstcharacterindex is always 0
how are you trying to access it
Can you show your code?
how are you indexing the pageinfo array
I’m away from my pc rn so can show it a bit later, but basically I get the current page, and try getting its firstcharacterindex
changing pages won't ever change firstcharacterindex, it would change which page character index is used
So in short, there is no way to know what is actually written on a specific page?
Damn, that sucks
by "no" i mean, yes there is a way
Ah
Then which pageinfo would allow me to access that?
As first and last character indices do not seem to help much
would need to see code but first step would probably be iterating through the pageinfos and logging their results to see if the indicies are wrong or if your sampling the array wrong
we're saying your code probably has a bug and is accessing the wrong PageInfo object
you may be reading the first page info every time
Ah
Sorry for misunderstanding
Will double check when I get back to the project
but can't know without seeing the code
wat is your dudes simplest way of making pixel fonts look the best
ive tried making its rendering mode into hinted raster but sometimes it still gives off a blurry look
just wondering if theres a lil more i could do to make it look smoother
double check if the size of the text box is 1/1/1, as scaling the box instead of the font size can lead to blur
Here is the code, the text input, and the debugs
it updates lastcharacterindex, but for some reason the firstcharacterindex is always the same
so it leads to this behaviour when the text is being copied to a different text box
I know I can just work around this one by subtracting the previous index, but I'm just curious as to why it is not working like it should
without that first character index it looks kinda horrible, but it finally works
oh yea, forgot to say that earlier, but wanted to thank y'all for taking your time to try helping me out
The way firstCharacterIndex is working does seem off. Nothing in the docs about it explaining anything, so I don't know why it's that way. Glad you worked around it, though.
Will try reporting that as a bug on the forums, hopefully it'll help the devs
how should I go about making it so my cursor goes into an animation state whenever you hover over or exit a valid ui element? ik how to do it for every individual element, but I'm wondering about a global callback on those events (like every time it hits a on enter event, it runs a function, and everytime it hits an on exit event, it does a different one, regardless of the object it enters or exits)
how does one use this lol, never touched this in my life and I'm fairly new to more involved ui stuff in unity lol
You use the Raycast method (linked)
Hello everyone 👋 I’m a passionate UI/UX designer who loves creating intuitive, user-focused, and visually appealing digital experiences. Excited to connect!
Hey I just added some ui to my scene just a canvas with a few buttons, it worked fine before but suddenly it's gone in game? Like I don't see the ui at all anymore and I don't recall making any changes to it
nvm it seems my resolution changed causing it to go outside the screen
That means you've not setup the anchors correctly
You know how to add and swap images in the UI. Apply these skills to make your UI elements look even better. You could have the settings button use a custom image instead of the default one, or you could add borders around the background to make it stand out more.
It says you can add border to this button. I can't find option to add border.
(New to unity)Hey I dont know if anyone else is facing the same issue but when I try to add a button to my menu, its super large, and the resizing is really confusing
You'll have to explain a bit more what you find confusing about it
This is a bit vague so I'll just give you some general tips on how to deal with UI in Unity:
- Make sure your scene view and game view windows are both visible, side by side
- Make sure you have Gizmos enabled in the scene view (should be a little button with a sphere in it all the way top right of the scene window)
- Make sure your Canvas render mode is set to Screen Space (Overlay is simplest, but Camera will also work)
- In the hierarchy window, double click your canvas (or select it and press F). This will zoom your scene window to look at the whole canvas. You should see a big rectangle representing the canvas.
- Make sure you have the Rect tool selected in scene view
- You can now properly work on UI. Drag a Button or Text or whatever from the Create -> UI menu into the scene inside the canvas rectangle and watch how it appears in the game view window simultaneously. Move it around a bit and see how the canvas rect corresponds to the game
Thanks
How to make UI scale with screen because my 1920x1080 looks normal but QHD (2560x1440) looks smaller
check your Canvas Scaler settings
ohh yea found it i have not used into in like 1-2 years now
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
I'm trying to show/hide the text (ARCHITECTURAL RENDERING) with a checkbox toggle. It doesn't seem to work. I'm probably not using right function from drop down. Please help
It seems to work if just use "setActive" instead of "setActive (bool)". But I want opposite result. On toggle enabled, it should hide instead of show.
You need to write a function in your code to do it
You won't be able to do it in the UI
You need to invert the bool, which the UI can't do directly without some code
Okay. Since I don't know code yet, I'll try it later.
do you guys think the slight offset in the hud elements here is achieved via some kind of shader to give it that curved almost fish eye lens effect or by just rotating and offsetting the elements slightly...
better pic
i have no experience with unity but that looks like a fisheye
bc it doesnt look like it's js rotated
The red line is straight so probably not a fish eye lens effect
It looks like it's skewed rather than rotated
Camera space slightly rotated canvases on both sides probably would be the easiest way to make it look like one.
can you clarify a bit more 🤔
Screen Space - Camera https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UICanvas.html
nah i understood that lol
its just that youre suggesting using 2 canvases?
am i getting that right?
Having subcanvases is an optimization, you can have as many as you like.
It confines redraw to one
The elements on the left are skewed to a different direction than the ones on the right. That's why they need to be on different canvases so that you can rotate them separately
makes sense
ill try it out
thank you
looks like someone got half life 3 a bit early 😜
Hmmm i guess i know a lot less about ui in unity than i thought
i set up my reference resolution to be 1920x1080
with screen size scaling
but i also notice that now all my ui elements are hot blurry shit when the game view is set to 1920x1080 and only stop being blurry when i set it to higher resolutions
🤔 am i missing something obvious here or is there no way to ensure that my ui elements maintain constant scaling but also dont look like garbage at lower resolutions
it could be some aliasing at play perhaps 🤔
same exact resolution and everything but the left is screenspace camera and right is overlay...
🤔
yeah the overall scaling is slightly off but i got them to be pretty similliar in size when viewed in game view
this is with the game view at 4k with the screenspace camera and it looks like its supposed to.
Hi. Im making a portrait (640x1136) unity app that is designed to run in windowed mode on macOS/Windows/Linux. I was wondering if there is a graceful solution to automatically resize the game window to a specific size so it doesn't go over the actual monitor resolution. Any help is appreciated.
Set vertical to a percentage of the actual screen resolution, set horizontal based on that to achieve your desired aspect ratio
Might be off by a pixel at times but you can deal with that
Awesome! Thank you so much.
Is there a way to make a spline slider? Like a slider that moves along a custom curve?
Unity does not provide you one by default as far as I'm aware. Which UI system are you using?
uGUI
I couldn't find any ready to use solutions on asset store or elsewhere so you probably have to implement that yourself. The splines package can be good starting point. With it you can quite easily calculate the distance from the mouse to such curve and how far along the curve the closest point is (needed for placing the handle/knob along the spline). When it comes to visualizing the spline, you can generate a mesh out of the spline using the package though I haven't used custom meshes in UGUI, don't really know how that will work. The second option is to use a shader that draws the spline, the UI shader graph samples might be good place to start with that: https://docs.unity3d.com/Packages/com.unity.shadergraph@17.1/manual/Shader-Graph-Sample-UGUI-Shaders.html
About the mesh approach which might be easier, the CanvasRenderer component seems to be able to take custom meshes and materials. https://docs.unity3d.com/6000.2/Documentation/ScriptReference/CanvasRenderer.html (SetMesh, SetMaterial)
Oh good idea, I'll try out the mesh approach, thank you so much!
Hello everyone. Can you tell me what to do in this situation? Do I need to create a copy of the scene for portrait, or can I use scripts to change the layout group from horizontal to vertical? Does Unity already have the necessary tools?
I have about 30 icons. Everytime a new level loads, there will be 5 icons displayed on the screen out of 30. Should I have all the icons(.png) separate or combine them into a large atlas[Tile sheet]?
you'll be loading sprites, not textures, this won't matter too much
use whichever makes the workflow easier
alright. Thanks!
For performance you can add the 30 individual sprites in Unity to a sprite atlas, which means Unity will handle the combination and batching. It's easy and reduces draw calls
Hi all, I am currently attempting to figure out why my UI button isn't working
For testing purposes, I have put the button in a brand new scene with the automatically-created Event System, and it works fine in this scene.
However, when I try to load the button scene via another scene, the button refuses to acknowledge any input whatsoever, and doesn't show the hover transitions etc.
Is there a specific thing I need to do when loading a scene that contains UI to ensure that my button will work?
Select your event system, it will show you what is active while you hover and click. It might be another object overlapping
I'm using the newer input system and couldn't seem to see any display of which element was active in either of the components, however you were right about the element overlapping, there was a UI Document in the other scene that had no sorting order set, so it was just drawing on top of the button by default.
Cheers for the tip :)
I am trying to remove all padding and space between this set of buttons. 12 in total in a 3x4 grid , button size is 64x64
but even with padding and margisn set to 0 there are gaps , can youone advise?
could you try selecting one of the buttons to see how it lines up in relation to the others? the layout properties seem to indicate that the grid isn't putting any gaps in
certainly can!
I have checked the parent objects for content size fitters etc and did not see anything either
and no RectTransforms are on Stretch , Top left is used for most objects
looks like the margin is actually padding within the button sprite rather than a margin between elements
it's pretty easy to see in the sprite preview, actually
oh jesus
I spent hours on that , thank you so much
worst part is that was just a placeholder sprite that unity applied as default! , thanks again.
when I click on 1 in redirection me to to 2
and to modification mean reduce the width an height
The buttons in the Chapters menu are not working correctly because their RectTransform hitboxes are much larger than the actual button graphics.
This makes the clickable areas overlap, so when you tap Chapter 1, Unity detects the hitbox of Chapter 2 or another button.
Resetting the RectTransform and using the sprite’s native size fixes the problem.
I'm using "World Space" render mode for UI so I can place the UI elements in 3D. Now in the image, you see the canvas and the UI elements are far from the objects of scene. How do I transform (rotate and move) them where I want to place them? Should I transform the Canvas or the individual elements?
Also, does it even matter if UI elements are inside the Canvas or not? For example, it does matter in Screen Space overaly UI.
Ello! Trying to make a workable Menu Bar which somewhat works in Vertical screen but now I'm trying to make a workable Horizontal ver so that the Player can use it no matter the orientation of the screen. Is there a way to make it work?
At least Vertical works, not so much for Horizontal.
I’m trying to create a similar. top bar like in the picture, but it’s not really working.
Here’s what I’m doing:
• Creating a Canvas
• Adding a Background as a child
• Adding a SafeAreaRoot as a child (with the Safe Area script)
• Inside the Safe Area, I put my Top Bar
• LeftGroup → UI Panel with a Horizontal Layout Group (for the hearts)
• RightGroup → UI Panel with a Horizontal Layout Group (for the coins)
• Both groups have “Control Child Size” enabled
But it’s still not working correctly.
The hearts and coins don’t display or position properly, and on some phones the top has too much space while on others it looks normal.
Can someone tell me what I’m doing wrong?
Can you cause the problem to happen in the editor, or do you only see this issue on actual devices?
i see the issue when i use simulator - but when i have 9:16 it seems normal
okay, good, so it'll be easier to debug
I am not familiar with this "SafeArea" component
what is it from?
yes, I'm not aware of a component named "SafeArea"
using UnityEngine;
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
public class SafeArea : MonoBehaviour
{
private RectTransform panel;
private Rect lastSafeArea;
private Vector2Int lastScreenSize;
private ScreenOrientation lastOrientation;
private void Awake()
{
panel = GetComponent<RectTransform>();
ApplySafeArea();
}
private void Update()
{
if (Screen.safeArea != lastSafeArea ||
Screen.width != lastScreenSize.x ||
Screen.height != lastScreenSize.y ||
Screen.orientation != lastOrientation)
{
ApplySafeArea();
}
}
private void ApplySafeArea()
{
if (panel == null)
panel = GetComponent<RectTransform>();
Rect safe = Screen.safeArea;
lastSafeArea = safe;
lastScreenSize = new Vector2Int(Screen.width, Screen.height);
lastOrientation = Screen.orientation;
Vector2 anchorMin = safe.position;
Vector2 anchorMax = safe.position + safe.size;
anchorMin.x /= Screen.width;
anchorMin.y /= Screen.height;
anchorMax.x /= Screen.width;
anchorMax.y /= Screen.height;
panel.anchorMin = anchorMin;
panel.anchorMax = anchorMax;
}
}
okay, so it just resizes the target RectTransform
So your top bar is automatically moved below the notch so it stays fully visible.
While in play mode, resize the game so that the problem happens. Then, select the "SafeAreaRoot" object and look at its bounds in the Scene view.
with Gizmos on, you should see a rectangular outline showing you the space that it covers
I'll try
You're looking to see if it is shrinking the rectangle too much
thanks,
but would you normal do it like this?
Adding a Background as a child
• Adding a SafeAreaRoot as a child (with the Safe Area script)
• Inside the Safe Area, I put my Top Bar
• LeftGroup → UI Panel with a Horizontal Layout Group (for the hearts)
• RightGroup → UI Panel with a Horizontal Layout Group (for the coins)
• Both groups have “Control Child Size” enabled
oh, make sure that both of the groups have their anchors set properly
the LeftGroup should be anchored to the top left corner and the RightGroup should be anchored to the top right corner
otherwise, as the groups resize, they may slide around your screen
the default is to be anchored to the middle (0.5, 0.5)
Hi everyone,
Currently I'm working on accessibility in my game and one issue I keep running into is the fact that some of my ui elements get lost off screen. My game is being developed on an aspect ratio of 1980x1080, however when i port the game over to itch.io using a webgl build, some people can't see my ui elements due to their smaller overall screen sizes. What are some best practices/solution in terms of preventing or solving this issue?
Should not be hardcoding UI size, make it resizable with dynamic anchors
Okay so I looked into dynamic anchors and am trying to implement them for some ui elements to get the hang of things but my anchor for my score text box never moves after choosing a different location, what could be causing this?
As you can see in the first image the anchor of my ui text element is set to the middle in Rect Transform, but the next image i select it to be by the top of the screen yet the anchor doesn't move from the middle?
okay nvm, i found out it was a hierarchy problem bc my gameHUD objects anchor was set to the center, overriding child objects below it
I've disabled the UI map of my inputaction asset. I know with 100% confidence because, If I click the middle mouse button it should print "middle mouse" but it is not.
The problem is even after disabling the UI map and selecting my input action asset into InputSystemUIModule, my UI button are functioning. But it shouldnt be funcitoning right?
I've disabled the UI map of my inputaction asset. I know with 100% confidence because, If I click the middle mouse button it should print "middle mouse" but it is not.
I'm going to question this because I'm pretty sure your issue is there are at least two copies of the input action asset in play here
how are you getting a reference to the action map to disable it?
Ive used the generated c# class and get the inputaction into a Singleton. After that, I use it throught my project
If you actually did this I assure you it would work:
public InputSystemUIInputModule inputModule;
void DisableMap() {
inputModule.actionsAsset.FindActionMap("UI").Disable();
}```
yeah so - the generated class creates its own instance
the Input module is not going to be using the same instance you created when you do new MyGeneratedClass()
so you're disabling a different copy of the ActionMap
Makes sense
Actually if you do (pseudocode):
inputModule.actionsAsset = MySingleton.instance.myGeneratedObject.actions;```
that would make it use the same instance too
then it would respond to what you're doing
But we can only plug the inputaction asset into the InputSystemUIModule and not the reference from my singleton?
I'm confused what you're asking here. We are indeed plugging the reference from your singleton into the input system module here
This is what I've done throught my project. But for the InputSystemUIModule, Ive referenced the InputActionAsset instead of the reference from my Singleton
^^@mortal robin Would this still count as two different instances?
Showing actual code would help because your description here is vague
If you are just assigning the asset in the inspector to the input system ui module, yes that's a different instance than the one you create with the generated class.
Got it!
I'll reference the generated class from the Instance. I think that should solve it.
I dont think the asset and the generated class are two different instances? @mortal robin
they are.
Showing the code for InputSingleton would help
https://paste.ofcode.org/G9htedr8hu9ZZvw2HzBfVs
InputSingleton
right so when you do:
inputSystemActions = new InputSystem_Actions();```
You are creating a _new instance_
So how do I fix that?
https://paste.ofcode.org/B5Emuqxad8s3KrtR9vVxuZ
Ive tried this as-well
But I'ts still not working
@mortal robin
I mentioned what I think you should do
In that case, I can either stick to the InputActionAsset or the generated class
No, as I mentioned here
you can have your input module refer to your singleton
hmm, ill try that.
So like this for example:
https://paste.ofcode.org/zdWVEa8RrqACbsMjWq4ydR
https://paste.ofcode.org/RtujFw4ei3PeHYFrt4iXxy
Isn't that what I've done?
No? I don't even see a reference to the InputSystemUIInputModule here at all
What you have:
- Input singleton creating an instance of the generated class
- BiggerManager referring to that instance from the input singleton and disabling the UI action map on that instance
- Your input system UI input module referring to the asset in the project folder directly and therefore unaffected by the above
What I'm recommending:
- Input singleton creating an instance of the generated class
- BiggerManager referring to that instance from the input singleton and disabling the UI action map on that instance
- Making your input system UI input module refer to that same instance so it will be affected by what you do in BiggerManager
How would I put a text infront of an image in the canvas?
Create a Button - TextMeshpro from the Create -> UI menu and take a look at how the hierarchy is laid out
that has the layout you are talking about, and you can look at that example to see how to do it yourself
Honestly do not understand but heres mine
this isn't that helpful. WE need to be looking at the hierarchy and the components on each object
The hierarchy window and inspector window are very important
I was recommending creating a button and taking a close look at what that actually creates because it has exactly what you want, an Image and a text overlaid on it
I'm not great with UI
ohh
Sorry I just didn't understand what you meant
how does layering multiple ui's on top of each other? i have 2 UI items overlapping each other and one is overriding the other and preventint interactability
Oh wait no it works
im just a bit special
I forgot I had other Images infront of it so It looked like it was wrong
UI within the same canvas uses hierarchy order to determine which displays on top
Lower in hierarchy goes on top
As for "preventing interactability" that will depend on the "blocks Raycast" property of the one on top
ah ok thannk you
if the items are using 2 seperate Canvas's would it be a sorting layer issue?
That will depend on the render modes of the canvases.
Assuming they're both the same type of screen space canvases, then it will be based on the depth of the canvas component
depth as in the Z values?
not sure i understand
Actually I guess it's called different things depending on the unity version
Sort Order in some versions
currently using the 2023 version
Sort Order yes
lower the number the higher in the order?
I don't remember, should be easy enough to test
got it fixed, thanks for the help!
I've done this in a new project.
https://paste.ofcode.org/kZSXtCN5cXJt3mJ6HzvHja
I've changed the Singleton. Now the InputSystemUIInputModule's action asset is referenced properly.
But the UI buttons still seems to click, despite disabling the UI ActionMap.
Disabling the InputSystemUIInputModule disables all UI interactions, this works.
I also wrote this code which finds the object of type InputActionAsset>() during runtime. After running it, seems like two instances are present. However looking at their hideflags -- one of them is flag: None and the other one is flag: NotEditable . So we only have one actual InputAction asset and the other instance is a clone?
@mortal robin
My guess would be that the input module is enabling the actions itself. You can debug this too
What does this yellow lines mean?
That's how the selections flow when a gamepad is used, rather than touching / clicking the element directly
I'm trying to create a prefab with some text on the object, I'm confused on how the canvas system work and how the text renders so how can I make it so that the text is part of the prefab and moves with the object?
Text is made up of GameObjects and Components like anything else in Unity (assuming you are using UGUI)
Assuming you mean the UGUI versions, you would make a prefab with those components on it, and you would instantiate it as a child of an existing canvas in the scene, generally
When you say "object" though, that's a bit vague
What kind of object are we talking about?
Or include the whole canvas as part of the prefab
Nothing really it is a just a cube with some text on top
I'm using textmeshpro, I don't know if its from UGUI
TextMeshPro has both a UGUI (UI) version and a 3D game world version
It really depends what you're trying to do exactly
If you're trying to make it follow a 3D game world object, you can just use the 3D version of it
and then it's not UI related at all
I just want to overlay text on top of the box, the box itself is not going to move ingame but I might create multiple instances of that box, so I want the text to just be ontop of the box wherever I put it
Like a Sign on multiple doors kind of thing
the game is 3D
I want something like this (which what I ended up doing by making the canvas a part of the prefab)
so create the text as a child of the box
you don't need a canvas
oh
the canvas was automatically created when I added text
But you need to use the correct version of TextMeshPro component
because you created the UI version
3D Object -> Text - TextMeshpro
UI - based approaches are valid and potentially viable too
it kind of depends on the details of what you're going for
If you're looking for like "3d text floating in the world" then this makes sense
if you want like... a UI label in screen space that is pointing to the 3D object, you would use UI
hallo
im looking for a bit of guidance and advice with unity UI
ive been messing around with it for a while and from what i can tell it looks like you can take two approaches
one being: items with a defined size are at the end of the heirachy, and everything shrinks until it can't shrink anymore
the other being that everything expands till it can't anymore, with the define size being the container at the start of the heirachy
it looks like you can set up your UI rects in such a way where this behaviour can change in the middle of the heirachy too if you want
but when im making my horizontal and vertical layout groups, each approach seems to require different settings for the layout group
so this affects how i set up my generic Row and Column component, and i'm not sure if one approach is better / more useful than the other
or if i should make both, an expanding row/column next to a shrinking row/column
- i'm also not sure what the 'control child size' options in the layout group are actually doing, cos the doc just says "control child size: controls the size of the child object"
i made a practical example
i made this text deliberately too big, and it correctly results in a height of 111 in the text transform
now i just need the parent object to represent the 111 height of it's content, but it's not doing so, and the content fitter doesnt do anything here either
ok i was able to achieve the behaviour by utilising LayoutElement and LayoutGroup 
Hi, does anyone know why the Vertical Layout Group component introduces an X offset in children and how to prevent it (other than just offsetting the parent)? Padding is all 0, parent has no offset.
that's a dropdown that sets where to align the children.. upper left/ upper middle/ etc
What do you think about this text size? I feel like it's a little big.
Hi, I have a weird bug whenever I spawn another UI inventory object in my grid layout system. The objects are all tilted to left as if I haven't spawned the slots inside the object. When I move (resize) the play window, or deactivate and then reactivate the horizontal layout group that hold all the other UI inventory objects, it just works. I tried manually calling LayoutRebuilder.ForceRebuildLayoutImmediate AFTER spawning the inventory slots in each object but it didn't change anything. Any clue why that happens?
The top bar is the newly spawned inventory bar, as you can see, it's tilted to the left, as if it's centered WITHOUT item slots (the lighter brown squares)
if I close and reopen the hud, it gets set correctly
It is worth to mention that every bar is dynamically created via code: the prefab has no item slots, they are created while reading the source of the inventory (e.g. a backpack, internal player inventory etc)
can you show the code where you spawn it?
Another example of a 2x2 inventory
A great classic, while copying code I noticed that i was spawning the slots in another method and not in the intended one, so it first gets ordered in the grid THEN it spawned slots
thanks 🤣
Hey guys unity localization change fonts
I need to make it so that when I change the game language, the font also changes to match that language.
Whatever code you're using to apply the localization to text can also just apply a font change when needed. Not sure what you're asking.
Its set to center mid and all children have a 50 x offset, changing this dropdown does not change the offset unfortunately.
The arrow cursor disappears as soon as I click on in game view (that's default behavior I guess). So I'm not able to click this Button UI I've created. What do I need to do?
Actually I think the default behavior is that cursor stays in the game view too. So something must have disabled it in my case.
You, probably. That looks like an FPS game so if you've locked the cursor or hidden it for the normal gameplay then you'll have to unlock/unhide it for UI prompts
I used a script (downloaded from tutorial) for walking character. Yeah it has a cursor by default. So to bring back cursor I'd need to edit scripts?
In the code that shows that UI prompt, unlock the cursor. When you click the button, lock the cursor again.
Howd u guys like the UI I've been working on? =3
Can I use a Panel object with only Rect Transformer as an empty placeholder?
I'm not using an empty object because, at scale = 1 -- it does not fill up the canvas.
You can use anything as container, just keep default scale to not skew child objects
A Panel is nothing but a GameObject with RectTransform and Image components.
at scale = 1 -- it does not fill up the canvas
You should not be playing with scale to do UI layout. Use the RectTransform layout properties
Yes, I just did that. Scale was skewing all the children and layout properties were better.
Is there a guide for the best practices, such as this
correct, leave the scale alone
There seems to be 2.0 as well ?
Heya I'm having an issue with toggle groups and toggle
Everything works fine in game, but in editor setting an item to 'IsOn' does nothing, and it's off in game
should be yellow in editor, but it doesn't actually toggle on -- only in game
what are you expecting it to do?
IsOn -> should be enabled by default & Yellow
I saw this on some UI asset I bought a while ago but implementing it myself here doesn't work
enabled by default for which ui element
Wondering if that's expected behavior, like if it should be enabled by default through code?
Yes you can and should enable it first through code
works here just fine though
exact same implementation
(ignore the disc call sound )
hard to say without seeing the full context
Oh nevermind, the Graphic "Checkmark" was the yellow image that was getting revealed
So I guess unity can't just 'select' a button in editor, but it can hide/reveal a 'selected' image
which is how that vid was setup
I run a custom shader in my project. On my Scene window the UI assets run through the shader(not intended behaviour). On the game window -- the UI assets don't have the shader look and runs properly.
Is there any way to make my UI not run through my game's shader on my Scene view?
hello I have a problem
I have a canvas set to screen space overlay and 2 cameras
1 rendering the world and 1 rendering some UI indicators on top , suing a compositor
the canvas does not render ... at all no matter what display i set it to
what am i missing here ?
I want the Middle to automatically fill the space between the Top and Bottom sections.
But when I change the anchors or positions, the Middle section never looks the way I want.
On some devices (like the Samsung Galaxy Z Fold), the Middle area becomes stretched or either too big or too small.
What I want is a responsive layout that looks good on both tablets and mobile phones, with the correct proportions.
The picture in the Middle should always look the same on every device — just scaled a bit smaller or larger, both horizontally and vertically, so the visual proportions stay consistent everywhere.
Hello I have a question regarding mobile UI that I hope some guru can spread some light on.
I am trying to recreate the horizontal scrolling UI from the game Clash Royale and I think I have gotten pretty close but theres a few things that are bugging me:
-
I noticed that on any device thats not a tablet the "panels" of each UI are overflowing on the horizontal axis. I am using masks so if anyone could enlighten me as to why a UI designer might decide to do this its greatly appreciated.
-
I was able to see from their publicly available assets that for some backgrounds they use huge sizes i.e. 2674x3334 however If I am using a canvas scaler and matching height, with a reference resolution of 1080x1920 my viewport is almost always far smaller than even the actual device size let alone the background image size it feels so wrong to me that this is the behaviour we aim for
If anyone can take a stab at explaining these things to me id greatly appreciate it cause as of right now I cant help but feel im doing something wrong
I have a canvas set to screen space overlay and 2 cameras
1 rendering the world and 1 rendering some UI indicators on top , suing a compositor
This doesn't make sense to me. Screen Space Overlay canvases don't render on any camera
They render directly on screen after all cameras have rendered
Did you mean to use a Screen Space - Camera canvas?
Having an overlay canvas as a child object of a camera is... weird to say the least
nope
i meant screen space overlay
it just doesnt render
AT ALL
not even on top of the screen
Even if you use Screen Space Camera it shouldn't be a child of the camera either
does that create issues?
does someone know how i can fix it?
you need to use a VerticalLayoutGroup and LayoutElement components
why are you trying to make it the child of anything?
Should I apply this on the Middle component, or on the main GameObject that contains Top, Middle, and Bottom
What I said describes something you need to do involving all of the objects in the layout
refer to the article I linked
well
it seemed a decent idea to tie the UI to the player character ias it is used only when the player character is in the scene
thanks
found my soultion
dropped the compositor in favour of a custom pass
I'm working on building a stream overlay in unity, have two items in a Horizontal Layout group, both set to flexible width, which allows them to each grow to fill the space of the row. However, when I start adding children to one of its children, it grows, even though there's so much free space. Similarly, adding a Text Mesh Pro child causes it to expand way beyond the size of the text.
I cannot seem to figure out why
The "solution" seems to be setting the min AND preferred width of the row containers to 0. This doesn't actually make then size 0 though, it just stops them from growing randomly.