#📲┃ui-ux
1 messages · Page 38 of 1
the goal is simply to have two columns in a variable-width row that are always equally sized
Vertical layout group sets the positions of UI elements after first update (maybe in late update?) which means you can't get the local transform of UI elements in start, awake, or first update. Does anyone have any insight on when would be a good time to grab a base local transform for a child of a vertical layout group?
I ended up biting the bullet and doing it on late update, I just didn't want to add a late update just for that lol
You probably don't want to be getting the local transform anyway, you shouldn't be touching that for UI. UI needs to be manipulated via the RectTransform
rect transform doesn't have the same issue with vertical layout? I would still need to get local position, to my understanding rect transform generally behaves the same in shared functionality
Gave it a shot, good guess but exact same issue unfortunately.
can you call setlayoutvertical or the other one directly to make it refresh on demand? https://docs.unity3d.com/2018.2/Documentation/ScriptReference/UI.VerticalLayoutGroup.html
I didn't know off the top of my head if it sorts that issue. But you don't want to be positioning UI with the local transform. Use the rectTransfomr.anchoredPosition if you use .localPosition on the rect, you're probably still getting the transform.localPosition
.anchoredPosition will give you the values set in the inspector, so should be valid straight away.
there's also force rebuild layout
The positions shown in the editor are overwritten by the layout group on the first update, so that won't help either then. I will try forcing the layout rebuild / setlayoutvertical
vertical layouts work at edit time, so for everything that's already present nothing should be changing UNLESS there's a change that affects the size of the group
Yep I'm instantiating it.
No luck on either of these unfortunatley. It's simple enough to manually grab the value before I manipulate it anyway, so no worries
Does anyone have any idea why this is behaving like this? It seems like such a simple use case. A vertical layout group has a child which is a horizonal layout group, which has two children that are vertical layout groups.
One would think that setting each of those children to Flexible Width would cause them to each fill half the horizontal group, until one needed more space. But instead they're growing long before they need it.
This is really frustrating. I changed something with the camera (I guess) and now it looks like everything's rendering at half the resolution? I don't understand
What's really weird is that "200" in text size is way bigger in-game than it used to be
This has happened across all of my scenes too. Something real fucky happened
Is your game view window set to 1x scale
yes
I'm calling EventSystem.current.SetSelectedGameObject on a GameObject which is in the middle of being initialised. The GameObject has a component called SelectedHandler. Awake has been called on the component, but not yet Start. The component has the ISelectHandler interface but OnSelect has not been called. Is this to be expected? The gameobject does end up being selected, but because OnSelect has not been called, it does not have the correct custom effects applied to it
I don't think OnSelect will be called unless you actually click to select it.
I do have other menus where SetSelectedGameObject is called and OnSelect is called on the component
this may be a timing issue
Perhaps Awake or OnEnable has not yet run on the EventSystem or something
meaning possibly it's not yet ready to call event handlers?
Just as a test - is it possible to move the SetSelectedGameObnject call to Start() or something like that?
Or in a coroutine with a 1 frame delay?
It is still happening even if I use a coroutine to delay it
Just added some more debug and it thinks this object is already selected
There was some old code which called SetSelectedGameObject on this object while it was still disabled. So that explains everything
The object was not enabled, so OnSelect was not called, but it was still considered selected, and when SetSelectedGameObject was called on it again, it did not call OnSelect because it was already selected
One other problem I have is distinguishing between reasons for a button becoming selected. If a button was navigated to using keyboard or d-pad, it becomes selected (playing a sound effect). If a button was clicked on with the mouse and is not currently the selected button, the on select sound is played, but the on click sound is also immediately played. Is there a way of detecting whether the selection came from a mouse click, in which case I can suppress the on select sound?
Check the type of the BaseEventData in OnSelect
e.g.
if (evt is PointerEventData ped)...```
I'm doing this, but it's showing as BaseEventData and false when I click with the mouse: Debug.Log($"OnSelect {eventData} Pointer: {eventData is PointerEventData}");
Might just try using Mouse.current.leftButton.wasPressedThisFrame
if you're still having this issue, select "Small Bar" and show me the preview pane for its layout properties
Oh, dammit, I didn't scroll down
i thought that was the last message in the chat :p
still, it looks like you've got some issues, so both the Layout Properties and the configuration of your layout group would be useful to see!
hm, that method works fine for me -- my OnSelect method in my menu-sound-maker component does this
public void OnSelect(BaseEventData eventData)
{
if (!target.IsInteractable()) return;
if (eventData.GetType() != typeof(BaseEventData)) UISoundSource.Instance.Hover();
}
I'm checking if it isn't a BaseEventData
I guess I'd check what logging evt.GetType() shows. It should match whatever evt.ToString() produces
Thank you for reaching out! I ended up getting something workable.
could be wrong but pretty sure you need to connect the alpha as well
oh wait you are driving it through the sample texture mb
Hello all
Working on a class assignment, Recently my group struggled on getting our UI to scale properly in our game with different resolutions
Any help + rule of thumbs would be appreciated
For Example regarding above
Player UI is an Empty with the anchor points on stretch
Feedback is also an Empty with anchor points on stretch and their children are images
I feel that maybe we're doing something wrong with the hierarchy or the anchor points but im unsure
Tutorial here describing different modes https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/HOWTO-UIMultiResolution.html
Impossible to say without knowing what result you're going for
how can i fix this
i had this issue and this isnt gonna cause problem. it is just a warning about gizmoz out of screen view
do u use gizmos currently?
yeah
this is because of it
i had this issue in 2 of my projects and it didnt interrupted anything
it is just a warning
so i have to remove the gizmoz to fix it ?
but i want to use it
it prevents me from playing
as i know, it didnt prevent my game from playing. are u sure that it isnt from any other porblem?
no
i tried every thing i cant fix it
and this error doesn't show every time
does anyone know why I can't click any UI buttons when timescale is set to 0?
i have an animator on the buttons and the canvas itself both set to unscaled time
Are you sure it's an animator issue not an issue of, e.g. another UI element blocking it or something?
thats the only canvas loaded at that moment
unless do unloaded menus still exist
it does to into dontdestroyonload if that makes any difference
since its not directly in the scene
but idk
Things in DontDestroyOnLoad exist in the game
check with e.g. IPointerDownHandler/IPointerEnterHandler if the events are being detected
it should be, i have a method in my game manager object that the buttons call
and what's weirdest is that pressing escape (another trigger for the unpause function) works
but the buttons dont even get like a hover animation
check with e.g. IPointerDownHandler/IPointerEnterHandler if the events are being detected
You need to do some actual debugging here
timescale doesn't directly affect the event system
how do i use those
Is there a way to scale a background to text without ignoring overflow completely?
I followed this advice but it ignores overflow: https://discussions.unity.com/t/scaling-background-with-text-detecting-horizontal-overflow/548507
this is something from last year and i dont know if this considers overlap either but maybe it's a rabbithole to explore? https://github.com/IAmBatby/IAmBatby.IterationToolkit/blob/6093096c0ad266cb5f261a907d34027433cf9d4f/Runtime/Scripts/UI/ImageFiller.cs
perhaps if it doesn't you can sample the values off the tmp comp instead/additionally
its used in this console
Yeah, GetPreferredValues did it
I just started testing my app on an actual andriod phone and I have two UI issues that I don't understand at all why they are happening. The first is simply an input field that is not appearing. Any idea why?
it's not anchored correctly
the y position is hardcoded
You want it to be anchored to the bottom, presumably
Don't change the scale on UI elements either. Especially when you don't keep the scale uniform (the same value for all 3 axis).
It's going to cause you problems - change the scale back to 1,1,1 (for everything) and set the size with width/ height fields where necessary.
@mortal robin : I'm not clear, what other option do I have other than an hardcoded position Y? Does it matter if its anchored to the bottom or the top. Either way it is dependent on the size of the parent element (PasswordPanel) correct?
@low pike : I'm not aware of any width and height fields to change the size of the input box. Can you please help me find them? I am new to this.
They're on the RectTransform. Though if you have it set to stretch the fields are renamed to left/right/height
Use an anchor preset that anchors it to the bottom. Yes it's dependent on its parent element. You want to anchor it to the bottom of the parent element
right now you have it anchored to the top of the parent element, with a -173 pixel offset
so if the parent element is significantly smaller than 173 pixels high it will be pushed off the bottom of the screen
You want this one
@low pike + @mortal robin : Thanks for your help. The issue was scaling and me incorrectly choosing my positions/anchors. Everything is running as expected now.
usually caused by the font being packed too close when you create the SDF with the TMP font creator thingy
I got it
Ill try now and send the answer fast
So I tried increase padding in TMP_font Asset 4 to 8 like what you said
and It worked!
Thanks for your help :) @low pike
Heya, in a scroll bar , how do i make the content auto adjust after adding gameobjects through code?
my stuff is all there but the Content stays at 0 height
the content isn't going to get bigger on its own, something has to control it - that could be a layout group
Yup, I have Grid & Vertical, (2 display types), Those sizes are fine but content is 0
Yeah ,ContentSizeFitter didn't seem to work
(or some other layout group, doesn't necessarily have to be content fitter)
Content.sizeDelta = new Vector2(Content.sizeDelta.x, ScrollContentQuest.sizeDelta.y);
This didn't work either, almost like the sizes weren't set yet
Any suggestions?
ContentFitter->Preffered works great on the 2 child prefabs but Content is unaffected
Yeah this seems to be 1 frame behind. is there a way to force UI updateor something?
Fixed it with an inline coroutine that delayed 1 frame, and then set the content size to the proper child size
ContentSizeFitter is not a kind of layout group. You often use it along with a layout group.
For example:
- Scroll View
- Viewport
- Content <-- ContentSizeFitter, VerticalLayoutGroup
- Items <-- HorizontalLayoutGroup
- Item 1
- Item 2
- Item 3
- Cool Picture
- Items <-- HorizontalLayoutGroup
- Content <-- ContentSizeFitter, VerticalLayoutGroup
- Viewport
You can request an immediate layout using LayoutBuilder.ForceRebuildLayoutImmediate
this even seems to be an intended use of that method!
/// However, for special layout calculation needs, ::ref::ForceRebuildLayoutImmediate can be used to get the layout of a sub-tree resolved immediately. This can even be done from inside layout calculation methods such as ILayoutController.SetLayoutHorizontal orILayoutController.SetLayoutVertical. Usage should be restricted to cases where multiple layout passes are unavaoidable despite the extra cost in performance.
This is necessary if you need to know how large the RectTransform is going to be right now
(but this should not be necessary at all, in your case)
appropriate use of ContentSizeFitter and layout groups will make it work correctly
Yeah I tried that but it was still getting size values from the frame before all objects were added
either way the 1 frame delay worked perfectly 🙂
render order in UI stuff is usually a matter of what's first in the hierarchy right? Why isn't this changing if I move it above DialogueUI?
Can you show the inspectors of the two objects? Are they using UI Images or are some using SpriteRenderers?
Also what in the screenshots are "dialogueUI" and "tutorialPopups"?
Ah, nevermind, I had canvas components on the constituent objects of the popup to set their order relative to each other, and it was overriding the render order with other stuff
hey uh guys
i have a background image. i wanna add a title on the background image for a main menu screen. is there any like person who can find me a good font for it . the game is about finding a kids toy its called Toy Trails
nvm
i can mak it
does someone knows how to make UI render first?
I already make the "PerkSelectionAlert" locates higher than other Elements
but It does not working
also all of the child elements has Sorting layer UI(5)
And If i make Canvas to PerkSelectionAlert and change sort order
it works but that makes the child Button not working
I think u have to move the enemy info objects above the perk indicator
UI elements lower in the hierarchy will be drawn on top (within the same Canvas)
Also make sure everything involved here is using the Image component, not SpriteRenderer
And if you're using multiple canvases, things are a bit different
wait
bruh did I remembered completely opposite way
I thought the Children above would be rendered at the top
children are rendered on top yes
not sure what "children above" means
the good way to tell is just where they appear in the hierarchy window. Anything that appears below something else in that window will render on top
That's why enemy info is appearing on top here, because it's lower in the hierarchy
maybe I'm confusing for midnight issue
wait a sec
So The lower the child is, the later it is rendered, and it is located on the top layer.
is it right?
yes
damn I'm so embarrassed
dont be, happens to the best of us
I want to be able to drag a scriptable object into a public field on a UI prefab, and have the UI prefab be populated with the data. Doing this in game is easy of course, but I want it to update in the editor. I tried with a property which seemed to work at first but never printed any debugs, I think it was just assigning to the underlying field unfortunately.
Cheers, just found it too :))
Please stop advertising here This channel isn’t for service promotion
<@&502884371011731486> spammer
am not
i can show you my previous work
this is a unity server
Unsurprisingly I'm not interested in Roblox development on a Unity server. Someone who posts ads to unrelated servers is the very definition of a spammer
!ban 1450105861040246867 spamming non-Unity job postings across many channels, ignoring server rules
@favour768 banned
Reason: spamming non-Unity job postings across many channels, ignoring server rules
Duration: Permanent
I'm seeing this weird behavior with teh label on the right when I resize the window
and i don't know why
These are some of the rect transform values for it
i don't get what a negative value means in this contxt
Similar behavior if I resize the window the other way, changing the width
If I mask a UI image, and then set a button to use that image as its graphic, will the raycast click limit itself to the contents of what is shown in the mask?
I imported a big map image (1920×1080) directly into the scene. Now when I add UI (Canvas/Text), everything feels off scale-wise.
The map is already scaled down a lot, and if I scale it more, the aspect ratios start breaking.
What’s the right way to handle this?
Should I resize the map via PPU instead of transform scale, or is this more of a camera / canvas setup issue?
As you've been told in another channel, this is how canvas ui works. There is no issue here.
Check the game view tab to see how it would look like during play.
sry you have to be wrong iam getting yellowd wehn i start the game
- Reset the scale to 1.
- It could be a totally different issue that you'll need to investigate before continuing with what you were doing.
As is tryed to say when i creat an panal is so big i have to scale it down to 5x5 and then i cant see it in game anymore something with the scaling has to be wrong i resettet all of the rec
It is supposed to be big in scene view. Don't resize it...
Look at the game view to see how it would look like in runtime. Or use a world space canvas.
it was never this way i cant even work proberly can u see my game map instead of the pppanal? its not normal
tryed my map and characters are way to small in the end
You can hide the canvas while not working on the ui.
Either change the camera size or resize your map/character sprites(the ppu setting).
Just to clarify something, UI isn't visually scaled to the objects in the world (in the scene view). The UI in the scene view should look significantly larger than game objects in the scene as they're in screen space (seeing them overlap is simply for the development process). For instance, moving would not have the UI leave the screen. If you're wanting to simply work within world space, TMPro would also allow you to do so (canvas setting) but it's really up to what you're trying to achieve (I'm assuming this is a misunderstanding with the design process of UI)
When I go to scene it looks like the image but when I go to game It looks blue and blank please help me fix it (I did script scrolling UI look at right hand side code below.)
using UnityEngine;
using UnityEngine.UI;
public class ScrollingBG : MonoBehaviour
{
[SerializeField] private RawImage _img;
[SerializeField] private float _x, _y;
void Update()
{
_img.uvRect = new Rect(_img.uvRect.position + new Vector2(_x, _y) * Time.deltaTime,_img.uvRect.size);
}
}
what kind of canvas are you using
ummm idk im new I just pressed create then canvas
a screenspace overlay canvas should be fine
you said you were just seeing the camera's background color in gameview, or what exactly?
Idk it looks like when the screen is empty it just shows a blue square that
so the camera's background color, right
Yes?
idk
Its the background of the game
The scrolling BG script is probably broken. Does it still happen if you remove or disable the script?
that color is the default camera background color, that wasn't a question
Let me see
Nope still blue
do they show up if you use a normal image
let me check
Idk but why do my shapes keep on spawning in huge and far away from my camera?
nope
because they're on your screenspace canvas
Huh?
you've made your stuff insanely small because you've been trying to match them to the camera's worldspace size
your image is showing up fine
yeah
OHHH
select your canvas in the hierarchy and press F to focus it
Oh that would have been nice to know LMAO
now you do 🎉
i mean, code is just doing things, you can basically always solve things with code, but that's not necessarily the best option
you should just make your texture tile properly
tile property?
How do I do that?
In here?
that's not what i said
Oh texture tile property
that's also not what i said
huh
properly, not property
this isn't anything in the editor
just make your image better
the left edge and right edge of the image don't align, that's why you have that seam
anyone know how i can make sure the menu size stays reasonable for different aspect ratios? for some it just turns to a single line for others its gigantic
set your anchors reasonably and (iirc) use a canvas scaler
make sure none of the parents of that button are scaled either
those.. are some massive rects
if it's in screenspace, 1920 width would be the entire screen on 1080p
and the height seems about normal, so probably you have something along the hierarchy where X is scaled
yes i was also confused by those astronomic numbers haha. But i found out the parent parent object, my panel, was set at x 0.30
I only learned today that you should reshape by width and height, and not scale
Hello. How would you go about implementing a static UI bar at the top of the screen in Unity similar to games such as Super Metroid and Shovel Knight? I want the game screen to functionally end where the UI starts and have been unsuccessful at finding any tutorials or guides on how to implement this.
It's basically just UI anchored to the top of the screen
Not much to have a tutorial about
If it has to be pixel-perfect and also scale with various screen resolutions, that's a trickier topic with no single solution to
What it means for a "screen to end" is totally arbitrary
Thanks, I'll try some of that out
happy new year!
im trying to learn the UI system of unity by trying to create a dialogue system, and have a question.
here im using two example buttons using a content layout group to organize them, and it looks fine.
but when i run the game and initiate the dialogue, the responsebuttons clutter. any idea why ?
are you setting the text there at runtime?
yes, i think so. the text is inside some scriptable objects which i assign to the npc objects
it just soudns like they aren't set up to handle that correctly then
perhaps try setting the button text to some longer placeholder text and see if that breaks in the same way
it partially worked! The padding wasnt assigned left enough to show the whole text if it was long enough, so i fixed that. But the text for the two options are still spawning on top of each other, and stays on top even when i adjust top/bottom on the vertical layout group
why does your vertical layout group have negative vertical padding?
ah wait, that's padding not spacing, nvm
have you tried messing with the control child size stuff?
-# i honestly just set those by trial and error... i should really figure out how to use them properly lmao
i think i've found the issue here's my code where i spawn the buttons depending on the number of available responses. However since the only spawn when conversation is initiated, how do i adjust their position ? i mean it's not like theres something in the inspector i can drag around
If you understand my problem ?
well, you'd make sure your UI is anchored and set up properly to handle that
well they are anchored correct i think. Their position is more or less correct, it's just that they all spawn on top of each other. How do i adjust each individual elements spawning position, when theres no game object i can move around ?
well, then obviously they aren't set up correctly lol
How do i adjust each individual elements spawning position
you don't, that's what a layout group is supposed to eliminate
you use the layout group to define how it should be laid out, and then it does it for you, no manual tweaking of each individual element
Haha no you're correct. But what i mean is that the top element is exactly where i want to be. they just all appear on top of each other for some reason. I've set child alignment to top left, and i can change their position by adjusting left and top ( not bottom and right) but even when i change the values of left/top they still stay on top of each other, even if they change their position. Any ideas why ?
is your vertical layout group perhaps overly constrained?
hmm, not sure what you mean by overly constrained. Sorry, im still pretty now to this UI stuff
like, maybe your vertical layout doesn't have enough space to expand down to accomodate the buttons
i'm not super well-versed with UI so this is mostly guessing at potential issues rather than knowing what mightve happened tbh 😓
ok so my thing is not scrolling.
QuerySlots has a scrollrect and a rectmask2d.
Scrollable has a grid layout group, but it's not auto-sizing, and when i put a contentsizefitter it shows a warning saying i don't need it in a grid layout group. But apparently something is wrong because the grid layout group is not growing to fit the new slots
guys can somebody help me TMP_InputField is typing but text not visible
Does the default component work if you just drop it in without changes?
I figured it out! I had assigned the vertical layout group one spot too high in the hierarchy, and therefore needed to move it one object down
Should be working just fine, check the settings. Are you adding things at runtime?
i fixed it by having a contentsizefitter anyways, on the same gameobject as the gridview
and now it's not scrolling again, idk what is wrong
i added a scrollbar, that's it
i have it set to clamped and it does nothing, but when it's elastic it works half of the time.
It reacts to the size of the Content element. So select it to see its gizmo when you moving the slider.
(if content element size is fitting the window already, or nearly so it wouldn't be moving)
I don't see anything when enabling gizmos
or not for the selected item
i see other gizmo things
ok so it only scrolls when it's hovering over a slot
also it doesn't update the scrollbar, even though it's pointing to it in the inspector
Does someone know how to fix the jittering Im using pixelperfect camera
how's your camera set up? is it following the player, a child of the player, etc?
just set up a nice timeline grid using the Grid component, a Scroll View and a bunch of rects
what would be the best method to add visible grid lines to this?
(Note: watching until 0:18 of the video is enough, the rest is just me showcasing the grid numbers)
(the Grid component doesn't do anything right now, but it is correctly updated, and I would like to be able to utilise this if possible)
is there a way to add a panel into a script? (preferrably by using public)
making it public gameobject doesnt let the panel enter
making it public panel doesnt work either due to "security level" or smth
and trying to get it by it's recttransform doesnt work either
can anyone help?
this has way too little info
oh this was 3 hours ago
please don't crosspost for future reference
The Panel object you're talking about is a GameObject with a RectTransform component and an Image component on it
depending on what you're trying to do, any of these would work:
GameObject, Image, RectTransform, Transform
ok basicly the ui doesnt work when i start the project
editor
in game
the test input work but when i try to put in game doesnt work
can you show the scene view (of the text object) when in play mode
Write out “Ammo: 29 / 30” outside of play mode to see how it looks and if you have the same problem. You may just need to make the text box larger.
Not a good test to use a different text value. Use the same one
@ruby shell there's 2 components for tmp text, one for UI and another for worldspace
you have the worldspace version there
add the correct version and remove the wrong version
it's not like, a setting you can change, they are separate components
im really not understanding sorry
what part of "add the right component" do you not understand
where i add a componnet
you could probably just create a new gameobject with the right settings instead, that'd probably be easier
however you created this one, do the same thing except pick the UI text
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thanks
Has anyone got any idea on how to properly scale the Canvas (UI) for a pixel style game? My resolution is 320x180 and my PPU for all my sprites is 32. I've created a health bar I want to use for my game and made it in a UI with a image and a slider for the health bar itself. When I imported the sprite it was 64x16 as I wanted it to be about half the size of the actual world grid and length of 2 world grids. When I manually add sprite onto the scene without canvas it looks actually really good, but when added to a canvas and set to native size, its absolutley massive on the scene now. I've tried making my UI Scale With Screen Size specified X and Y and also match to 0.5. Tried playing with PPU on canvas Scaler nothing happened tried setting my sprite to 1 PPU as I've asked chatgpt if it could give me an idea and nothing changed there. I'm kinda running out of ideas as this is my 1st ever pixel project and kinda lost of the UI front of it as I need to make a lot more UI stuff and I'm unable to get HP bar to work correctly. 🙁
@solar herald let's continue here.
have you checked the Include Font Data option in Font Import settings?
import settings for any given file are visible in the inspector when you select that file
There is absolutely nothing here. I'm following a guide on youtube on how to create this dual coloured pixel perfect font and its from 2022 but he just creates an asset and is able to extract the atlas so he can edit it as atlast created becomes a single white colour instead of black outlines with letters being white. Ive done everything step by step as needed. Unity is being absolute pig about this.
If I put in Dynamic mode I options for Include font data
With Dynamic I'm unable to extract atlas from the asset to edit it
ok, one thing at a time. with tmp you can specify a custom set for the atlas with the tmp font asset, so im pretty sure dynamic is a step in the right direction
what's the issue you had with extracting an atlas
there isnt an option to extract atlas with dynamic option thats the issue Im having but idk if custom would change that.
real quick, are you intending to use tmp (text mesh pro)
Yes ofc
have you generated the font asset?
the font asset is what you configure with tmp stuff afaik
yes but im unble due to font ass in dynamic breaks pixel perfect and make everything blurry
trying to use bitmap but that aint working rn either
dynamic is unrelated, dynamic just means the characters imported are dynamic
the render mode is what you'd configure for this if i'm not mistaken
shit mb forgot to add my proper render mode. Okay now its the atlas time
Now that I have font asset I cannot extract the atlas.
This is my atlas its does generate it but I need to edit this with my dual coloured font where there is black outline
mm, i'm unfamiliar with that aspect
what do you mean by "extract the atlas" exactly?
Here I made bitmap asset from my original TTF and it has the ability to extract font as PNG which is linked to the actual atlas. If you edit that PNG and swap all the atlast with correct black and white you're able to get dual coloured font pixel perfect.
Does that make sense? I hope
But when I use maker for asset it make that what it is instead of the actual asset where I cna extract atlas from
the font asset thing made the top PixelPerfectTinyFont?
that's not right, make sure you chose the tmp option and not the text option
HOLY
I got the atlas
How and why was is making normal text and not tmp
I have no idea Ive been battling unity for last hour or two for this going nuts
probably because you chose the wrong option? the tmp and text menus are right next to each other so couldve just been a mouse slip
they also loook idetical
they have different icons, they're different asset types
thank you for noticing this I will go try edit the atlas and see if rest of the step work,
Yeah I have no idea what a normal text asset looked like until now
the tmp font assets have that capital F thing
@steep warren You know how to make custom work? because Dynamic is just not doing it. Its messing up all the characters and only 1st character works from custom font.
the characters option is just about what's included in the atlas, it doesn't have to do with rendering
nvm I got it to work its really quarky but pixel perfect does work I can now scale font size and its pixel perfect on screen and no blur what so ever
hey yall quick question
how can i have an UI image have its size stretch/shrink to fit different image sizes?
example:
the second one is a wider frame but i want it to stretch
ive got a free pixel font but some letters and numbers are not pixelated ? is there a setting i could fix that
I think you should use preserve aspect option
@neon field you can align as you want by having your elements use anchoring correctly and have the layout group expand width
The elements need a parent container that gets force expanded and inside is where anchors get set
The thing is that I putted my player prefab bubble with an anchoring top-right and the npc top-left but it still doesn't work
It can't be the object that's in the scroll rect content
Actually it works when i remove the vertical layout group from my content (Scrollview component), but it's this vertical layout that manage the fact that the bubbles doon't overlap each other
You need an additional gameobject
So:
Content
-> Element parent
-> -> Bubble image
-> -> -> Text
The things inside element parent get their anchoring set to the left or right
Hmm, I'm maybe too new to this, but like, my bubbles are basically two prefab object with the image of the bubble being the root, and having a text as a child. Then i have my Scrollview which is a child of my canva. And the bubles are added to Scrollview -> Viewport -> Content with a script
Oh
Like I'm supposed to have one more parent in the content of my scrollview where the bubbles get added ? Is that what you meant ?
assuming tmp, make sure the character sets are set correctly (perhaps dynamic)
Yes. "Content" is your scroll view content that also has a vertical layout group on it
Can the default ugui toggle be made to stay a certain color when "is On"? I just want a color effect on the toggle, not an image or animation change
But the docs do not even cover the "Selected Color" in the inspector!!
I think this is a missing option from toggles which expect the 2 image method, I used a modified button before and custom code
That's what the Color Tint transition is for
Hey y'all, I'm making a book UI for my game and I'm trying to achieve one-sided text so the text only appears on one side of a page. I tried using the same shader that I used for the images but it just screws up the text. Would someone be able to point me in the right direction? Cheers
Wdym by "one side"?
Is this a UI question or something else?
What components is your book made of?
Yes it's a UI question. And what I mean by one side is I want the text to only show up on one side of an image because they rotate like pages in a book.
The only components it has is the script that tells the pages to rotate. Other than that, it's just the default UI components edited to work with the script.
wdym by "default UI components"?
We can't figure this out without knowing what we're looking at here
are these SpriteRednerers? Mesh Renderers? UI elements (UGUI? UI Tooklit?)?
This stuff (sorry, I'm not very savvy with Unity yet. you'll have to bare with me here)
And what Canvas render mode is your canvas using?
Screen Space - Overlay
Ok so I'm a bit unsure what you're trying to achieve here
WOuldn't you just disable any UI that shouldn't be visible?
Are you rotating it or negative scaling it or something?
Also where does a shader come into play here?
I'll try to explain what I'm trying to achieve here the best I can: So what I'm trying to do is make a book UI that you can flip through the pages of. Right now, each page is an image that rotates around a specific point to look like turning a page. Each of those pages have images that use a shader I made to mask them to only one side so you only see whatever images are on that one page rather than all of at once (if that makes sense) and I'm trying to do the same thing with text but unfortunetly the shader doesn't work with TMP as it just makes the text a bunch of black boxes
The shader basically acts as a mask so the images on the page only show up on once side
honestly if you're trying to do a 3d animation I would avoid using UGUI entirely
use actual 3d objects, it will be easier
I'll look into it
The thing is, it's not 3D. Just a script telling UI elements to rotate like book pages.
otherwise - i would just disable the component when it's facing away from the player
that's much easier/simpler than a custom UI shader
it's inherently creating a 3D effect - the effect of flipping a 3 dimensional page in a 3 dimensional space
I might just try that. This has been a headache for me already
Right, makes sense
I have 2 bugs. In QuerySlots there is a ScrollRect and RectMask2D. in Scrollable, I have a GridLayoutGroup and a ContentSizeFitter.
The 2 bugs are:
- The scrollbar does not update at all
- The panel only scrolls when my pointer is over a Slot, if it's between the Slots, it does not scroll.
- It also lets me scroll out of bounds
i fixed 1 and 3, but it still only scrolls when i am hovering over a Slot (The viewport was supposed to be the parent of the scroll content)
Fixed 2 by adding an image component to the same GO as the ScrollRect, and setting it to transparent
i have a curved slider
when the sliders value is set between roughly 1 to 0.7, theres no difference
only when it gets below that does the slider work visually
how can i get it to show for all values
Put in a solid image, then you'll see how it works and can adjust range with code.
You probably want to limit it to 0.150-0.850, if you put it on a non rotated image.
preserve aspect just makes the sprite smaller to fit inside the pixel requirement for the image
i want the image to grow to fit the image at the same resolution
For redering 3d shapes in a UI, do i really need to put the canvas into a camera object? (Changing it to "Screen Space - Camera")?
You need a Screen Space Camera OR World Space canvas yes
not sure what you mean by "put the canvas into a camera object" exactly
Screen Space - Overlay will always draw on top of everything else
(Screen Space - Camera) is what i meant
There is one other option though - you can render your 3D object to a RenderTexture, then draw that texture in any kind of canvas (including Overlay) with the RawImage component
But if you just want to render a regular MeshRenderer over UI, you can't use Overlay
will render textures be viable for an inventory system?
for an inventory system, unless you have a really good reason, I would just pre-render your items as sprites
and use the regular Image component
If you have a lot of different item types, you can automate this process.
Hmm... eventually i will have items with custom data that will chnage the visual, i could cache them probably,
ok so i am looking at a tutorial that is putting the item itself into a scriptable object
it'll be the ground item probably
can i can still use a json object for a scriptable object?
I don't really know what you mean by this question
like can i use a json to auto gen scriptable objects (for editor)?
a common pattern for inventories is something like:
- A ScriptableObject defining the item
- An inventory that contains references to the SOs
- An "in-game" version of the item that also references the SO
- A UI element that references the inventory data
you sure can but I'm confused at what the point of that would be
you can write code to do whatever you want though
if you want to define your items in a JSON file, just do that
the point of ScriptableObjects is to be able to define and work with, and reference, the objects in the Unity Editor directly
is a scriptable object like a class where it is assigned for any type of item, or should i have one scriptable object per item?
a scriptable object is an object, an instance of a class that derives from ScriptableObject
make sure you understand the distinction between objects/instances and classes/types
each SO represents some static data, a kind or a type of item in this case
then the actual "items" would reference an SO to know which specific item it is and what properties it has
Is it possible for me to see UI elements in the Scene view?
They're all invisible so right now its hard for me to adjust anything
All the layers are on as well
i have some text inside the choice button, i want the choice button to expand to fit all the text, and the choices to display the choice buttons vertically. this is working well right now but i want to add animations to it, which apparently i need a layout element for. adding a layout element messes up all the formatting i have already though, i tried it with and without all the other components but it doesnt work. anyone know the proper way of doing this so i can also easily animate it?
maybe im misunderstanding your question but you should be able to see them on a huge canvas at 0,0,0
select your canvas (or some UI element) and press F to focus it
if it's screenspace, it'll be in screenspace units instead of worldspace units
Hey I could use some help, in my game I have split screen with the input system but when I have 2 players the UI doesn't shrink down to show everything so the score at top right corner and the ability icons in the left corner can't be seen. How could I make it work?
Anchor everything correctly.
When this happens, it usually means you have everything anchored to the center, and not the sides/ corners
How do i fix this behavior with the the RightText label?
So that it doesn't hit the slider if you resize the window?
These elements should have a parent, and on that parent you should have a horizontal layoutgroup
THey are all in a parent as you can see in the hierarchy window
but putting it into a sub parent causes more issues with the overall control @low pike
if you don't show what those issues are, you won't be able to get further help..
Organise the slider so it has its own parent. Instead of being 3 or 4 sibling game objects
Should be something like
horizontal layout
- left text
- slider
-- slider element 1
-- slider element 2
-- etc - right text
you don't want the horizontal layout to be controlling each individual element of the slider, which is what you have atm
oh huhh
When you create the slider from the right click menu, it's all under 1 parent.. that's how it should remain
Hey I am trying to access the color part of the Image component in the UI RawImage, in my code. I want to change the colour of the UI Image based on a variable trigger. However when I am trying to run the following code it is making every UI element fully transparent.
If you could help me out with how to change the colour of the RawImage through code.
[SerializeField] GameObject dialogueCard;
public Color horenColor;
public void ColourChange ()
{
if (colourTag = "horen")
{CardColorChanger(horenColor)}
}
public void CardColorChanger(Color cardColor)
{
dialogueCard.GetComponent<RawImage>().color= cardColor;
}
First tidy up the code and get rid of that GetComponent - you shouldn't be doing this everytime, cache and re-use.
[SerializeField] RawImage dialogueCard;
[SerializeField] Color horenColor;
public void ColourChange ()
{
if (colourTag = "horen") {CardColorChanger(horenColor)}
}
public void CardColorChanger(Color cardColor)
{
dialogueCard.color = cardColor;
}
What colour has horenColor been set to in the inspector? -> show a screenshot
this is the inspector
that black line under the green means the alpha is set to 0
Ohhhhh
I am so stupid
sorry I did not even see that
we all make small mistakes like this, no matter how experienced
I am completely noob to technical stuff tbvh
also why did it make all the UI elements in my project transparent??
I only put the reference to the specific UI image object
unknown from the information provided so far
ah okay
hey thanks
It is working perfectly
thank you for helping out
the "RectMask" won't expand to fit "Credits (TMP)" What's going on?
can't tell for sure, because you've cut off the recttransform from the credits game object... but it looks like you might have credits anchored to the bottom of its parent, with the pivot set to top left... so it will always been outside of its parents rect
what is this error? it was fine before, I had just reopen my unity and it's like this now. I don't think I've never mess with GUI or some sort
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
oh, this is not a #📲┃ui-ux issue
the error you're referring to is an internal error iirc, you'd ask in #💻┃unity-talk
oh okay thanks
Hello I was told to ask this question here if someone can help that would be much appreciated
any idea why my panel has UI elements passing through it? I thought I fixed it by changing the waiting canvas' sort order to 1 (and keeping the other one at 0) but that doesn't work in play mode for some reason
you haven't provided enough information, and you've cut off the hierarchy
And just to be clear, the project dice and buttons should be hidden behind the waiting for steam..?
yes
I think I fixed it, the project dice canvas didn't have a background panel and that seems to have caused it... maybe?
not sure how that works
if you don't put an image on a gameobject, then there is nothing there to block the view
a "panel" isn't anything special, it's just a premage game object with an image and assigned sprite
yeah I'm just a little confused on why that matters when the Steam account panel should be obscuring the other UI stuff anyway
but it works now somehow
how can I add a drop shadow to UI elements?
Not sure if this is a good place to ask about this issue
I think the issue may be related to UI layers but not entirely sure
Welp turns out the issue was just I had to adjust the order in layer on the particle system itself
Anyone have any of the top of their head idea on why my menus don't react to mouse cursor at all? I was building them with gamepad in mind mostly, so they all navigate with gamepad/keyboard. but I wanted to properly support clicking around, added a custom cursor, and a Cursor.visible = true on menu open. (and lockState=None)
made sure only the image component on the gameobject with the "Button" component has raycast target checked (removed them from nested text labels)
I'm using screenspace - camera with the camera set to my scene's main camera. (but I tried to switching to overlay just to test, and still no clicks/hover events)
does each Canvas in the hierarchy have a GraphicRaycaster and are all CanvasGroups interactable? fwiw, all Graphic components below a Selectable contribute to the interactive area of that Selectable, they do not block the Selectable they are part of.
How would one find the center-most selectable item in a scroll view? I'm working on controller navigation and created a script to scroll an active scrollview when the object selected in the event system is a child of the content rect by using the right stick. However, this signal does not signal to the event system to navigate to the nearest visible or available content item. Struggling to think of what the best solution is, or if scrolling via stick is even a good idea.
I've seen it done in other games and to me it feels intuitive... if you're in a vertical scrollview, move the right stick up and down to go up and down. Maybe it's not as common as I thought, but, yeah, if I do go with this navigation solution, I would love some ideas on how to navigate to the center-most object.
You can simply pick the middle item, but if you have many items its often not such a good idea to keep them all instantiated, then your math/pooling/updating gets more complicated. If your items have different sizes, you need to make some sort of 1D spatial lookup where each content item's rect registers its area. On a gamepad pages can be a better UX than a scoll view, but that depends on the specifics of the design.
Transform content;
Transform middleObject = content.GetChild ( content.childCount / 2 );
Ah, yeah, in this context I mean the middle item relative to the viewport.
However, you may be correct that pagination would be much better here rather than a scroll view. I may implement that instead for this use case if this gives me any more trouble.
A friend of mine at another studio mentioned instead of controlling the scrollbar programmatically, instead using the right stick to simulate a faster UIVertical input and then snapping to selection. I'm currently trying to use a UIScrollToSelection I found on UIUtils but unfortunately doesn't have a setting for an offset (to overshoot the scroll) and I had trouble decoding it to redo it myself.
Maybe I'm thinking too hard. Console compliace/controller support for the last 2 weeks is frying my brain lol.
Here's the video example
a brute force way is to calculate the rect-center-position of each content object in the viewport rect-center position, then find the item with the minimal distance.
you can optimize that by adding each rect to a spatial lookup data structure so the "what is close to point X"-question gets cheaper.
you may want to have a look at RectTransformUtility to help with the calculations https://docs.unity3d.com/6000.3/Documentation/ScriptReference/RectTransformUtility.html
thanks, it turned out to be that I had a PlayerInput component handling my gameplay input, and since all my actions are in the same inputactionasset that has a "UI" map, it was seemingly "eating up" the ui events? Anyway disabling that component when I open my menus seems to fix the issue! (I was previously just disabling the "Player" map)
But this is breaking other stuff (I'm adding a callback to playerInput.onControlsChanged ) and it looks like disabling and reenabling it looses my bindings? I feel like I'm fighting unity and doing something wrong.
Should my EventSystem driving the canvas use the same inputactionasset as the gameplay player input? Or should I use the autogenerated default one that gets created with a new EventSystem? Whats the best practice for pausing player inputs when menu interactions are open? disabling the PlayerInput? Disabling the player map? (I've seen suggestions to call SwitchCurrentActionMap but this didn't seem to work for me...
And bonus question, outside of ui/ux topic maybe, it seems that pressing Escape when playing in editor takes away focus from my game. This seems to be editor specific behaviour, can I turn it off?
I have a text input on the bottom of my screen. When I click on it, it gets completely covered by the keyboard. Can I please ask for guidance on how to handle this? I have no idea what to do but the user experience is horrible as it currently sits.
Heya guys, how can I get my items to overflow to the left instead of to the right?
I imagined "Middle Right" alignment would do it but nope. They align correctly until it's full and then overflow to the right
middle left?
Same, they align to the right/left based on that dropdown but once it's full they shoot off to the right lol
I tried changing the rect anchors, pivot, reverse, etc
I don't think I've done this before.. I'm willing to bet there isn't a built in way and you'll have to code something for it
Yeah thought so, prob just a unity oversight. Thanks!
Was planning to shrink them inside the box anyway, was just curious about this 😛
try reverse arrangement, maybe?
ah, you've tried that, never mind
Yeah I think it's just something unity didn't think of. Everything works perfectly until overflow, it always goes to the right no matter what lol. Can be easily fixed with a nested object though if needed, though tbf the box should just be big enough to begin with 🙂
what if you add a content fitter? maybe that'd respect the pivot
Nope it just made the box bigger lol
does it not make it bigger in the correct (left) direction?
It does yeah was just curious about overflow, but that's bad design anyway (I wasn't even using it)
So I doubt it'll be a real issue for anyone
i'm confused, doesn't that solve the issue then
it expands to the left so the rightmost element stays in the same spot, no?
I was just curious, items aligned to the right are added to the left, but then overflow back to the right. Wasn't an issue I was specifically trying to solve. Just one of those things you kind of expected to behave differently 😛
Wasn't planning on using it, just one of those "huh, interesting" moments 😄
is this a dating action game or something? it looks so good
Dating Card Game 😄
thats such a sick idea
Thank ya thank ya. Fingers crossed I can get it steam deck verified before valentine's day lol
any idea why textmeshpro UI text component's overflow setting doesn't work for me at all all of a sudden? no error or anything - yesterday I was getting the warning that ellipsis doesnt work so it would default to truncate, today it doesnt even truncate
wait im dumb text height is too high
still weird that it lets me change to ellipsis now tho
I feel like I'm going crazy - it randomly changed again and now I can't use ellipsis and it changes to truncate again
same font as in above screenshots
at this point I'd reimport the TMP essentials, mebbe something is wrong with that font asset
I'll try that, thank you!
hmmm that didn't work, but restarting Unity worked
so weird
Is there a good way to get an event subscription for when a TextMeshProUGUI's text changed?
Wanted to make a helper script I could apply to a dropshadow text obj to always mirror another TextObj without the overhead of a loop.
I tried checking out the TMP_Events but the documentation has no examples, and I couldn't figure out how to use it.
No, but you can simply introduce your own abstraction
Well I guess you can use this maybe?
https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.2/api/TMPro.TMP_Text.html#TMPro_TMP_Text_OnPreRenderText
I believe I got it! On pre-rendered text event, just have to check if the obj matches the one I plugged in
Does anyone know why this image isn't fully opaque? I have this worldspace blackout screen thats still marginally transluscent.
I made sure the alpha was 255
the shader is for making it render over everything
Apologies if this is the wrong channel by the way
Do you think it's not opaque because you can see the scene grid through it?
I can see the world through it
What type of canvas is it? World space?
oh, must be - looks like it's for VR
In that case, I'd suggest your material/ shader isn't setup correctly to be rendered last
Yeah probably
I set blend to off and it fixed it
but this means I can't do transparency like fade to black
currently its just a binary switch
ill have to revisit this issue tomorrow because I can't keep my eyes open
3 am debugging
im fresh from bootcamp when it comes to unity can somebody explain as to why the green doesnt stretch from left to right and just becomes a blob
the image file assigned in the sprite field isn't square
I coldn't find square anywhere
..make one?
or just remove the sprite, the field can be left empty
if you're expecting it to stretch just the green part, make sure it's set to sliced, this looks like a non-sliced sprite
Hi, wondering if anyone can give me some advice I have no clue when it comes to designing good looking UI and any feedback and tips on how to improve my design would be appriciated. I don't think it's very good but don't know how to improve it or what about it makes it feel bad. It's the UI for menu in my VR game that appears in front of you in world space when you press the menu button. You select things via a ray interactor originating from the hand.
Ignore the font for the discord part I meant to change it to match the font for everything else just didn't notice it
you could start by looking at the design of games that look nice to you and copy them, from that learn the language and rules of creating such designs. Acquiring taste and eyes that 'see' design choices takes time, deliberate learning and practice (trial & error). There are no 'tips' that shortcut the learning and improving an individual screen is not what 'good design' is about.
There are many starting points. I would recommend reading at least one introductory text that goes over the basics. Example: https://ellenlupton.com/Graphic-Design-The-New-Basics
This gives you enough understanding to plot your own course towards the goals and topics that matter to you.
I wasn't really planning on doing a deep dive into UI as I really don't have the time for it and there won't be much in my game compared to everything else I have to do. Just wanted advice on what parts of my current UI need improvement and ideas on how to implement more aesthetically pleasing elements.
everything about it needs improvement.
Great, thanks
#1180170818983051344 is a better place to ask for feedback but you can get far by increasing the opacity of the button backgrounds, changing the button font to something else (the font is fine for titles but not for buttons or body text, the "Join the Discord" font is better for that), and fixing the "thank you" text so that it's not squished and black on dark background
Thank you will do 👍
hey guys so I will start to design my game's ui like main menu, settings and player hud. So there is a new thing called UI Toolkit with Unity 6 but should I use that or should I use the old canva system. Which one do you prefer?
they serve different purposes and arent drop in replacements for each other. toolkit excels with lots of data, panels, menus, UI like the unity editor. Canvas UI excels by being well integrated with prefabs and scene hierarchy flows, it makes it easier to do 'rich' UI, HUDs, 2.5D world-space UIs etc. You can succeed with both. The main selling point of toolkit is that it promises to make style-consistency and maintenance more manageable as a project & team grow.
So for a indie game developer, using UI toolkit for main menu and settings screen then using canva for player hud design would be the best option if I understood correctly.
Is there any way to add canvas specific grid/guides? I want it so I can align my elements in the corner accordingly.
not sure about guides in scene view, but you could just set its top and left margin manually to the same value
assuming that it's anchored to top left, which it should be
Let me try
Using two frameworks creates overhead you don’t want. A settings screen or menu can be achieved easily with either. Toolkit is good for ‚lots of menus and data‘, not for ‚the odd panel with a few extra items‘. That said, you can choose either one and be successful, just in different ways. If you’re making, for example, a colony simulation with many inspectors, dashboards and views into the simulation data, toolkit is a natural candidate that solves many practical issues that canvas UI has in that situation.
canvases sort rendering top to bottom in the hierarchy
the sort order you see there is for the entire canvas, compared to other canvases
so your dialogue there would indeed be rendered on top of the fading screen
presumably your fading screen would only be fading at runtime, since that's something that happens over time. so i'm not sure what you're seeing when you say it's behind the fading screen in edit mode
what's your question
Do you have any sub canvases or just the main one?
Because your second screenshot omits the useful information of the gameobject name 😐
oh
they are all sub canvas
let me rename them
but I don't know why the fading canvas is not above all of them
By using sub canvases and using "override sorting" you fuck with the normal sorting scheme
oh
Sub canvases main purpose is to isolate some UI graphics/text to optimise rendering
You can use override sorting to force things to draw on top of other things but it seems to have caused the issue and confusion here
Id stop using this option and then make sure this fade/loading screen is at the very bottom. SetAsLastSibling() can be very useful for this.
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Transform.SetAsLastSibling.html
@trail flint
i will check it , thanks
If I maximize the game view, the purple UI element moves towards center. I want it fixed towards the corner like the 1st image. I'm not sure what's wrong.
It seems like it's happening because of PrimaryObjectives game object. I've set its anchor to center. But that shouldn't cause issue? What's happening is, the PrimaryObjectives rectangle changes its size whenever I resize game view. That's the reason that UI also moves. I don't know why rectangle is not same size as canvas all the time.
As you can see, the PrimaryObjectives outline and Canvas outlines are not aligned.
Found the issue. I just needed to set anchor as stretched.
The problem is you have it anchored to the center
you want to anchor it to the top left
teh canvas is the size of the game view. The canvas therefore changes size when you resize the game view
hey didn't i tell you to anchor it to the top left earlier #📲┃ui-ux message
and the game view you have set to free aspect, which is why it changes resolution when you change the game window size
Left worked but I chose stretched as I want to position other elements too in other corners .
That was child of this parent object. I'm still figuring out that.
so have the parent stretched and the child anchored to the top left
That's how it's done right now. Currently, it's fixed in corner as I want. But, I still can't manually give equal padding on left and top. If I see Transform panel, and put equal values, it's visually not equal. I would show a screenshot later.
hm those are in px so it should be equal
keep in mind that the child will be anchored to the top left of the parent, so make sure the parent extends to the top left
or you could have the margin on the parent and none on the child
Here. Note the X and Y position values, 200 and -50px. If I put both 200 or -50, the image doesn't have equal margin. I guess it's because image is rectangle, not a square.
But the other solution as you said is, give margin to its parent element which I stretched. That should also work.
it not being square shouldn't be an issue afaik
oh it's because the pivot is in the center
you would also move the pivot to the top left
Ah. This blue icon is pivot right?
yep
Hi everyone I have a problem with my ui sometimes it disappears in some devices
And I have a video for the issue I have
(Note: I am working on a mobile game for IOS and android)
(Note2: I use pixel art for my game and in the scene menu the ui is still there but in the simulator it doesn’t show up)
most likely it's not anchored properly so it falls off the screen when displayed at the resolution on your phone
use the game window settings to test various resolutions, especially those of the target device
When working with mobile, don't use the game view at all. Use the device simulator, change the selected simulation device to test different resolutions
Hi friends, I’m looking for a blur effect between UI elements. I’ve searched for this, but I’ve only found solutions where game objects behind the UI are blurred. Does anyone have an idea how to blur a UI element that is behind another UI element?
render the UI you want to blur on a camera (using a screen space camera canvas) and apply postprocessing to that camera
@mortal robin Thanks for replay, which post processing effect is work for this? motion blur is for moving objects
depth of field can be used for a blur
How Do I Hide Horizontal Scrollbar And Make Vertical Scrollbar Look Smaller
untick the 'show' bool on the scroll area component
Bruh... I Don't Saw This :P
You need to learn the basics of Unity to be able to understand the help given.
Things to learn for this:
- what the hierarchy is
- what the inspector is
- what a component is
- what a gameobject is
- where values/ vars/ bool/ etc would be displayed for a component on a gameobject.
Sometime... The Chat Was Too Small To Type
make it anchored and stretched properly to be responsive to various resolutions
And set the canvas scaler component appropriately
I.E. 1280x720, and "match height"
Every canvas in my project is set to this and in the player pref i set the preferred size to 540x960, but when I make the web build it has a relatively large excess for scrolling. My display res is 1920x1080, is there smthg im doing wrong ?
Really New To Unity :P Sorry If I Distrub Someone
I made this mockup in photoshop, but how could I make a per player event system that is limited to a certain set of UI elements to accommodate something like this?
The new input system has a "multiplayer event system" designed for this:
to be honest I'm not sure from your mockup what you're referring to exactly though
I'm talking about separate controllers controlling each box only
it's hard to explain via text
but like basically when you select your character your controller is confined to your quarter and you can navigate that sub menu and only that sub menu
this multiplayer event system looks good though
thank you!
sure the mockup looked like all 4 panels were related to the same character so I wasn't seeing it the way you're describing
but I understand what you mean
oh right, no the mockup was just showing all the possible windows that could show up on one quarter
but yeah it looks like the multiplayer event system is perfect for this
Sorry so what resolution are the best for iOS devices and android?
I am using the simulator to see how my game is going
resolution of what? You mean what to set the canvas scalar reference res to ?
Yes
I’ve read online that the Pixel Perfect Camera solves the issue but it didn’t
Pixel perfect camera has nothing to do with this, it won't make a difference to your issue.
Set the reference resolution on the canvas scalar to whatever resolution you used to design your UI in Photoshop (or whatever).
In my last job the designer always used 1080x1920
can you actually show the issue too
Thx man I appreciate it
I am using pixel art for the art direction so I’ve set everything to 640X640
no you wont
Here it should be showing the ui
Pls don't share photos, use screenshots
and it's helpful to include the whole editor window
When it's in this state, you need to investigate.
Look at the scene view, look at the UI in the hierarchy.. is it active? is it setup right? etc
Will I can’t get the screen shots rn when I get the screen shot I will send it here thx for the help 🙏🫡
is the resolution of the build determined by player preferences or the resolution u select in the game view
neither. It'll be the Resolution in the Player Settings in your build profile.
@mortal robin Hi, I have use gaussian and bokeh mode in depth of field effect i got the amount of blur i want from bokeh mode but letter i come to know that its not working on android, so i transfer to gaussian blur but with that i can not get the maximum blur i want. is there any way to do this with post processing?
you may need to look for third party/custom postprocessing effects
Hello, i am using TextMeshPro -InputField in my mobile app and i am facing issue with virtual keyword, like when i select one inputfield and then select another the vertual keyboard kind of flicker first its disappear and then reappear how to solve this issue.
Is there a good free resource to look at common ui templates/formatting for portrait-orientation iOS game In-App-Purchase shops? I’m working on one but feel like I’m trying to reinvent the wheel when it comes to where to put things
Just reference images
I’m not really a UI/UX designer so it’s not super intuitive for me, so referencing common patterns would be really helpful
maybe check out https://www.gameuidatabase.com/
i tried searching "shop" and filtered for mobile there, and there are some portrait results, but i couldn't find where to filter for portrait if that's an option
ah wait, found it
controller & display > display > portrait
Awesome. Thank you!
quick q does this look good for a UI (just the style)
instead of having the seperating line being just a red / blue line , make it into an arcade screen effect , also behind the instructions just add a big black transparent box and animate the buttons being clicked
since u going wit ha pixel art theme , makee the hearts also pixel art and remove that blue box cus its ugly
i let the title and the death counter just float there?
just add the hearts either on the top of the screen of each character or on the top of the entire screen
wait im getting to tthat
ah alright
ill make smth rq and send u an example holdon
alrught thank you
@cinder swift smth like this for the death counter (the number is a bit off lemme fix it rq)
also add a drop shadow for a smoother look
ill show u a drop shadow one sec
also having the same for hearts might be boring so just use heart capsules that become empty when consumed (aka when the player takes damage)
have sweet dreams
huh?
unless u are diabetic
Heart capsules?
resend the image
Ah man
I dont reallt have it on phone
isit something like minexraft?
for the heart u talking about
u see the hearts that u already have in the UI?
mhm
make them pixel art instead of normal art
and put each persons stats ontop of their part of the screen
Oh i have camera swapping to shared and all that
they have shared health
so i decide to put in a general area
Its just a part of my game
and finnaly add this effect to each screen and add alot of Bloom
Ohh okay
if they have shared health then put the healthbar in the line between the 2
and add a screen shake effect when hit
then if i do shared camers i bring the health to top right?
wdym shared cameras
oooh alr alr ye i get it
ye put the health next to the death indicator except this time their death counters are 2 indicators in each corner of the screen ( u can change the color of the pixel art depending on the player)
np , anytime
i make this only for the split camera
else i do top right which for the shared
shared pov
alr , gl with ur game and gn
Thank you bro
np g
u can use the art i made for the grave btw
and i can make u the hearts too if u want
ok now it looks like im riding u so hard alr dude imma stop ts gn
this seems really wrong @tame shell , whats that red x for one - does it mean its inverted?
Yes thats correct. The content anchors should only be expanded horizontally and vertically they should both be at the very top of your viewport
presuming this scroll rect wants to scroll vertically
yes
And you still need to move its anchor (round blue circle) to the top middle
oh wait
bro... I somehow set the viewport to be the Uh Oh text and not the actual panel
🤣
that explains so much
Ha hopefully it works better now
it works way better yeah, thank you!
any idea how I can have the text padded away from the left and right slightly, without changing the shape/size of the background panel?
changing padding in the layout group makes the background expand as well, and it moves past the edges
TMP has it's own padding - expand the 'advanced settings' section
thank you, that fixed it
struggling so hard with all these layout elements still though 😢 I'm trying to have the text determine background size, and I thought I had it but on playmode the layout group set all elements to y = 0 and broke
try them in context
alr
It's for UI questions about Unity, if you want to run a poll about your game, use devlogs
alr alr sorry (just wanted to know which prespective was better for UIs in general , orthographic or normal)
What does "background size" mean? If you want content size to affect the scroll rect viewport or whole size its a pain and requires code to do custom
The parent panel, but I managed to do it slightly different (was still absolutely excruciating btw 😢)
If you wanted a bg for the content + text that is simple to set up
anyone know how to make ui's actually look good and properly scale. The first image is what the game should look like and is what the game looks like when I make a build and play the game on my pc's monitor but when I try the game on a different monitor the buttons and ui look like the 2nd image. I have my canvas stuff on the 3rd image for anyone who can help me out. Man I just hate when ui's are like this...
You have to anchor everything correctly, and use layouts.
The canvas/ canvas scalar are only part of the required setup.
is that not scaled and anchored correctly?
nope
First off, scale should always be at 1,1,1 for UI. You'll run into issues if you don't keep them uniform, and you just don't need to use that for sizes of things, that's what the height/width fields are for.
Second, you do not want to stretch a button to the entire canvas like that. It will change the button size in annoying ways for different resolutions.
Those buttons should:
- be children of a parent with a vertical layout group on it
- have a scale of 1,1,1
- not set to stretch
- have their width/ height set to the correct value
the parent will probably want to be anchored to the left side, middle
ok ok. So wait for the width and height thats just the right and bottom values right?
ohhhh
You use stretched for panels, images that need to fill the parent, etc
the red one?
they're all red ;p
XD
but there's only 1 middle
ight
The layout group on the parent will deal with the anchoring
ye I've made a parent called left side and one for right side
and basically jus anchored it to the left and right and placed the respective ui elements into them
on bigger resolutions you'll end up with a gap in between them
maybe .. test that, the canvas scalar might take care of it
ye I'll see tnx for the help
seems like masking and fallback tmpro fonts don't work too well together (1st image no mask, 2nd mask on the tmpro object with show mask graphic on, same for mask on the child submeshui with show mask graphic off)
not sure how to approach fixing this
I assume the way that the submesh's stencil values are set up isn't entirely correct for my use case
I'm trying to build an inventory item view page (using Vertical Layout group) and I can't get the spacing correct. I want the image to take up all the extra space (make description height small) and I can't find the correct settings to do so. Currently all elements have a Layout Element component and all have flexible height = 0 except for the image which is 1. Can someone help me find the corret settings?
Oh, I forgot...I wanted the image to spaced in the middle so I put it as a child. It can be viewed here:
It should work just fine unless the fallback font has the wrong material. If this is UGUI make sure its using the correct shader on the font material.
Turn off "force expand height" first because that wont use preferred height
second make sure to override the preferred height for your image to 0
Material doesn't seem to matter, even on everything having tmpro default material this happens
how do you make the game screen fit even when you change the display scaling of ur screen ?
Properly anchor all of your UI elements
and test it with different resolutions
Also choose the right canvas scaler mode that you desire
anyone got any ideas for 2 more colours I could use for 5 and 6 dice that would fit with these? the idea is to try to be colourblind friendly, but also distinct colours
How can I fill a complex shape like the bottom curved shape? I want it to follow along the shape, not just like a sweeping horizontal full cus that's not going to look good
I think you'll be needing a shader for that
I got a ui question
why selecting one toggles under a toggle group effects everyone?
like I have toggles like this
-Toggle set A
-- 1
-- 2
-- 3
- Toggle set B
--1
--2
--3
if i select 1 in A then it deselcts everything from B despite me not wanting it
you must have them linked somehow
You probably have them all use the same toggle group object
any good tutorial or something about it? My issue is effect is still global despite me explicitly stating that toggle is targetted toggle group component
What does that mean
i assign toggle group to my button but yet having global behavior. I searched about this a bit but not much result about it. So wondering if I'm missing right keywords which shows how to assign toggle buttons and multiple toggle groups
Make two toggle groups. Assign one of them to set A and the other to set B.
It can't know that you want sets A and B behave separately if you assign the same toggle group to both
what kind of shader should I try to research? haven't really written shaders before. can it be accomplished in shader graph? I've heard you can write UI shaders with graph now
Yes you can do this pretty easily with shader graph
This is how I would do it. You use the mask as the background. Then for the fill, you just do a threshold on the gradient which will cut it off as you go from 1 to 0
oh wow, thanks so much for the graphics explaining as well! I don't have much experience with the graph, but I kinda have an intuitive idea on how this would work
what functions would you use to cut off the fill?
you mention threshold
how can stop screen tearing for ui objects without setting vsync to every v blank? when disabling and enabling ui objects
one image is with vsync on and the other is without
half way through disabling
i tried limiting the application fps but that didnt help cause i was getting like 3000 fps in my main menu
I haven't been in shader graph in a while so I don't remember what the easiest way is
step function
but how do games like minecraft go about this because u can have unlimited fps and u still dont see screen tearing on ui objects
I see, will do some research on this. thanks again to both of you!
do games enable vsync while a menu is active?
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Step-Node.html
basically you modify the Edge value according to how much health there is and that will make varying amounts of the gradient show up
AFAIK there is no getting rid of screen tearing without vSync
although UI is generally pretty static and not updated frequently compared with teh rest of the game so it might just be less noticeable
you might need to add some custom code to select all the text when focusing the input field
hey sorry just coming back to this, how did u make thst gradient shape? are u doing in it in photoshop or something?
do you know by any chance how i could go about it?
because when i have vsync off and i disable my black overlay which reveals the gameplay straight away i can see the tear
do you know if games by any chance force vsync in main menus and cut-scenes?
and then vsync just goes back to whatever the player set it as before in settings
Yes photoshop. I made the shape with the pen tool, duplicated it, made a gradient for the angle that went from 1-0.66 and then another gradient for 0.66-0 for the horizontal part. Also made a clipping mask so it’s only inside the mask
is there an equivalent to OnDrawGizmos for the editor window class?
this chan is for game UI using the canvas, you're best off asking that question in #↕️┃editor-extensions
how would i fix this delayed vertical layout and content size fitter
hey how could i create a curved UI? it's mostly for a visual detail in an animation and I have only found for resources for VR
You need a shader for it, the same shader that works for VR will work (the VR element is not relevant).
You cannot curve a screenspace overlay canvas .. it'll need to be world space or screenspace camera
Oh okay, thanks :D
CurvedUI plugin should work fine for non-VR, it's a good package
Depending on the details it could be:
- Just imported images that are curved
- Shaders
- PostProcessing effects
- Some combination of the above
I have been going over this and i think a shader is the only good option left
I thank all of you for your replies and time though ❤️
Shaders can distort things quite easily. The only problem with it is that it does not distort the CPU side presentation so if you need to interact with the distorted UI elements, you must take that into account somehow or otherwise the hitboxes for the elements would work where the undistorted elements would lie
What can I do to fix the font texture to be a pixel perfect font?
Its looking like that, an the bar below its pixel perfect, how can I do for the font to look like that?
Thanks a lot in advance peepoHappy
Change the shader the tmp font materials use https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.2/manual/ShadersBitmap.html
ok before i attempt to try to recreate the wheel, does unity have a way to have more than one person to select selectable objects at the same time?
im working on a local multiplayer character select screen and i haven't seen any unity examples showing that it's possible
like in particular, the UI selectable buttons. is it possible to select more than 1 thing without deselecting another?
In Scroll Rect, how do you make it not interactable to mouse drag? I can drag the content around if i hold left mouse.
turn off vertical or horizontal in component on your choose
input system has support for multi user input and has special components for users to control their own ui. I think this means that they must be seperated though (e.g. seperate canvas)
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.18/manual/PlayerInput.html#ui-input
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.18/manual/UISupport.html#multiplayer-uis
ah, i never thought about making another canvas. i ended up just making a script to adopt the current buttons and pretend that they are buttons instead.
thank you very much for the response, i never even knew of this
Hey there 👋 I'm trying to use TMPro to make a UI element.
I've made it so that the text follows the main character(by making the character parent and text chil (It's a counter above it)), it worked perfectly without any issues but now that I've added a background the text is invisible, I can't change the sorting layer of the text and I just don't know what to do.
Canvas in world space mode (which you should be using on the text following character, for simplicity) is sorted by Z coordinates. So just make sure background is behind it with respect to the camera.
like this ?
Make sure the background is using the same rendering layer. Order of layers overrides positioning
(or just put it on the lower render order layer)
My background is set to background so there's not problem with that normally ?
Even with the canvas on foreground, the background on background the number is still not showing up
Which points to different layer order.
I don't understand ?
Select background and examine its renderer
and compare its render layer with UI text
Ok so, I don't know if it's because I'm a beginner or if my english is poor but I don't really understand what you wan't me to do...
I'm really lost I just don't understand why I can't change the layer of the text
Text sorting layer is on the canvas
If you just want to have text on top of everything make sure your "ForeGround" layer is actually higher in order
My main character is on the foreground but not the text
I mean
My Character is set to ForeGround and IS visible, but the Canva's is also set to ForeGround but not visible
Anything on the bottom renders last.
on top of everything
Make a background layer and put it on top
don't forget to assign
My foreground is last and it is on the character and i see it
And the canva is also on foreground
Right. Did you make sure you can see the text at all, without anything?
When i don't have the background i can see it
Sprites and meshes often have these "sorting issues"
If text doesn't fit the box it can go to another line etc
You may need to move the text forward on z some amount untill it magically draws in front.
You can try also setting the sorting layer on the tmp mesh renderer (if using tmp text non ugui)
id recommend against a canvas + ugui tmp text
this only applies if NOT using the ugui tmp text
there is a general 3d mesh version too
I know from experience mixing sprite renderers and mesh renderers is annoying
An alternative is to use an overlay canvas and just make the elements follow the character world pos
(using code to convert some world pos to screen pos)
Do you have a tuto or smt for this I am completely loss, + I just got another issue that i can't see my colliders on my tileset it's driving me nuts
You can search for one if needed.
Its a normal solution to have UI elements follow some position in 3d space
If using the "screen space overlay" mode you can do:
```cs
Camera cam = Camera.main;
someRectTransform.position = cam.WorldToScreenPoint(someTransform.position);
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Camera.WorldToScreenPoint.html
Can I ask something else here btw since I wan't to throw a punch into my screen.
I have this tilemap for collisions for my ground i all of a sudden it decided not to show, now i don't know where are my collisions
Also, when something doesn't work like it supposed to you do a sanity check. Create a clean scene and drop default components, see how they are sorted. Which by default should work just fine. Then you compare with your setup to see what's misconfigured.
I have everything falling apart I don't what to do or what i did wrong but nothing is working as it should, my collisions don't show up in scene, the text is not showing up and i going through ground where i know i have collisions
You have gizmos disabled
this button shows gizmos
HANK YOU SO MUCH
I just need to understand one thing...
Why wouldn't my text be visible when in all possible way in front of everything else
I managed to fix it by puting everything on the same Default Layer and just moving on the z axis, thanks to everyone that helped me.
Some things (opaque) write and test depth so work as we expect.
Transparent things like sprites and tmp text do not so things get funky
thats why the sorting layers + order exists to help
anyone know why this autosizing, single line, text mesh pro ui text just scrunches up like this? done just about everything to get it to not,
text comes from random generation from a few text assets, and in code ive parsed out all spaces and escape characters, and also turned it off in the tmp extra settings
noting this text scrunched towards the middle
Im VERY new to any coding so its probably something easy to figure out but why doesnt that 0 go onto my game screen?
Select the text, not the canvas
mb
I wonder if the tool sidebar changes the screen aspect ratio
Try to change the anchoring to top left (the red crosshair looking button in the inspector)
Why do you have Z position set on UI? It could be removed by distance. Happens at -1000 anyway. Also should not be using Legacy component, use TextMeshPro (TMP) text
i thought that z would do something but it didnt its my first time using the ui thing
didnt work
Can you show a screenshot of the game view?
