#📲┃ui-ux
1 messages · Page 20 of 1
GetPropertyHeight is the only option
I don't know of any other way
Is there something wrong with my TextMeshPro markup here
It's generated by script
Identical text, but in the first case, everything from the - /home/ritchie is white as it should be
but in the second case it's red
┌─[<b><color=#CE0000>root</b></color>@<b><color=#CECE00>ritchie-pc</b></color> (<i><color=#CECE00>Admin</i></color>) - /home/ritchie] - [%d %t]
└─<b><color=#FF0000> #</b><color=#000000></color>
┌─[<b><color=#CE0000>root</b></color>@<b><color=#CECE00>ritchie-pc</b></color> (<i><color=#CECE00>Admin</i></color>) - /home/ritchie] - [%d %t]
└─<b><color=#FF0000> #</b><color=#000000></color>
This is the markup that's generated
They LOOK identical
Is it that I'm closing <color> tags before closing <b> tags?
Why is it affecting the second prompt but not the first?
Hmmmm... deleted more of the markup at the start. Ended up with this.
<color=#FF0000> #</b><color=#000000></color>
┌─[<b><color=#CE0000>root</b></color>@<b><color=#CECE00>ritchie-pc</b></color> (<i><color=#CECE00>Admin</i></color>) - /home/ritchie] - <[%d %t]
└─<b><color=#FF0000> #</b><color=#000000></color>
At the end you are opening a color tag and not closing it
<color=#FF0000> #</b><color=#000000></color>
Soon as I delete that very first < there, the incorrectly red text goes white
could it be an issue with the code?
As I said, you are just not closing a tag and so it remains open and flows over to the next paragraph
I know. I was trying to grab the actual code and see if I can get a second pair of eyes on it but ideavim's being annoying rn
How do I make a button like this ?
Import a sprite in that shape
yeah I already got it. Just trying to mess around in GIMP
Why is it so weird?
I set up the anchors and put 0 in the margins
the text for some reason is much further to the left than the left drag bar
ok nvm there is an extra margin down in tmp and it was set for some reason
Hey, guys! I have a small issue. I have a GameObject for my Pause Menu Screen and when I click the resume button to deactivate this game object my resume button color stays the same and not turning back to its normal color. I will send you a screenshot
It stays like that when I click it and open it again it stays grey
its normal color is black
Yes, a screenshot displays a colour change problem well 
it's probably because clicking on a button selects it, and it remains selected
click off and it'll go to some other colour
what?
it was a gquestion
I mean there is no option to disable selected color
So set it the same as the colour you want it to be..
You said to click off how?
click anywhere that isn't the button 😄
So the problem is with my OnPointerEnter
no?
because of the Hovered colour..
I ve made that thats why I am telling you that
So, when I touch with cursor mouse those button I have a OnPointerEnter method
I did it to turn it grey color
so have you got an OnPointerExit method to change it back?
I will show you a video
Oh
OnPointerExit
Do I have to add that at the same button?
Where else would you add it?
My OnPointerEnter method actually does that check
I play a clip whenever my mouse cursor entering the UI elements
...yes, and?
This has nothing to do with that issue
that doesn't touch the colour
I know
Give me a minute to try OnPointerExit
So, actually I have to make a method like I did here called OnPointerExit
So, I have to make a method which will turn the selected color back to default right?
It will be OnPointerExit for example
What do you think?
No.
You're not using OnPointerEnter to change the colour, so there's no point doing it in OnPointerExit either.
Just deal with the colour changes in the one place - which is wherever that's changing it now - I assume on the button component
I am using EventTrigger and I have there the OnPointerEnter() and on that method I have the code that I show you.
Yes you are ture
true
stop talking about that , it is not relevant whatsoever
So, whats happening I am confused XD
Something happening with button colors but I am not sure
I have tried to make some changes to all of them
but didn't fix the problem
A guy told me yesterday to do something with the Interactable option in code like Button mybutton; mybutton.Interactable(false);
What do you think?
I think that the problem is coming from my different game states
I am like 90% sure that the problem comes from it
Because when I am interacting with the escape button to disable my pause screen game object after that the color button isn't turning.
@low pike Hey! You were correct when I am clicking somewhere else then everything is fine but it seems to me like a bug how to fix it?
It is not a bug
Can I make a thread to join me?
I want to do the typical effect where a Sprite gets progresively filled with a clockwise pattern; like you know, skill CDs in a lot of games. I am assuming that's just a multiplicative mask on top of the spritez but how do I actually make it follow that clockwise pattern?
Filled UI Image in radial mode does this off the shelf
What does tab view look like when its tabs cannot fin the screen
I'm trying to implement a heart system into my game. Full hearts worked fine, but adding quarter hearts has lead to a bug where every time you are hit, your health gets set to 1.25/3 hearts.
public void subtractHealth(int healthSubtracted)
{
playerHealth -= healthSubtracted;
int index = 0; // Variable to keep track of the index
foreach (GameObject heart in hearts)
{
Image image = heart.GetComponent<Image>();
if (index >= playerHealth / 4)
{
image.sprite = heartSprites[0];
Debug.Log(heart + "set to empty.");
}
else if (index <= playerHealth / 4 && index %4!=0)
{
image.sprite = heartSprites[index%4];
Debug.Log(heart + "set to 1/" + index%4 + ".");
}
else
{
image.sprite = heartSprites[4];
Debug.Log(heart + "set to full.");
}
index++;
}
}
Let me know if additional information is needed.
Hey, I have a little problem with my dropdown menu, i got that dropdown with the viewport behind my others options
I tried to use another layer for the dropdown, and put it above the UI layer, but still not working, does anyone know a solution for that pls? :p
(edit : my fault the problem appears only in scene mode (idk why)
how do i get rid of that audio symbol?
it's a gizmo
disable it from the gizmos menu
👍
I don't like this action prompt. I'm trying to nail down why.
I guess it should be offset from the actual object.
and maybe it should have a little bit of padding? the box is very tight.
is the grey box part of it?
I feel like the box shouldn't be there at all? And definitely offset the whole thing, and perhaps make it a little transparent?
okay, let me try that..
that definitely works better
i should really make an actual texture for the lever so that it doesn't look like a blob of scrap metal
I previously had it so that a line was drawn from the popup to the thing you could actually interact with
that was in world-space and I ditched it because it was getting horrifically mangled by post-processing
and I can't just draw things in AfterPostProcess because they get screwed up by dynamic resolution scaling
It looks better without the border.. but this border looks worse because
- it's too thick
- it's grey, should be white
- it's too close to the text/ icon, needs a margin so nothing touches
That does look nicer as well.
Give it about 5? pixels more space on the right - so that the space is the same as the left
oh yeah, the action icon has excess padding on it
Padding! That's the word I was looking for
should be able to make it work dynamically with layout groups
so the mouse has some blank space on the sides
I should probably just adjust the sprites so that they're all tight
that A+circle is too large
it gets the point across
hmm, I'll have to tweak the action icons
but.. have you seen the pack of these Kenney is working on/ released?
no, I haven't!
ooh, very pretty
Attached: 1 video
Working on "Input Mixer"! Using this online tool you can create your own set of input assets. Use effects (like shape, detail, shadow, outline, color, grunge) to generate over 800 unique icons in a single click — all for free! 【very early, WIP】#gamedev #gameassets
get outta heeeeere
that's cool
ooh, actual keyboard icons too
i've just been writing the button name into a text element and getting
acceptable results
I did that too, with a square around 'em
and < > v ^ for arrows 😄
or did I do v upside down for ^
oh right, I can just scale the entire icon object down to 0.8
loverly
i'll make the icon fill in when you actually perform the action, and have the box grow a little too
anyway, thanks! time for a break :p
Break? It's bedtime!
Hello! Does anyone know why my LineRenderer would render in front of the UI text?
My UI text is TextMesh Pro, and the LineRenderer is used to create a sine wave design element for the background, but it renders above the text. The Canvas is on a sorting layer above the wave sorting layer, still no effect.
The LineRenderer is used to create that ugly pink wave that obscures the text.
Sorting layers don't matter for UI
Assuming your Canvas is Screen Space - Camera, the line renderer is simply physically in front of the UI plane
Ahhh, silly ChatGPT told me it was the Sorting Layers.
Yes, the Canvas is set to Screen Space - Camera
How do I fix this, move the LineRenderer object back in Z axis?
I think it's at 0 in Z.
Let me try, if this works you have no idea how much headache you relieved me of!!
It's working! Firstly my camera was in Perspective for some reason, it should be Ortho. Secondly the canvas is at 90 in Z axis and I can't move it - it's created by Doozy UI Manager. So I set the LineRenderer to render at Z = 100, and it worked!
Thank you so much, you have no idea how much headache this gave me.
I have a problem: I want to scale a designed button to any scale, but even watching this video https://www.youtube.com/watch?v=_-9MrJfbysM it still looks like this:
Ever had your UI bend, stretch and distort? Not anymore!! In this video I'm going to show you how to create and set up your UI elements to scale perfectly everytime!
Join me and learn your way through the Unity Game Engine, the C# language and the Visual Studio editor. Remember, if this video was useful then DROP A LIKE! 👍
💬 Join the Discor...
When someone nows why this is the case, just write @tall gulch
the video seems fine though
Is there a way to use the Sprite Renderer as an Ui element?
because an Ui image, can't use the image and sprite renderer component
Why do you need to use SpriteRenderer?
In UI you use the UI Image component
SpriteRenderer is not for UI
well it is working with the sprite renderer but not with the image component
Try Sliced mode instead of Tiled
I'm not sure... seems right?
It's possible your Image component is too small / your actual PNG is too large
or maybe your UI has scaled parent objects or something?
Well now I used a simple 16x16 png and sliced it, the upper one Image Type: Sliced, the lower one Simple
Quick question. If I have a canvas with one panel and an image inside, how can I move the image behind the panel? There seems to only be a sorting layer option in the canvas itself, but not for the image?
UI draw order is based on the hierarchy order
lower in hierarchy == drawn on top
Also a "panel" is also just an Image
Would it be okay to just use a canva component on the image?
an image component requires a sprite assigned to it
Hello! I need help with TMPro please
Im using a korean font as well as a Japanese and chinese font, I want the TMPro fallback to work well when the characters aren't available in one font, to go fetch in another
But I can't seem to understand it, also my fonts can appear blurry at times
Heya, I'm pulling my hair right now.
I'm working on making a scroll view.
I have a panel with a width of 320px and height of 500.
Then inside the panel, I create a scroll view (from the UI menu), removed the horizontal (need only the vertical)
Also unchecked Horizontal from the scroll view component.
Then, inside my Content object, I attached a Grid layout group and put a bunch of buttons in there.
Everything looks good until I start the game. The scrollbar doesn't appear, I can "scroll" but it comes back to the initial position
I also cannot see the scroll bar
I followed step by step a video tutorial and literally do the same thing they do and yet here I am
i think the scrollbar only appears when there are enough items there to scroll
Yeah there are more than what you see on the screenshot
I however realised that the height of the container doesn't increase with the number of items
Is there a way to have a flexible height so that it takes whatever space the items take?
lemme check how i did it on my project
If I increase the height of the content to left say 800 (instead of 500) then the scrollbar appears but it's manual
do you have a content size fitter component?
I don't, no. I'm quite new to unity, still learning the components
Let me try it
Ahh yes! That's perfect!
Thank you!!
👍
A quicky here, how do I create different materials for the same text in TextMeshPro?
Like I can create a copy of the material from the assets, but I don't know how to change it
Shouldn't it be in Material Preset? Cause it doesn't let me change it
you need a 9-patch
how do i fix buttons like this
mouse cursor position is hitting the middle button
is the button collider scaled wrong?
I'm using PowerQuest's engine, the dev said 'Maybe you've got some weird setting with your unity sprite atlas. If you're not using unity 2020 it could be something im not aware of. I'm at a loss though how it'd get that broken'
I have a canvas with some buttons and sliders and toggles on. The buttons can be pressed and do work, but for some reason I can't click on or drag the sliders, and I can't use the toggles either.
All of them are interactable with the raycast target ticked. They aren't covered by UI elements. I have an event system with a (InputSystemUIModule) which is on default settings.
I've exhaused all the issues I could think of so I came here for some help with this
i put a custom cursor in my game. it appears in the editor but not in the build. this is the warning but i cand find the things it wants me to do.
you would get more help by providing some pictures of the settings of your canvas, toggles etc
you have to show the actual settings in the editor
also that menu looks cool asf
Wrong texture type
so what should i change
...the texture type?
to what?
Have a look at the options and make a guess
Come back when your PC is on if you still can't figure it out
i just updated my editor from unity 2020.3.30f1 to 2022.3.19.f1 and everything seems to be working alright except for one specific canvas that doesnt render its ui elements properly. I havent changed the code in anyway and what ui element that doesnt show is random everytime i play. Sometimes it looks normal, sometimes the background dissapears, sometimes the button dissapears, its just random. Im not getting any errors related to my ui and this is pretty much the only problem i have after the upgrade. Any help is appreciated.(Left post upgrade, right before upgrade).
man idk if i'm the right place but how do i compress texture in GLB file, it cannot be separated
thank you!!! :D
will do soon sorry abt that
Hello, is there any way to make an object inside of the Layout Group move freely inside of it? Or maybe any alternative to achieve the same behavior?
Give it a layout element and check the "ignore layout" box
I see, it works, but completely destroys my logic with content size fitter
is there any other way for the logic to stay the same and make it move freely just on the y axis?
It's either part of the layout or it isn't
is it this one?
how do i make these options in the dropdown larger? like the same size as the first bit
Your Dropdown will have a disabled child object called Template. You can modify that template to your heart's content
do i need to download some custom designs or am i able to customize it somewhat in the editor
Should i just use UIMGUI instead of UI-TOOLKIT
Due to the lack of documentation and resources
(eg everything online is for IMGUI)
(and i cant find many issues for ui-toolkit specific components)
If so, how can i create a RecyclerView / ListView using IMGUI
UI toolkit has plenty of documentation
Yes but not a lot of tutorials on how to do specific things or why specific things happen
Hello, I have a problem with unity 2022.3.19f1 and 2022.3.18f1, when I select any element within the Canvas, it becomes smaller for some reason, also, when I enter play mode any element that I add to the Canvas starts flashing strangely.
when im using my dropdown, the scrolling between the options is really slow, how do i increase it?
Did you google it?
Google says you want to increase the scroll sensitivity on the ScrollRect that's on the Template 🤔
IMGUI objects can be instantiated and constructed in a background thread right ?
eg to avoid the ui pausing while a large complex ui gets instantiated at runtime
i have these items showing in the inventory with a scrollrect, and theres a mask hiding the items at the bottom of the list not in the viewport. i have that bottom area there with the gray box where i want to be able to drag items into it, but when im dragging down there its outside the mask so the item isnt seen. how can i set it up so the mask is working for the inventory, but allows the player to drag an item someplace outside it?
i was thinking i could change the parent but not sure if there's another or better way to do it
when I do dragging stuff I usually have another gameobject that's rendered above everything that references the slot's image
could be its own canvas group too so you can just override sorting
much like how you would do tooltips
compare its recttransform bounds coordinates to the screen bounds
Hello everyone! Does anybody have any idea why changing my res in the editor makes my menu buttons invisible? Like, they are still in the good position and I can hover over them but i can't see them anymore
Found it, for some reason, the font is doing it :/
EDIT: The size of the font is changing when changing res, so that's why it was invisible for me, had to lower the size.
my tmpro gets blurry when my overlay canvas scales downs to fit the camera. Is there any way around. Would changing the canvas scaler be ideal?
My games inventory functions very similar to minecrafts cause every other inventory system just feels so wrong to use, probably after 10+ years of that game
I wonder what i can do with the inventory gui to distinguish it 
nvm fixed it by changing tmpro to hinted rash
Hey, I was hoping someone could help me out with dynamically adjusting buttons for text size?
- I have a UI canvas with a child panel
- The panel contains several child buttons
- Each button contains text that will be updated as the user presses said buttons
The issue is sometimes the text goes past the border of the buttons
I tried following this tutorial: https://discussions.unity.com/t/fitting-a-parent-ui-element-to-a-child-texts-content/160492
But it just made things worse as now the buttons are going outside the panel
Here's what I mean:
As the attachment illustrates I have an Image element to function as the panel behind its child Text element whose content dynamically changes at runtime, and want to make the parent adjust size to fit. I’ve tried adding a Content Size Fitter and Layout Element to both the parent and child, and fiddled with both their vertically-oriented parame...
Hey, guys! I have a small issue with my canvas elements here. So, like you see my reset button isn't set up properly. Do you know why this happening?
what would "properly" mean?
i.e. how do you want it to work?
I was playing with the anchors I am setting up canvas elements right now and something happened and my buttons got expanded I did not scale anything
I change also for one time my game view
Also, I got trouble with my resolutions settings and canvas when I change to some specific resolution it doesn't set the resolution propely as a result to cut off some ui elements
It just looks like you're acnhored them improperly
Or rather maybe you've chosen a bad canvas scaling mode
they appear to be anchored to the center and are simply too large for this resolution
No, that's happening when change resolution settings to some resolutions and it cuts off my ui elements like you see. That screenshot was when I was playing the game and test it.
I solve the issue with the buttons it was very simple btw I had to change the width value of the buttons and thought that I changed something different now about the ui elements I don't know why this is happening when I change resolution and like I said it's happening to some of the resolutions
FYI You can freely change the resolution of the Game window from the resolution dropdown. This will let you quickly test your UI with different screen resolutions
Oh, thanks! I will do it.
@mortal robin Hey! I test it and like I see i have some small issues with some of my ui elements when changing to some resolutions like my score which is shown at the top left for some resolutions, when I change to other resolutions for example 640x480 it is for one reason on another position like a little bit below.
Content Size Fitter should be used if your object is not parented to another RectTransform with its own layout group on it.
- Response List <-- ContentSizeFitter, VerticalLayoutGroup
- Response <-- VerticalLayoutGroup
- Text
- Response <-- VerticalLayoutGroup
- Text
- Response <-- VerticalLayoutGroup
- Text
- Response <-- VerticalLayoutGroup
All of the vertical layout groups should be set to control child size, and to not force-expand the child.
Each VerticalLayoutGroup will ask its children how much space they want, then ask for the appropriate amount of space to fit them.
They then set the child sizes based on how much was asked for.
The top level group doesn't have a parent, but it does have a ContentSizeFitter.
vitally, ContentSizeFitter belongs nowhere else
It's used because you don't have a parent layout group changing your own size
If you don't have layout groups on the "Response" objects, then they won't ask for any space to fit their child Text object
so everything will get overlapped
Oh that actually worked like a charm, thank you so much
I do have one other question if that's ok:
If the buttons are childs of an image (like the black one shown in my screenshot), and I set the image to use Preferred size vertically and horizontally in the content size fitter then the buttons inside just end up really long and force all the text on a single line which is difficult to read and the image doesn't even make it all the way for the buttons, it only expands a little bit
But if I leave horizontal as unconstrained and just do preferred size for vertical then the buttons look fine/readable but the big image doesn't expand to fit behind them properly
Is there a reason that happens or is it just not able to work like that?
Do preferred size for both. Add a LayoutElement to each text object and assign a preferred width.
That will override the preferred width from the text component
Although, in the second case you mentioned, I’d expect the buttons to get squished horizontally to fit in the parent. Maybe they have a minimum width from their image
Hmm ok thank you, I tried that solution and it seemed to work but I think overall if the text is expanding it looks better without the black image behind so I'll just hide the black image and keep the solution you initially provided
Thank you so much for all your help!
np!
Anything in your scene is a GameObject , even UI.
How can anyone answer that question?
guess no one has used unity for any complex ui's
If you say so
-_-
im not talking about fancy ui's with pretty animations
im talking about ui's with hundreds or thousands of game objects composing the ui itself
In what scenario would you need hundreds or thousands of GO's visible at the same time for UI?
Obviously you would be disabling canvases and object pooling things for scroll rects, if you had any wish to be doing "complex UI's".
any other ideas for inventory i should sort out 
(besides making actual sprites and focusing on visuals)
so far i can think of-
fix the number display height so picking up an item doesnt look shit
hold right click to drag across inventory slots
give some sort of indicator when you pick up items besides the pickup noise (i'm thinking text that shows up in the bottom right of the screen and says +1 (itemname) when you pick something up...
So far i've implemented basic inventory functionality, equipment slots that can only equip certain item types, and a hover GUI sprite thats also usable on floor items
hey guys Im using a text to show my game score but the canvas white borders are showing when playing the game i cant move the canvas so how do i remove its borders from user perspective ?
Turn off gizmos in game view
These will never be visible in a build anyway
oh ok thanks
yeah
Sorry for my foolishness, But thanks for your help!
Guys, does this UI need improvements
will the grey background be replaced with an image? or is this it
i'd be more worried about that car 😄
Hoi hoi hoi, What would you improve in this picture?
a non-gray background maybe, and idk what the numbers in the top left are or the arrow and number in the left corner
The arrow(triangle) represents a box
Well maybe i need to add icons to those coins and bolts
oh yea definitely, i thought that was like an fps counter or something
I have a hard thought on this one
If i will add icons
it means i have to move the logo little to the right
maybe move the logo down to the middle and add a background like a sky with clouds or something so its not just gray
remove car and move logo down so its centered vertically idk if that woud look good
That's uh what im avoiding to do.. somehow
to feel like you're in the garage
Maybe something like this would work
Of course this one is a joke, but hopefully will clear out some things for the user
dont know if this is just a for fun game / quick project or something thats meant to be professional
but yeah the UI feels very unprofessional which i think immediently puts people off
It looks like you spent months and months on a game and then do the visuals of the UI in 1 hour
My String Field keeps on resizing every time I move my mouse. It has a Horizontal Layout Group and everything works fine if it doesn't have TMP_InputField on it. The text on both images is the same. Any ideas?
why i can't interact with the button?
I found the problem and it is the Cursor.lockState = CursorLockMode.Locked;
But how do i make it works even with this line of code?
Any advice how i can fix this? It sticks with a wrong react transform.
The parent is an empty Gameobject. Could be the version though...
hdrp
not sure I understand your question
What does "It sticks with a wrong react transform." mean?
Anyone know how to make a toggleable indicator for color. (e.g. if button 1 is pressed change indicator for that button to a different color. if a new button is pressed reset indicator 1 image and change indicator 2 image to different color)
This is the default behavior for all Selectables including Buttons
👋🏽 it goes with x * x or y * y but not x * y
The size of your canvas is going to be whatever you have your Game View resolution set to, since you're using a Screen Space canvas.
The Reference Resolution is just that - a reference.
Does anyone know why adding a material to this image turns it red? I tried physically pulling apart the shader by seperating the RGBA into a vector 3 but it did nothing
but the base image is just black and white with transparency
You're not using a UI shader
What is a UI shader? I'm in URP and I see options for sprite shaders and normal shaders and decal shaders
i know that it's normally like that. In this project it seems to bug out, it will get to being squared. I never use a squared game view reso. Currently it's ok. Showing effect lol
that's exactly what I was doing with a sprite unlit shader but it's turning red
show the inspector of your Image component?
nvm you did
Can you show the "Glass Pane" image?
yeah this is what it's suipposed to look like
I noticed on changing the render mode to screen space camera it does work however it is then being effected by my depth of field settings which is sub optimal
Nooby question - I want something to happen (for example load next scene) when the user clicks anywhere on the screen as opposed to on a specific button. How can you do that? I'm trying to make something like a "Click to continue" button, but the whole screen is the button.
You just answered it yourself - make an invisible button that covers the whole screen
Hmmm, didn't think of that. Thanks.
I guess I could have just a plain text somewhere on the screen say "Click to continue..." and then an invis button that covers the whole screen do the action.
That's sneaky sneaky!!!
Hey, guys! What does this mean?
it means your RectTransform has a negative width or height
based on your anchor and other settings on the RT
Thanks!
Hey, guys! I have a small issue. My transform axis moved somewhere else on my scene and I don't know how to move them wherever is my game object? Check that
So, when I am selecting a game object i have to zoom out in order to move it because those axis moved somewhere far away from the objects and that's happening for all objects when I am clicking them and selecting the move tool
You probably have your tool handle position set to "Center" instead of "Pivot"
You can change it in the dropdown or press Z
It isn't that it is like at the same place and when I am moving something it only movees the object rather than the object and itself
It stucks at the same place
Can you make a thread?
Don't make a thread I closed Unity Editor and open it again so it fixed
And if im trying to change image colors that arent even associated with that button?
you can choose which graphic the tint applies to from the inspector
it doesn't have to be on the same object
Anyway to change multiple target graphics?
Write a script
Cheers
Text Mesh Pro, just updated - 3.0.7
Component or Script "text mesh pro input field" missing from unity for anyone else?
(I just went back to 3.0.6 to fix this but still would be cool to know if anyone knows)
How do you make a panel or background fit the text inside (which has its own content fitter)
- Image with Horizontal layout group
-- text as child, with content size fitter
you'll need to tick the right things on the layout group, can't remember which off the top of my head
yeah I thought something like that but they seem to ignore child size and it shows warning about content size fitter under layout group
how can I make a text stretch only as much as it needs vertically ?
i want some other UI element to be always right above it , whatever the height is
ContentSizeFitter on text with preferred size scales the Rect to fit
ty very much
I really want to use Coherent Prysm, it looks great
but I have to contact them to get access, and it seems like they're not very indie-friendly
i mean i might just use noesis+noesis studio but prysm lets you use animate CC (flash)
How could I do this but like actually in game and not just in the editor?
Can someone tell me why the Scene UI element positioning is different from the one in the Game view?
Thoughts on the colour scheme?
I feel like i keep coming back to this.
Items are color coded based on rarity, but so are increases to stats...
which can lead to some items have very ugly GUIS (such as archers ring) where the colors clash
heres how they look ingame... idk i think the transparent UI looks shit
How do you all do your UI animations? For example, motion graphics inside your game. I'm using tweens and a generalized script to achieve it but for some reason I feel like what I'm doing is a hack and not the proper way to do it. If anyone is willing to share their approach to doing motion graphics for UI in Unity, I would be very delighted. Thanks beforehand.
DOTween
For everything right? I also use the same approach but I prefab everything and try to capsulate everything I can because it gets messy really quickly. I also worry about the performance impact because of all the same UI-Image components copy pastes to create the motion graphics
Yep, I'm not an animator.. find it easier/ better to do it with DOTween than anything else
I have an animate component, with the various required fields
I'm not trying "interrogate" by the way now that I read it it may come off like that but thats not it, I feel like the more animations I add to the same canvas the more confusing it becomes, so I must be doing something wrong is what I feel like
what do you do in this component? can you talk about this a little bit?
I feel like the more animations I add to the same canvas the more confusing it becomes
depends on the animations, UI anims should be (mostly) there for information, not thrown in just because
think of it like on off animations in my case. lots of size controls to create interesting effects which then fades out
ignoring transitions between screens
I think the best comparison would be like notifications on an android phone. It happens then it fades out
gotcha, its similar to what I done but mine is shittier haha
I have this component, which is the only component that listens to the Unity Button events, so I can do fades/ audio/ etc without worrying about the button disappearing before the anim/ sound has finished
If I get what you mean right, I didnt encounter a problem like this yet but I get what you are trying to do
I think its best if I create a generalized library at this point, now that I know that others also use a similar approach
Much thanks for the responses!
If you have audio play on button click, on a button that gets disabled after being pressed, it's highly likely the audio won't get to finish. Same with animations
OOOOOOOOH
oki I got you now, I misunderstood
yeah I also had a similar problem, I think I solved it by adding a delay to deactivate after the animation secs, but that was a hack on my part, this seems way better
Honestly speaking I was very close to making the animations in After Effects, exporting and then using it on Unity but that also seems like a pretty shitty solution
It's not shitty, it'll allow you to have much nicer animations
All I do/ need are basic resize/ move/ rotate type things
I need to think more before deciding on an approach, thanks again mate :))
I wanted to make a little introduction screen for a boss, but some UI elements are below some sprites in the scene. Does anyone know how to change that?
I have noticed that while at full screen in Game mode (but doesn't need to be actually running so is not script related), if I tab, the interface moves slighty, like it is resizing even though the screen size is not changing at all; I can not be sure of what's actually happening cause it only happens at full screen and I cannot check the inspector casue as soon as I exit full screen it resets back; is this normal? Is something wrong in my interface setup or what?
(I figured it out)
has anyone worked with this before / does anyone have tips for this?
How do i get the buttons Navigation Functionality without having a button / Selectable component
I have created an input field that changes its width according to the its input.
InputField has a script that assigns its text to InputField's parent Text which has Horizontal Layout Group component to control InputField's width.
Now the problem is that this InputField doesn't get enough space for caret. So caret GameObject that's then Instantiated in Text Area in TMP_InputField script is shifted to the left when user's caret is at the end of the text, because of the lack in space.
Is there any way to fix it?
Hey, i have a little question, I saw a few tutorials, that's has a canvas using screen space - camera, as rendering mode. And with that, they can rotate the canvas, to make something like this (found on CodeMonkey video)
In its video, there's a script called "Canvas3D" attached to canvas, however nobody explains it, does anyone know something about that ?
This Image looks more like a world space canvas. Anyway if it's a code monkey video the script is probably part of the code monkey library
I didn't find anything on its library, :/ i looked into it
It just looks like a world space canvas from the picture
Looks like you have the script there
that's actually weird xD
yeah, i downloaded the project, but the script is not on
he deleted from it
i opened it up, but it's written "missing reference (Monobehaviour script)"
What are you actually trying to do or learn here
Rotating the canvas in 3D space, to have something like on the video x)
Because i really want this in my game, for others things
Just use a world space canvas 🤔
Event camera etc
I have some UI prefabs that can be used in both vertical and horizontal UIs.
So far, I've just removed the horizontal layout groups and replaced them with vertical layout groups when needed.
Is there a nicer way to do this? I guess I could just put both components on and have a toggle that switches which one is enabled..
I also have to switch which axis has flexible width, so it does look like I'll need to script it
oh, right, you can't have two layout groups on an object at once
when I deactivate and activate a part of my UI the music in my main menu restarts and plays twice, even though it is not a part of either UI... anyone know how to fix it?
presumably due to your main menu code
and/or settings on the audio source(s)
theres no code, just enabling and disabling UI through the button
settings for my audio source is here
the object being enabled has code presumably
this has "Play on Awake" on so it will probably play every time you activate the object
as i said before, i never activate that audoo source, except for when it starts
it is not part of the other UI
Show the main menu object that you're activating
or rather
the "part of the ui" that you're activating
what scripts are on it
(also gotta show the button on click config)
There's a ton of stuff here
Presumably GAMESTART and/or some of the dozens of other objects in that hierarchy have scripts on them
yes but they dont interfere with the music
you were right, the environment had the song on it aswell
solution: just make a DualLayoutGroup
both horizontal and vertical layout groups both derive from HorizontalOrVerticalLayoutGroup
It'll get more complicated if I want to be able to adjust which side the spacing goes on
but that's a "future me" problem
i have a massive problem. all of my ui from this scene has suddenly dissapeared. other scenes are fine but this one is just gone. ive never had this problem. last night i was copy pasting the project folder to a usb and canceled the proccess a couple of times if that helps
Convenient file sharing. Think of it as Pastebin for files. Registration is not required. Large files are supported.
here is a vid, its 50mb so discord wont let me upload it here
also all of the y values are NaN for some reason
not only the Ys, some others as well
it doesnt even let me change some of them
anyone have a good video tutorial series on Noesis? I haven't found that much documentation for creating custom themes and such for example... trying to replicate a persona style ui in my game and i think noesis is what i want to use now
I want for example to make an inventory list where each item has an image and number next to it
they have samples available but it's not very beginner friendly for someone who has never used XAML
I tried contacting Coherent Labs btw, they said Prysm isn't available for individuals and only for companies
i thought it would make sense if they offered at least a trial
also where is this plugin? https://forum.unity.com/threads/adobe-animate-texture-atlas-plugin-for-unity.1189735/
https://helpx.adobe.com/uk/animate/using/create-sprite-sheet.html
Hey everyone!
Can someone tell me why in the following main menu UI layout the windows build is screwing things up?
- Screenshot #1 Unity Editor (1920x1080 FHD) - looking fine
- Screenshot #2 macOS Build (2560x1600) - I disabled native resolution so it's forcing 1920x1080 here
- Screenshot #3 Windows Build - The display is in fact (1920x1080) FHD but for some reason the only one that is rendering the UI wrong
I just can't figure out what I am doing wrong. How come that the only true resolution (windows) is not able to render the UI as expected (by the unity editor) ?
Hi, I currently have a system where I have these game modifiers with +/- buttons on each one that appears when the modifier is selected. The +/- buttons are enabled and disabled via:
public override void OnSelect(BaseEventData eventData)
{
base.OnSelect(eventData);
increaseButton.gameObject.SetActive(true);
decreaseButton.gameObject.SetActive(true);
}
public override void OnDeselect(BaseEventData eventData)
{
base.OnDeselect(eventData);
increaseButton.gameObject.SetActive(false);
decreaseButton.gameObject.SetActive(false);
}
on the script of the modifier prefab.
Visually this works, but for some reasons I cant click the buttons anymore when I could before I implemented this code, does anyone know why?
Everything such as raycast target, event systems etc are set up since the buttons work if I comment out the code I have pasted above
Even more odd, if I leave the buttons enabled, they work! But then when I deselect their parent and reselect it, the buttons dont work when they appear
Ive changed the code to ``` private void Update()
{
if (currentSelectionState is not SelectionState.Normal)
{
increaseButton.gameObject.SetActive(true);
decreaseButton.gameObject.SetActive(true);
}
else
{
increaseButton.gameObject.SetActive(false);
decreaseButton.gameObject.SetActive(false);
}
}``` and it works now, but Im not sure why. Id rather it be nice and event based but whatever
I have this thing as an Slider, and I want the fill part to have the same inclination as the bar's shape, instead of the usual squareshaped mask that the slider does by default when on filed mode; I am guessing, I should be using some kind of mask component, but not sure how
This is the effect I would want, so... I am guessing I should have some kinda of inclined mask? Literally no idea of how to do this
How can i fade a canvasgroups children as if they are 1 flattened png
right now i get this blending
funny enough godot’s canvasgroup does this and its the exact behaviour im trying to replicate
Inherits: Node2D< CanvasItem< Node< Object Merges several 2D nodes into a single draw operation. Description: Child CanvasItem nodes of a CanvasGroup are drawn as a single object. It allows to e.g....
Usually you wouldn't have overlapping characters or images like that in the first place. If you can't change that, then a render texture is probably the only way. Though I'd really discourage against it.
Maybe you could bake the overlapping text into an image to avoid that issue.
same issue: https://www.reddit.com/r/Unity3D/s/XAv2n7L12s
That’s just an example to show the problem
Yes that’s what i think, baking the text into a rawimage element
but this involves separate cameras, render textures, higher cpu from regenerating the images
and ruining the entire scene hierarchy
to make my ui
same issue
four years later, and the “terrible hack” written here is still the only way to do it https://www.reddit.com/r/Unity3D/s/sZxhcAB5A9
Perhaps no one made a suggestion to unity and just kept on using the "terrible hack".🤷♂️
That being said, perhaps it works differently with ui toolkit/builder.
i need to fix this
for 2 years
i tried
and its why i cant use this engine
because of this
in ui
the rendertexture approaches makes render thread take 0.4ms on an empty project rather than 0.1ms with the simplest possible setup
4x worse performance
with a 256x256 render texture to render a camera to
fuck this engine
I think you're hard-stuck with additive alpha values since you can't really touch the UI shader, so perhaps using render objects and discard similar pixel values could be an idea
you mean render texture?
no, render objects
ive never heard of those
pipeline feature
it would be nice to just have a component i can attach to a ui object that would make it, and all its children fade as 1
i would pay someone or be eternally grateful for whoever makes that
it could do whatever render object magic behind the scenes
bump
It's endlessly frustrating that layout groups seem to disregard Layout Element's Preferred Height completely
Hi, does anyone know of a way to make a billboarding shader for a world-space UI element?
Hey guys, what should I do for users; should I have one button to register/login or 2 separate buttons?
2 obviously, they take you to separate screens
how do i make my world space text ui affected by light?
Anyone having issues with an inventory UI looking fine in the Scene window, but when you play it is blown up by 300% and covers your screen? Unsure what it is I am doing wrong.
check your anchoring
You're probably not designing it with the right perspective. Double click your canvas in the hierarchy and observe the full extents of it in scene view
Sure enough, it was the anchoring, sorry I hadnt messaged earlier, i hadnt seen this. Appreciate it guys 🙂
Hi, quick question. I am using TMP text MaxVisableCharacters to display a string like an old console, and am using linked overflow to split the string into 2 TMP text objects. Is there a way to get the string length of each individual part of the split string? When I do text.length, they both just display the length of the entire string.
Hey, i got a little problem in UI. I have a grid layout group, to display some information like this : (sorry it's in french)
However, i want the background to fit with the number of brown rectangles. For example i want it to be like this :
Does anyone have a solution please? 🥺
hey, I have the problem that my player disappears behind the background and I can't get it in front of the background. I've tried a lot
is the BG an UI image?
yes
make the BG a sprite
then I need a sprite renderer?
ye
Yes, don't mix 2d game components with UI components
SpriteRenderer for the game elements.
Canvas (UI) for UI elements.
Now I see the players in the scene window but no longer see the background in the game window
Don't mix game elements with UI in the hierarchy either.
Tidy this up and then fix the transform values for the background..
Hi does anyone knows why my hp fill ui cant snap to the side? (FIXED)
show the inspector for HP_FILL
What exactly do you mean by tidying up? Where exactly do I have to move something? I've tried a few things but it doesn't work
anything with a SpriteRenderer should not be a child of Canvas
ahh okay thats only the Players and the Background
ok i just found out it was the image part where i should actually set the image type to fill.
However, the main camera is now completely different; it feels like it only points to one point
A canvas, is HUGE, because it's using screenspace, so you've got your camera focussed on the UI.
The game, which you've got circled down there for your camera.. is the size of your game elements
You can't see your background because all you did was change it to a SpriteRenderer and didn't reposition and resize it
i tried to resize it
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
nobody has a solution? :/
Use content size fitters to resize elements to their children
For some reason when trying to place a textmeshpro component on this one specific prefab it makes the text blurry
any ideas?
with UIElements slider, is there any way for me to have the normal slider with "showInputField" turned on, and have that inputfield not be limited by the sliders minmax? I want the slider to have reasonable limits, but allow the user to go higher than the slider can go by manually typing in a value into the inputfield
okay, so you'll now want to inspect these elements while the game is running
(continuing from #💻┃code-beginner message )
check the actual size of the various children of "Classic Skin 1"
And if you select them while the game is running, do the scene view gizmos show that their size is what you expect?
(i.e. mostly filling the box)
Yeah their sizes are showing the same whilst the game is running
Show me the inspector for the object that's got the material you're changing the color of.
That object is behind its three siblings
It's the UI Primary material that's being updated but isn't changing on those elements in the layout
Yeah it's still not changing, even when I've disabled those other layers
Those two plain green boxes in the middle row are set up with the other layers disabled as a demo
ah, you're changing the outline, I see
I was thinking you were changing the "Swatch" object
Does deactivating and activating the Outline object do anything? What about switching the material in the inspector while the game is running?
Oh interesting idea. All other objects using that material change to whatever changes I make in the picker, but not the elements in the layout
Deactivate the mask (just the mask component) on the Viewport. Does anything change?
Shit. Yeah deactivating the mask changed it.
Exciting. Your material is playing poorly with the mask, then
I'm not sure why that'd be the case...
Oooooh
I wonder if disabling then immediately re-enabling the mask would force a refresh?
Those materials aren't the same, I bet!
Try double clicking on the material while in play mode
I think it instantiated your material when you put it under a mask
That explains why it broke in play mode
ohhhh
A pretty easy fix here would be to use global shader properties
assuming this is a custom shader, at least
I'm completely new to this, I'm not even sure what a shader is to be honest
ah, then probably not :p
the shader is the program the material runs to fill in pixels
you can define properties when you write a shader. these can be specific to the material, or they can be global
hm, so lemme think about how I'd solve this..
Oh I see. Yeah this material is using UI/Default for its shader
One idea would be to make a new Image class
call it ThemedImage
it'll be pretty simple
public class ThemedImage : Image {
public static Color primaryColor;
protected override void Update() {
color = primaryColor;
}
}
then just set ThemedImage.primaryColor to control the color of all of the themed images
This sets the tint color of the image.
So the material should just be white.
The Image graphic multiplies the tint with the color that the shader produces
that's news to me. good to know now, haha
(this requires using UnityEngine.UI; up top)
also, whoops, there's no Update method to override
public class ThemedImage : UnityEngine.UI.Image {
public static Color primaryColor;
void Update() {
color = primaryColor;
}
}
And this script gets added to the objects using that material?
You'd completely replace the Image component with this
This component does everything an Image does. It also grabs primaryColor every frame and sets its tint color with it.
Is that resource intensive?
Maybe if you had tons of these images
This has been really helpful! Thanks so much for all your time and patience Fen. Is there anything I can do to say thanks? I'm not sure if tips are something that happens here
Aww cheers man
Also, a more efficient way would be to use an event, like this
public class ThemedImage : UnityEngine.UI.Image
{
public static void SetColor(Color color)
{
OnSetPrimaryColor?.Invoke(color);
}
public static event System.Action<Color> OnSetPrimaryColor;
protected override void Awake()
{
base.Awake();
if (Application.isPlaying)
OnSetPrimaryColor += DoSetColor;
}
protected override void OnDestroy()
{
base.OnDestroy();
if (Application.isPlaying)
OnSetPrimaryColor -= DoSetColor;
}
void DoSetColor(Color color)
{
this.color = color;
}
}
you'd do ThemedImage.SetColor(...) to update everyone
I'm a little unsure about that Awake method. Graphic classes are marked with [ExecuteAlways]
That's how they can update themselves even outside of play mode
This might be a daft question, but is there not just a function I can execute once when I change the material that'll select these elements and change the colour?
well, the problem is that all of these images have a different material assigned to them
unity created a new one that's been modified to handle the mask correctly
I don't know if they all get unique materials, or if it's one shared material
Ah I see, gotcha. I'll give this a whirl. Thanks so much again!
Eh can someone help me fix this UI issue, In test its fine like the Placement and stuff But IN game build its not in the right place.First Image is in test second image is in game
Is there a way to make canvas gameobject's height grow/shrink based on TextMeshProUGui's content?
Tree:
Canvas
> GameObjectThatIWantToResize
> > TextMeshProUGui
Guhhhh, looks like I can't have children with AspectRatioFitter under VerticalLayoutGroup as well.
I can't have VerticalLayoutGroup with contents that has different aspect ratio.
How can I like Keep the positions of the Mag text and Ammo Text as on screen size changes they move about!
anchor them
thats the Center middle part correct?
Here's a tutorial https://youtu.be/w3sMD-3OJro
Something a lot of new developers struggle with but it's actually really simple! In this video I'll show you the basics of getting to grips with the UI anchors and scaling options inside of Unity!
Join me and learn your way through the Unity Game Engine, the C# language and the Visual Studio editor. Remember, if this video was useful then DROP ...
ty
Well it's the "anchors" part but the center/middle part lets you pick presets
change it to overlay
that's what it is on by default
hello i have a problem. i dont know why but i cant see my array elements in more depth, its intended to just open down and see the variables :(
its a custom serializable class
im sorry
You've got the [System.Serializeable] attribute for that class?
yes
share that class !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
You don't have any fields in that class, nothing will show in the inspector
Those three things at the top are called properties which don't get displayed in the inspector
im thinking that the { get; set; } causing the problem
it's not a problem, that's a getter/setter... which is called a property. They don't show in the inspector
solved it thanks!
i had to fix this by hand, deleting things and creating new from scratch but it happened again, can someone PLEASE help me because i know its not just me who has had this issue, ive seen people on the official unity support forum have it as well
i tried their methods to fix it but none of them worked
im probably gonna give up on my project if i dont find a solution for this
did you have any backups?
How can I set them to be anchored in same place for all devices
Completely new to UI and stuff in Unity and in general
Depends what you mean by "same place". Anchor them however you'd like them anchored.
Same place could mean:
- same distance from center
- same distance from top
- same distance from left
- same absolute pixel position,
Etc
Ah So if Anchor them to this pos stays as this on all devices like eh the Frames and stuff stick to the pos
like right now its here
if resize it auto changes them to be in pos
Without showing the RectTransform settings this doesn't really show anything
Ah its fixed I dont know what happen it snaps to the right pos on all types of size of screens
inventory layout mockup
any glaring issues?
I also want to have consumable slots somewhere but idk where to put them in the inventory thats not ugly
very old
Im thinking of replacing the top right and bottom right inventory slots with the sort inventory button and the trash slot... but i worry it will be easy to forget its a trash slot and delete something accidentally if its in inside the inventory
Need some help, my content wont expand when files are added
Use layout groups (Vertical/ horizontal) and content size fitters
Been following the Game Maker Toolkit Beginner Tutorial and at 29:00 I was struggling to get the text to look how he had it. The text is extremely large and blury despite this being a 1080p screen. Camera Size is 20. Video tutorial in question is:
🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...
That's normal for the scene view. How does it look like in the game view?
Guess I'll keep going with it. Just the text resolution looked concerning
Yeah definitely seems broken. According to his guide, it should show up. I may just work off of the new text object if this one keeps bugging
question about TMP and UI and text - all of these text assets are size 10 in unity but seem way bigger than what I expect from size 10, how/what/where/why is this the case and how do I fix it 'the right way'?
I ask the right way because I could 'fix' it by scaling assets willynilly but I assume there is a more correct way to fix it?
ah my reference resolution was 300x400 is what the main cause appears to have been
after changing it to a larger res it behaves more as expected
@Fen just thought you might be interested to know that disabling the mask of the Scroll View, changing the colour, then immediately enabling the mask again, worked a treat.
So after you do that, changing the original material's color correctly updates the colors?
Or do you have to do that every time you update the colors?
scrollMask.enabled = false; //Call colour change function scrollMask.enabled = true;
Every time yeah
Ah, good, that makes sense
the former would be very mysterious
oops, wrong reply
oh, and you figured it out! that was going to be my guess.
I was pulling up the TMP docs to figure out which of the many, many units TMP is using for font size
there are a lot of them
points, picas, em, en, ...
I don't suppose anyone knows how to change the colour of a shared font material? Really struggling with this one.
textMeshPro.faceColor = newColour changes the specific text object's colour successfully, but doesn't change the shared material's colour (I'm assuming the text uses an instance)
Figured it out. My shader had a "_Face Colour" property so I used that
given the following simple UI scene. my gamepad controller is able to go between the two buttons using explicit navigation. but when i click the blue area using a mouse, my focus is now lost on the 2 buttons and I cannot regain control of the buttons using a controller. (like say its on PC and someone accidently using the mouse clicks off, even if it sounds unlikely). How do you handle these situations. I thought about making a giant button in the blue area that explicity navigates 'back' to the buttons, but didnt know if there was a better way or something that doesn't feel so 'hacky'
I wrote this script to tell me what I am focusing on, and without a button on the blue background it tells me 'no element is focused' when i click the blue area
question about 'confirming' an input field. Currently when you hit enter, it calls the End Edit method, but it also calls this same method when you click off from the text field
I am using bog standard stock input actions, why does hitting enter 'confirm'? Like I know that enter should confirm because thats just how computers work, but I am trying to make a text field that only confirms when I want it to confirm
In your input module there is a binding for "Submit"
that is set to the enter key by default (and possibly other things too)
The input module is attaached to the Event System GameObject
ah this inside of StandaloneInputModule?
So I should hook into this callback instead of End Edit?
well I mean just look at the inspector of the input module
you don't need to dig around in the source code
that is where I found that, in the inspector, trying to double click it opened the visual studio.
Yes I am aware its mad at me for mixing input methods, there was a reason I wasnt using the 'right' thing here
ok so yeah it's going to be bound to the "Submit" axis in the legacy input manager with this setup
the reason being I was having problems with input issues related to virtual cursors and their behaviour in regards to the ui 🤔
ill try using an input thing again here because I dont remember why exactly I wasnt using it and try to use it's submit action
until whatever bug was stopping me before reappears (or doesnt)
Thanks for the help
hm im immediately realizing I don't know how to hook into 'when submit is pressed and this specific text field is selected'
but I think that is an input system question not a ui ux?
What dictates what field is selected in the Unity UI? Can I poll that info somewhere?
obiously selecting something by clicking on it selects it but this is all being handled by UI backend stuff by unity, I didnt manually code any of that
It's the event system
This can be done with an EventTrigger with the Submit event on the text field or a script with ISubmitHandler on it
Okay I will do googling and research into the event system, ive never used it before, to me its just a thing that exists in scenes
Okay, this has all I think I need. Thanks this is a big help.
I was already using IPointerEnterHandler, IPointerExitHandler to show tooltips, I didnt realize this was also the event system ( did it from a tutorial)
Ill set up a test script that impliments ISubmitHandler
Yep! If you're curious here's the full list:
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/SupportedEvents.html
Hmm I noticed a quirk of it. When you hit enter to send, it completes the field you are typing, but doesn't send.
When you then hit enter a second time, it sends
While this is technically correct, its not the preferable behaviour 
someone will have faced this before me, Ill google the handler
https://forum.unity.com/threads/inputfield-requires-double-enter-to-submit.359571/ yep others with same thing
hm im seeing more people with getting it sent twice than needing to press enter twice, but it looks like the people getting it twice are because theyre using the on end edit which is getting called when you deselect
same problem im facing from the other direction
oh no these people are just messing up context.started and context.canceled type stuff
@mortal robin https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.ISubmitHandler.html
ISubmitHandler doesn't get called if the UI instead reads your submit as finishing editing a text field, is there some other way to hook this up so that I don't have to hit enter twice to both complete writing the string and send the string in the same input?
I cant think of any way that isnt some ugly broken hack to do this
involving like bools and sending it twice and trying to filter out the duplicate
i dont think I could even hack it to work because I have no way to tell if I hit submit or if I deselected the field
ill keep googling, not sure how to fix this
I'm sure there's a way but I don't know it 😆
thats fair, ill keep googling
Ill call it here and try again tomorrow
because im starting to get distressed
I have issues with a ui button not working, couldn't find solutions online that fixed it. Anyone willing to help?
it helps to give details about your setup and show us, so we don't have to just guess or take you through it ... you're much more likely to get help that way
show the entire hierarchy, you've cut off stuff that is useful information
The arrows aren't working, but the buttons in the middle are
show the inspectors for those buttons, and the scene view
The canvas in the scene, and the entire hierarchy or just the canvas?
Oh and the script is on the scroll frame with the buttons referenced
I only added EventSystem after a tutorial did, but not sure what it's there for or how to use it
The EventSystem is required to make the UI interactable, which is why I asked for the hierarchy screenshot - so I could see if you had one
You don't have to do anything extra with it
oh ok, that's good then
Press T to change to the UI gizmos.
Press the 2d button in the scene view.
And send another screenshot of the scene view.
What I'm trying to see is if there's anything in the way of those buttons. Drag the up and down arrows so they are above the scrollframe in the hierarchy
Like this?
No
oh
because they're still below , not above, and now no longer siblings
Kind of.. that will do what I wanted, but it's not what I meant
BuildMenu
- UpArrow
- DownArrow
- ScrollFrame
Change it back to how you had it
outside of buildmenu?
Like this
Ok done
disable everything from (including) PriorityList to FavorBar2 (including)
see if the buttons work then.. that should confirm if anything is on top blocking the arrows
thats fine
Still nothing
what game object is this on
let's see the code
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
I just changed it now, is this correct?
you'll know because the colours in VS will be different, it'll say c-sharp assembly, and you'll have red lines under your errors
It's not opening at all
prob missed something in the guide
I can't find a option called Editor Attaching
IIRC, that's the option that was removed - I can't see it in the guides though, can you show me
Read the start of that line
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
Installed via unity hub
I had to admin confirm the installer for visual studio when I installed unity
So I feel like it's through unity hub
So you SHOULD have the stuff that's mentioned above it
Have you restarted both Unity and VS?
Dunno then, I haven't had to set it up in years.. ask for help in #💻┃code-beginner to see if someone there knows what you've missed
Just got off class and packed my setup I'll do it when I get home and set up again
Did your code come from a tutorial ?
Unity documentation
After you've got VS setup correctly, it'd be a good idea to re-read that doc page 😉
I searched for UI click something and first result was something with OnClick from unity
I copied everything from there
And changed it with Up and down arrow of course
I'm pretty sure you didn't copy some of it correctly
don't suppose you have that page to hand ?
yeah, you copied the declaring of variable incorrectly from that page
Oh
GameObject doesn't have any of the Button events (shock horror!), so if your VS was setup correctly, that line in your Start() method would be shouting at you with a red underline
I'm used to Roblox, Game objects by default inherent events and "components" onto them
I'll be home in 30 mins ca.
Sorry things got in the way as usual
It's taking the buttons now from the gameobjects
It's still not working though
your Atlas Resolution is like non-existent, it won't draw the characters if you don't give them space
you're still missing something probably, do you have a canvas raycaster thingy on your canvas?
or graphics raycaster
dont know what it's called
Where from do I add that?
on the canvas the buttons are on
Still nothing
could try to tick off "ignore reversed graphics"
but if that works that would mean your ui is flipped
or has negative scale... which is the same I guess
Still nothing...
which object is your script placed on?
is it active?
and is the script active?
On the ScrollFrame as highlighted here
It is active
Start & Update runs and can do Debug.Log(); just fine
weirrrrd
out of curiosity, what happens if you add the method using the editor? if you select a button it allows you to bind it to a method @thick sorrel
don't have to script the listening part
So like this thing?
yeah
that onclick
you can add your method there too
press the + and find your script
if that does not work then I'm clueless
I think I found it, but it can't see the function
find your method, you may have to make it public
it should have the same name as in the script
yeah the taskonvlick
nope
you are running your game right? 😅 not just in edit mode
Yes XD
In fact I keep forgetting to go out of play, but I try to make sure all my changes are done in edit when I realize
yeah that can be annoying starting out
well if you still have no solution by tomorrow you could send me the project, I'm not at home today
alrighty
could take a look why it does not do what it obviously should
I saw a debug tutorial video thing
And it has this eventsystem debug menu
But I can't find where to open it
in unity i see this, but when i try to put on my phone i dont see the black background all in the square
this is on phone
is the resolution of both of them the same?
and is the background stretched to fit or not?
the resolution is scaled with the screen size by the canvas option
give me a second to open the prohect
and how does the rect transform component of the black background look like?
unity cant read low resolution?
you mean this?
ye
click on this, and select the bottom-right option
as that will allow your image to stretch
like this?
oh not the bottom right option, the option at bottom right
sorry my fault
ok, what this changed?
now change these values to "0", as those say how many pixels away from each side of the screen your image will stretch to
oh perfect, so its perfectly in now?
uhhh why
it should work now, try it out
did you ping wrong people?
let me try, i am uploding the apk on the phone
look like somehow unity cant read it
too smol?
Got a weird issue with GUI:
I'm trying to make a debug console with a bit of autocompleting text, but whenever anything gets added to the prediction list, it autoselects all text, which then makes whatever next letter I use replace the previous letter instead of being a new one
What could be the cause of it or what would be a good way to force unity to not select the text when it happens?
https://pastebin.com/qri9jG6a
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
oh sorry i didnt understand you problem, i was thinking that your problem was canvas space render mode. sorry for the error
this is how the issue looks in action
I have only this small issue, but nothing that bad.
This will only do anything for the UP arrow, and as the scrollview starts at the top, it has nowhere to go when you click the uparrow, so you don't see anything happening.
on the event system, in the inspector
I think nothing will happen based on the fact the only thing my function does is a Debug.Log(); which btw doesn't run
question, I'm going to start diving into menu navigation with a gamepad. Few questions:
To help prevent reinventing the wheel, is it common to use the "Input System UI Input Module" component?
If I were to use that does that mean I need to use it with buttons only? reason I ask is tutorials that I'm watching/learning involving inventory systems typically create the slots using empty gameobjects.
...start with that for now
You're slots are buttons? You click them to add or remove an item for example?
someone in another channel mentioned the attached pic which as you all know is part of that genre of nav system which is native to use buttons, sliders, etc. However 99% of the tutorial videos out there that involve inventory systems create a grid of "slots" which are more or less square gameobjects
I'm afraid they are not buttons
Then please explain your slots ^^ What are they and what do they do
here's a visual AA
And you want to highlight one slot after another using a gamepad?
Like horizontally and vertically?
xactly
Then replace them by UI buttons, make their parent a Grid Layout, determine your desired spacing, and you have the system out of the box without the need of any code
I do have the parent grid layout in place. So I need to ask, why do most of the videos do this style of using gameobjects instead of i suppose adding the button component to them?
All buttons are game objects
also most also tend to use a mouse pointer to determine the click
so more or less I can simply add the button component to my existing gameObjects which are the slots now, right?
hate to say it so painfully obvious 🙂
I'll give it a shot, thanks AA
Here's an odd one. I'm accustomed to gameobjects in the hierarchy being drawn overtop of ones which are lower in the hierarchy tree.
Why does this rule not apply for gameobjects which have the TextMeshPro component [on a canvas]?
Is there something special about objects on a canvas having different rules on hierarchy order? Thanks!
in canvas UI, stuff lower in the hierarchy is drawn last which means it overlaps everything above it when drawn, if thats what you are refering to
yeah
it totally ignores stuff like z value depth and blindly draws top to bottom in my experience, if you want a sprite cursor for example to overlap all, it has to be the bottommost thing in hierarchy
it's basically opposite of non-canvas isn't it