I have a ui element with a few buttons that I activate/deactivate in multiple scenes. In my first scene, everything works perfectly, however, in another, the buttons don't react to anything. I've made sure there's a eventsystem in both scenes, I've copy and pasted my ui canvas from another scene into another, with no avail. It only happens in this one scene. What could possibly be happening?
#๐ฒโui-ux
1 messages ยท Page 54 of 1
Just tried using DontDestroyOnLoad on the canvas that works in the first scene to see if it carries on to other scenes. It doesn't fix the problem.
Have you tried using a separate OnClick method for the new scene? @dense terrace
or are there any aspects of the OnClick method that dont have access to data within the second scene
What I'm doing is instantiating a button prefab, with a script that has a function that is called with the OnClick() event. It works just fine in the first scene, but more importantly, I've noticed that the buttons don't even REACT when I hover or press them (like the default color tint effect I put on the prefab)
So it must have something to do with my event system... maybe?
If theres any screenshots I can send to help, let me know.
The craziest thing, is it works just fine in my editor (most of the time). But in my build, the buttons NEVER work.
it will just be an Image component in the hierarchy of the dropdown somewhere
Isn't that an option on the dropdown?
These are my options for the dropdown menu, but I want it to default at 1920 x 1080
Is there a way to do that?
set value to 4
Ohhh ok I'm so stupid thank you so much xD
Ayone have a good tutorial to UI objects? Nothing i do is making this damn elements stay where i put them,
Its starting t piss me off, so I figured id ask here, if anyone had a good Youtube video or written doc somwhere that explains how to force these things to stay where i put them
My canvas scaler is set to Scale with Screen Size...but its not working all the way down on eveything
This is what its supposed to look like:
But this is what i get:
Have you read this? https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html
Im reviewing it again now, ty
ok SO i was doing it correctly...but it didnt like my Free Aspect resolution
made a setting for HD 1920x1080
youd think setting Stretch and match would...ya know do what ya told it to do
working now.
that looks awesome @sour arrow ! ๐
So i have a scroll list. and i have 2 buttons
in the scroll list there is a viewport and scrollbar
in the viewport i have 2 panels
i use the buttons to change the selected panel
howeaver
though the panel which scrolls changes the other panel still shows in the back or fron depending on hierarchy
is there a way to set visibility of the other panel to false?
Use CanvasGroup to manage visibility
Whats that?
Something you should look up in the manual if you encounter something you don't know.
I have a hopefully pretty simple question, maybe I'm just missing something - I have a grid layout group to which I keep adding Prefabs at runtime. now, the Prefabs are all children of the panel with the grid and as such being displayed as a grid, with their order in the hierarchy being the order they're drawn in the grid. Now I have the problem that each prefab has a small menu you can open and it opens up on the right side next to where the prefab is on the grid. unfortunately, the menu slightly overlaps the next object in the grid and is drawn BELOW it and I am looking for a way to make it draw above it instead
Could you send a screenshot of your hierarchy please
here is a visualisation (I want the grey box to not be cut off by the adjacent panel)
Ahh
SessionTemplate being the prefab in the grid, OptionsPanel being the grey box
I know
the problem is, the lower object in the hierarchy will also be drawn later in the grid
but I need the objects in the grid in that order
hmmm
Reverse your hierarchy such that 10 is the first 9 is the second and so on
and make it so that the order of drawing them is reversed?
I have no idea how I would do that, I'm not sure it's even possible to control that
hmm
that's exactly why I'm asking here :D
it's also the kind of problem where I'm wondering what the hell I'm supposed to google for
Yeah i know that feelng
hardest part of game development tbh
so if anyone actually knows a solution for this hit me up ๐
@bright dagger If you want something to pop on top, put it in a container that is lower in hierarchy always.
mh and how do I fix my grid layout group element order?
You don't have to move the entire object, just the thing you want to show
but... the thing I want to show is always a child of the object in the grid since they're part of the same prefab
I think I got a solution though
kinda random question but is there a simple and elegant way to make a panel disappear when a click somewhere not within the panel is detected?
Use canvasGroup to control visibility
I feel like i heard that before
It goes around. It's a method with no overhead in comparison to disabling objects.
I have a question.. how do I make my ui elements smaller when resolution is changed?
When people don't know how to use UI components properly, you end up like BattleTech , opening scrollable list of 100+ items and almost halting your PC.
You use CanvasScaler component to set scale with screen size mode.
Has anyone been able to get the new UI toolkit system working with the new input system, i.e. with local multiplayer splitscreen?
Alright, figured it out. It's not officially supported (https://forum.unity.com/threads/feedback-wanted-new-input-system-support.963111/#post-6920885). But it's possible to have a UIDocument on each Player prefab, then split them like this:
rootVisualElement.style.right = new StyleLength(Length.Percent(50));
if (myPlayerID == 1)
rootVisualElement.style.left = new StyleLength(Length.Percent(50));```
Hey everyone, I'm doing a main menu and when I add buttons with textmeshpro and press play, I'm not able to get a selected and clicked feedback (change the colors), does anyone have a solution for this?
Do you have an event system loaded?
Is there anything in the way blocking it?
Thx! Worked pretty hard on it
Does anybody here have any experience whatsoever with XmlLayout on the asset store? I've got a couple of questions if any of you do!
What is an equivalent of a uGUI's prefab of specific type which is Instantiated at Runtime and added to UI, but in UITK's Runtime?
Do I need to create custom C# VisualElement for that or using just UXML Template Instances will be enough?
can someone help me: VisualElement.worldBound.width returns NaN. How can that happen?
why does the buttons get smaller when i change the size of the window
and how do i stop it
I do have an event system, that it automatically was created when adding a canvas, and can't really tell you if there's anything blocking it, ence the question. Do you need me to send anything for you to be able to help me out?
any errors in console?
Just this warning which doesn't have anything to do with it
I think
Select your event system and run the game with it selected. Watch the preview window that shows under the inspector
that will tell you what object(s) your mouse is over
it should show your button but it might show you some other object that is blocking it
have you changed the colours to obviously different colours?
the default colours are too similar
Its not about not being able to differentiate between them, is more about none of them are working lol
I will try that
... it just makes it easier to tell while you test
It doesn't appear anything in the select, on the rpeview window
I am able to click the buttons and they do what they are supposed to do
do a screen recording .. showing the whole editor
Here
someone had this issue the other day
disable this component and try again
I think that devs fix was to delete and remake the event system
Ugh - the preview window is useless for the EventSystem in the new input system unfortunately
The whole UI module or "deselect on background click"?
"deselect on background" isn't a component, it's a field
so, just this tick box
I've never seen this component before, I'm wondering if it's the cause
Now the click events don't work
but mouse over does?
Nope
it's the equivalent of StandaloneInputModule but for the new InputSystem
can you show your button inspector?
bleh - the new input system is shit, but haven't used it with UI, so.. I can't help further
Well I had an error in the event system and thought that was it, and I think It added that thing there
yeah your input module looks fine
Standart styff
Any tips?
Change the target graphic to the text
instead of the image
you don't really.. have a visible image background for your button as far as I can tell
it's the built in rounded rectangle sprite
that unity uses by default
and they have the alpha set to 0
so it's invisible already
so the color tint isn't going to be visible on it
the alpha doesn't stop it from being raycastable
it's not a problem of not being raycastable
oh, I see what you're saying
Doesnt work
And not sure what I did for this to happen? lol
you pressed visualize
wait so what is that play thing
Yep
And that's the thing you set as the target graphic on the Button component?
Yes, although its not meant to be the text but the area around it
To be selected and clicked
try seting target graphic back to ui sprite
But i did, still nothing
and set the default color of UI sprite to have full alpha
(right now alpha is 0)
I know it's not visually what you want yet but let's see if that works
changed the colors so it would be noticable, nothing happens
Did that aswell
hmm ok maybe there is something wrong with the event system/input module? ๐ค
what does the rest of the hiearchy above these buttons look like?
are you using the new input system / do you need it in this scene? -> if not, use the old event system
I did use the new input system but it is on the game scene, not this one
wait what
you're using different inout systems on different scenes?
In project settings what is your setting for Player -> Active Input Handling?
In my game scene I basically followed a tutorial to implement a zoom feature on cinemachine. I have no clue how the input systems work I just followed something that worked lol
I don't see that option nowhere
just search project settings for "input"
with the search bar
I don['t rememebr exactly what it's called
but the setting for new input/old input
Still having this bug...
Got it to work, somehow lol. Thanks for the help guys
hello
i wanna ask
how can i fade a panel in?
like its not active
i want to fade it into active
like SetActive(true);
but with fade animation
Just change Image alpha over time
wdym?
how
so i have setactive and change the alpha into 0
and when use while loop and make it into 100?
(or any other loop like for)
It won't work just with a loop, you could use coroutine for that
https://docs.unity3d.com/Manual/Coroutines.html
This page has fade-in example
Hi, I'm trying to do a drag-and-drop for some of my UI elements, in this case dragging a string of variable length into a box that then will change size to fit the string inside, so ordinarily I would place them at the 'anchoredPosition' of the box, but at the same time, I need these boxes to be anchored to one side so they don't expand off-screen when a big word gets put in them
what can I do to refer to the centre of the object without being able to use the anchoredPosition?
@dim mulch
Here's an example how to do it with a Coroutine:
StartCoroutine(Fade(1, 1)); // fade-in
StartCoroutine(Fade(0, 1)); // fade-out
IEnumerator Fade(float end, float durationSeconds) {
var start = panel.color.a;
for (var elapsedTime = 0f; elapsedTime < durationSeconds; elapsedTime += Time.deltaTime) {
FadePanel(Mathf.Lerp(start, end, elapsedTime / durationSeconds));
yield return null;
}
FadePanel(end);
}
private void FadePanel(float alpha) {
var color = panel.color; // Image panel
color.a = alpha;
panel.color = color;
}
Yeah, and when you need, you SetActive at the end or start
If you don't want to write custom Coroutines there's DOTween, which does it for you
You just call panel.DOFade(1, 1); and that's it
http://dotween.demigiant.com/documentation.php
โค๏ธ DOTween
DoTween should be a standard lib within the UnityEngine namespace. Its just that useful. Writing all those tween functions and sequenzing yourself would be too much work and somebody else already did it for you
Does someone know how to make my text box bigger? from UI > Text?
scale seems weird since hten size 14 is huge
and a bit blurry
I don't even mean dynamically or by a script I just want to change the size of it myself
Use ContentSizeFitter for that
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/HOWTO-UIFitContentSize.html#fit-to-size-of-text
Hey guys, any idea how can I "disable" the selected trigger of a button
I need it to be either normal or highlighted whether or not it's been pressed
not sure if this is best place to ask really, but im just working on a card game prototype and ideally I want cards to sit at bottom of the screen and be played by dragging them towards a target, be it a target in the world or a UI element which acts as a drop target of some sort.
Now given I want the cards to have front and backs it seemed easier to represent them as 3d objects rather than 2d UI elements, but it seems like this is a sort of common thing for people to do, so is there any pros or cons to doing the cards as a world layer vs a ui layer? as I have seen people say that having UIs that are draggable and interact with world content can be problematic but no one ever says why.
Hello can someone please help me? I have tried 9 slice a sprite for interface design but I can never seem to get the slicing to work, here is my sprite and
here is my ui and sprite settings
as you can see the gray border what is sposed to be there is completely out of wack
For me, I got my scale correctly by messing with the Pixels per unit multiplier in the image component
Try seeing if changing this value helps at all
I am working on a short unity game based on a writer reading out a script and you going through the story in your imagination, but my main menu is super boring, anyone got any banger ideas/tips for making a good main menu?
ah! thank you, I will try that out now
Screen position out of view frustum (screen pos 0.000000, 0.000000, 10.000000) (Camera rect 0 0 1024 1024)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
what is this?
everytime i move my cam
it keep spam appear
i started my unity just now
and i have 475 of it
error alr
(it doesnt affect me to start game)
What's the near clipping plane of your camera set to
ocean
i made it very big
is that caused this?
the near clipping plane is large?
ye
scale is 30000
i now made it 10000
Your game is just... not going to work well like that
hm
almost deifnitely your error is related to it
but, Unity uses 32 bit floating point numbers which start to get unworkably imprecise around 5000+
player will never able to each it end
oo
you certainly don't define the whole infinite ocean up front
I don't know, try it
but. if your near clipping plane is that high - your camera can't even see anything anywhere near the camera
i think it stopped
so idk what the point of that is
lmao
Hi. Should I use the new UI system or the old one?
yes
its ok - really shit documentation though
is it easier to use?
Why is there no text mesh pro room? or is this the text mesh pro room?
TMP is UI
This is relative. I prefer the old UI, and find it easier to use.. but I've been using it for 4 years. And have only used the new UIToolkit a bit for an EditorWindow
Yeah I'm not sure if i need to know CSS or something? I'm sticking to the old way because i am a little bit familiar wit it now
How do I override settings for stuff I dragged in from the Library in the UI builder
You mean style? Just change it
You mean elements inside Unity controls?
You want to change their style? Click on them and you'll see their classes, then you can override their style using css selectors
You can't change the hierarchy though
But you can extend this Control (extend the class, like MyElement : VisualElement) or create your own custom controls
For example, unity-label is the css class of that element
So why can't I change what css class it uses
You can try doing this
.unity-label {
position: absolute;
}
You can't change the css classes of greyed out elements, but you can add your css class to the control and try doing this:
.my-class .unity-label {
position: absolute;
}
Ok thank you so far. But it doesn't even let me add a style for the greyed out elements
Yes, that's on purpose, because these elements are created dynamically
For example, I wanted to change the image (and other style) of Unity Toggle Checkmark and did this:
.my-class .unity-toggle__checkmark {
width: 20px;
height: 20px;
border-width: 0;
background-color: initial;
background-image: url('project://database/Assets/Sprites/pin.png');
-unity-background-image-tint-color: var(--color-gray);
}
.my-class .unity-toggle__input:checked .unity-toggle__checkmark {
background-image: url('project://database/Assets/Sprites/pin2.png');
-unity-background-image-tint-color: var(--color-white);
}
So what I wanted to do was use that controls library as basicly blueprint I can drag in to customize but apparently thats not the intent?
You use it when you want the functionality
And you can customize the look with css selectors
If you want some custom functionality that isn't provided out of the box then you create your own custom controls
Almost everything is a bit different with UITK compared to uGUI ๐
How to get element's center position in UITK?
In uGUI we could center element's pivot and when calling transform.localPosition we'd get the correct position, how to do it in UITK? transform.position returns position at upper left corner (and I haven't changed Pivot Origin).
well I'd just give it a parent and use align-items and justify-content ๐
but yeah I'm new to this and I guess I have to do more research. A walk through by Unity to build something simple but individually styled would have been great.
Well, yeah, adding child positioned at the center of parent is what I'm doing right now, but I thought there's another way
And it doesn't work anyway, child's transform.position returns (0, 0) ๐ฆ
Try getting it 1 frame later
I checked, it's always zero
oh :/
Found that is can be achieved using worldBound.center
can anyone think of a reason why my VisualElement would not be getting calls I've asked for with RegisterMouseMove? PickingMode is set to Position, and there are no elements on top of it.
When do layout groups update? Should I be disabling the component after the first frame of activity to save performance if i dont need it to order position afterwards?
i think whenever a UI element is added/removed from the layout or if anything changes size
i mean, define anything
because i have sliders, toggles, buttons, texts that change
none change the "overall" size of the controls, but they do change
maybe i should just make a script OnEnable that turns it on and off after a frame to reorder once
newbie question: Im fooling around with UI, and I want to use an icon that matches an object in the game world. The lazy part of me was hoping I could slap a prefab variant on the canvas, and it would look like a 2d variant on there. However, it dosent render on the overlay. I have a text UI element next to it as a control step, and it shows normally.
Why dosent the prefab show?
hey i want to access the text & the button components using script what do i type after public
?
is it a MeshRenderer?
the type of the component you want to reference
Hello can someone please help me, I do not want to set the color of my UI Button, Instead I want to change the color of the text inside that button when that button is selected.
Change it to an animation type instead of color tint and generate and edit an animation however you want it to work
easiest way i can think of
affirm
Meshrenderers won't work on w canvas
so I need to convert the damn thing into a sprite and apply it to an image then. Or is there a simple hack of taking a prefab and making it work on a canvas?
You could render it with a separate camera to a rendertexture then draw that texture on the canvas with RawImage component.
Or just get a nice PNG of it and use that as a sprite directly
Up to you
3D objects can be rendered as 2D with rendertextures as PraetorBlue said, or with overlay cameras
But neither of those solutions are "simple"
yeah, that figures. using 3dpaint to create a png out of a screenshot takes 3 seconds, so guess thats a bit easier. Thanks for your replies!
You can also use a RenderTexture to render a model to the UI.
Hi I am new to Unity and was wondering why when I add a CANVAS it appears at the bottom left instead of at 0x 0y 0z it seems like it is the only UI element that does this can anyone help or tell me why ??
Screenspace Canvas' are their own space. It doesn't have a world position.
If you want it to be in the world, you can change it to be a world space canvas on it's Canvas component.
So it is not going to matter its size or location it only needs to be present in the Hierarchy
I just dont know how it will affect the menu or ui I am setting up
Its size is dictated by the camera viewport in this mode, you can't affect it. Canvas scaler component on it will manage how elements will be resized in it.
Well, you want to do a little learning on how screenspace UI works with regards to resolutions and such.
Ok I will go and try to find some more information on this thanks for your help @mild kernel and @azure flame Sorry if it was a stupid question just didn't know the verbage for what to look up and get a good result
I tryed a few searches but seemed like most of the stuff I was looking through was old and wasn't sure if it was relevent any more
the unity docs are good but were very confusing on a lot of the information there
If it's UI with components, it's relevant. It hasn't changed since it came out years ago.
Ok thanks @mild kernel I am watching the ui for canavs on unitys youtube site if anyone wants to check it out it is here : https://www.youtube.com/watch?v=OD-p1eMsyrU&t=118s
I also am comparing the information in the docs as well to the screens and options I want to make sure i understand it before I continue on in my class I am taking
Watch on the official Unity learn pages here -
The Canvas is the root component for rendering all UI objects in Unity.
The important part to remember for screen space UI is to create your UI to scale and stick with that resolution.
Then set your canvas scaling to Scale with Screen Size and set the reference resolution to the same.
That way it'll be a 1:1 scale with your imported UI.
Then of course, proper anchoring of your UI elements so that when the resolution changes, remains where it should.
Ok Very helpful thanks for the information I will keep this in mind @mild kernel I am trying to learn this stuff for a Udemy course I am taking hopfully it will start making more sense as I go but thanks for all of the helpful tips and usfull information I really appreciate it
Hey guys can someone please tell me if I am going insane or not?
Does it look like that second time the bar goes across the screen is faster than the first time?
UITK
Is there documentation for custom VisualElements?
Hey guys,
does anyone know, how to get a panel like in my picture on the Screen of the Computer Object, so that i can interact on the Computerscreen and not only in the UI panel i can enable and disable?
set the canvas to world
this text refuses to get any bigger than this
no matter how high i increase the font size
it stops at like
5
Press T , to change the gizmos to the UI ones.. and see how big the rect is
would also recommend changing to TextMeshPro
How do I make changes to the TMP_SDFShaderGUI.cg that survive Unity restarts? Or... how do I make a custom version of this that's unique and somehow works? New to editor customisation and Unity shaders... as material editors of the underlying shader's accessible bits and bobs
but for that my objects are to small. When i get them bigger then nothing works anymore. if i set the canvas to world and size it down you cant read anything becuase the buttons are to small
ah got it thanks ๐
๐
Hello. I made a script to put what a character says on his top:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class CharacterDialogBuble : MonoBehaviour
{
public TextMeshProUGUI dialogBubleLabel;
public Image backgroundColor;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//if (dialogBubleLabel.GetComponent<Renderer>().isVisible == true)
Vector3 pos = this.transform.position;
pos.y += 1;
Vector3 bublePos = Camera.current.WorldToScreenPoint(pos);
dialogBubleLabel.transform.position = bublePos;
backgroundColor.transform.position = bublePos;
}
}```
but when I watch exactly 180ยฐ back I see the text that comes back to my screen
how to avoid it?
please
Anyone know any reasons for a UISlider not sliding?
I don't see anything in front of it, like overlapping colliders or such things so it's very strange
How can i have scroll views scroll to the selected item in dropdown menus?
I finally arrived alone
Where/What is the file that generates the Builtin GUI in Editor Inspector for shaders like Particles? How does one find, access and edit this file?
For shaders? Or Materials?
both. im making changes to the shader i want to expose in the material editor gui
By adding exposed properties to the shader, you automatically get fields in the material inspector. If you want some kind of custom handling of those properties I guess you'd need to replace the Material editor. I don't think the editor for Material is open source, but I could be wrong
There's something I'm missing in how this works. A part of the process I'm failing to do, or even know exists. If I create a new shader, that's a copy of an existing one, and then start modding it to be unique (unique name, a couple of extra features/changes), how do I then get this to access the same path of hierarchy to UI presentation of the Material's properties? It doesn't seem to just work.
For example: I want to change the TMP_SDF shader, making my own version that has a stronger glow falloff, and a slider to control this falloff. I can do that, and can do it in the existing shader... and this works. the problem: it changes the appearance of all my existing TMP objects, so I want to make a unique TMP_SDF shader, TMP_SDFmine...
Making this requires that it know of TMP_SDFShaderGUI, the part of the TMP package that draws the GUI of the Material in the Inspector, for the shader.
Customising TMP_SDFmine with new properties doesn't automatically draw them in the Inspector, I have to modify TMP_SDFShaderGUI to do that... however, those modifications aren't saved between Unity restarts, because the package Manager forcibly resets the TMP_SDFShaderGUI file between restarts.
Attempting to make my own TMP_SDFShaderGUI_mine, leads to layout problems and many other issues in the Inspector, as there's some kind of hierarchical descendency going on that looses its flow when I use mine...
What am I missing in how this works?
I've read about the npm cache and the global cache, and unpacked the TMP version of this, and modified this... as another effort to work around this problem. This only leads to much bigger problems. Sorry to bother you with this. There's an issue that I don't know, in a system that I know of, as to how the whole system works for creating custom shaders that descend from TMP
TMP = TextMeshPro
why cant i push buttons? when i click, it doesnt do anything
do you have an event system in your scene?
you have an input module on the event system?
(and is it the right module for the input system you're using?)
i have a standalone one
and which input system are you using
the default one
Ok and:
- Does your canvas have a Graphic Raycaster?
- Do your button graphics have "raycast target" enabled?
If you select the event system and play the game, can you see your button in the "Pointer Enter" section of the preview window for the event system?
yeah to both, ill check the third one
wait nvm they work now...
they used to just be like images
whatever, thanks
Anyone here familiar with how to make TMPro's links work? I'm talking about the Rich Text ones mentioned here: http://digitalnativestudios.com/textmeshpro/docs/rich-text/#link
The docs really don't help. They mention linkInfo but not that linkInfo is accessed via textObj.textInfo.linkInfo. But even past that, I'm not sure how to watch for clicks. Is there an event handler I can attach a method to? Do I need to watch for mouse clicks and then check if it was on that link?
I found a forum thread (https://forum.unity.com/threads/clickable-link-within-a-text.910226/) but there's no code fragments to point me in the right direction.
Rich text documentation for TextMesh Pro.
I have this same issue with canvases z-fighting even when one if physically in front of the other https://forum.unity.com/threads/world-space-canvases-sometimes-appear-behind-further-canvases.357809/
"So the most likely issue is that they are all sorted by distance to the camera. The distance is taken from the center of the bounding box."
does anyone have any workarounds for this?
The only suggested options I have found is to change the order in layer or the spacing but niether of these will work for VR where the camera angles are dynamic.
how can I edit the textmeshpro in script?
[SerializeField] private TextMeshProUGUI text; I'm trying to do this but TextMeshProGUI seems to be missing
You need using TMPro; at the top
Hey guys, how would I go about creating this style of text in Unity using with text mesh pro system?
What are you trying for? that it be all caps, pink, inside a blue box, two lines, inside a blue box inside a pink box? Where are you at in your attempts?
Hey! I wanted to create the text that has a "hollow" like appearance, like an inverse masking effect ontop of a parent image such as the blue box. So in this case I am trying to recreate the pink text caused by the masking effect
Argh... I see... a "cutout" effect, like paper with holes in it from the letters....
Fake it: I think you'll have to put a texture on the TMP, in the Face part of the shader, that matches the background (pink and white lines in this case) and then size that texture so that it matches the pattern on the background, "underneath" the blue.
In the TextMesh settings, above the shader, there's an option to set the width of the textures used based on letter, line, paragraph. Choose paragraph, as this will give you a consistent scaling across both lines.s
Then you'll need to fiddle with the scale of the texture in the shader's face texture slot, as it's highly unlikely that just dropping it in there will match the background.
If the background has both a horizontal and vertical pattern, it will be more difficult.
If you really want to "sell" the effect, use Underlay on Internal Mode (again, in the TMP Shader) to fake an internal shadowing on the background.
thank you
I'm having a few problems with the text in my game and was wondering what the issue might be... this is how it looks when in the inspector and the game isn't running
and then it does this when the game is run, and shrinks...?
I've done CaptureMouse on a VisualElement and registered a mouse down callback. I was getting the callback twice, so I figured, that's trickle down and bubble up. But actually the phase is AtTarget on both calls. Other elements aren't getting the callbacks at all. How can I say "ok, I'm not interested, carry on doing the default?" Is that possible?
I have a toggle component here, I need to change the target graphic's tint manually
is there any method or property I can set to change which of these is currently set
not without selecting, highlighting, pressing, or disabling the selectable
however - one thing you can do is change that set of colors to anything you want.
Not what I need to do here I don't think
for example you can change the "normal color" to what would normally be the "selected color" in order to simulate selecting it without selecting it
I'm making a mod for a VR game which has it's own code for selecting things. There's an odd bug with it where if you select a toggle, and then select another toggle in the same group it'll deselect the old toggle but won't change the tint back to normal
man that sounds so familiar. Playing with friggin toggles and the event system and trying to get color tints to work right
Starting to hate Unity's UI system lol
some of it is pretty intuitive and great, other times you'll accidentally add a layout group to the top level and watch it permanently reset all the transforms and scales of every child and then auto save the prefab

Just can't figure out this thing with the toggles
I figure I'll probably just end up controlling the tint manually by setting the toggle.targetGraphic.color
I just don't want to lose the pretty fading transition or waste time doing all this
oh!!
Found a fix
Just disabling the button gameobject and re-enabling it on the next line resets the toggle color. Just have that running in a listener on the value changed event
Mm.. doesn't seem to work if I press the same toggle to turn it off though
This is why I design all my UI using only layout groups, with no manually-positioned elements (well, except for dropdowns, since they don't play nicely with horizontal layout groups - I just add a layout element and set the preferred height to 30). The learning curve is pretty steep but once you figure it out, only using layout groups makes everything a LOT easier to work with.
Yeah I figure that system's probably better
still can't figure out this toggle thing. I assume it's due to how the game is doing it's selection stuff
With that kind of thing I find it very helpful to draw (MS Paint, Photoshop, paper and pencils, a whiteboard, whatever) exactly how you expect the UI to look. You'll figure out a lot by doing that (including sometimes helping to figure out a sensible way to store the data internally). Work out what should happen when the user clicks each option. And then if you post that here I'm sure someone can help you figure out how to achieve it.
There's also tools specifically designed for that called "wireframe" or "wireframing" tools but I've never been a big fan of them.
Does anyone know if it's possible to create buttons in a windowed build of a game, just like the buttons you have at the top of unity?
Or do you have to create those manually?
I would imagine you could do it with native Windows calls if you could get the handle of the current window but I doubt that there's a built-in cross-platform way ๐ค
Mmmh, might look into that. Or just recreate it with unity buttons. Thanks
I would definitely just recreate it with Unity buttons because I'm lazy lol
how does one add boarders to a 2D image so it can be sliced?
Open it in photoshop or a similar program and add to it?
the "slicing" part happens in Unity
you can do it with any image
god damn it I keep forgetting to remove my messages once I'd found a solution, thanks anyway guys
turns out I didn't even wanna slice, I just needed that 9 square boarder thing which is even easier lmao
Hi. I have an issue where the first textbox in my scrollable list is wrongly placed. all the other are appended on top.
is someone familiar with this?
but if i click on the GO in the hierarchy, it refreshes and is in place (however this is not doable in build ๐ )
if anybody needed more info about my issue:
so i solved it with the below code, probably a bug or something.. (calling one rebuilder is not enough ๐ )
@livid canopy Sometimes I find doing Canvas.ForceUpdateCanvases or whatever it's called is necessary. Not sure why
So, I'm looking for some tips, I have a mobile side scroller, but when I press one of the menu buttons I want it to seem like the camera pans away from the character.
Just move to the right/left instead of having the UI move.
So my thoughts was to have the UI in world space, scale it to the size of the screen and then move it to the exact position I need it to be in based of the screen width.
I have done this one a previous project, but I kind of want to hear if people have any other ideas or best practices for how to make this effect come to life?
Can you send a video about it?
Your issue...
It's not exactly an issue, I just want some advice on how I should do this in the best way. I want the camera moving instead of the UI. And the UI needs to be scaled to the screen size but moved to the sides.
okay..lemme think
Could you not just have in screen space - overlay and then pan it in the opposite direction to the camera? Seems easier and more reliable than trying to line it up in worldspace ๐ค
Hi all. Im trying to get my TextMeshProUGui (world space canvas) to render in front of everything, but even changing the material to DistanceField or Overlay, it still doesn't work
Any hints?
Oh wait, actually it DOES work!
But the TMP <sprite> (the fire icon) doesn't as seen in the pic. Is there any way to do this?
But if I do that, how do I make sure I move the UI at the same speed as the camera depending on resolution? Seems like way more work to me rather than just at startup measuring the UI from cam size, positioning it in world space and then just start moving the camera around... Or am I missing something?
I would still need to scale the UI with overlay to fit the screen I assume
Oh if you position it programmatically then sure, go for worldspace. I was just imagining you positioning it by hand and then hoping it would still be correct for different resolutions. Can never assume anyone's skill in this discord ๐
Ah, okay, thanks.
I would be lazy and just use a second camera lol
It works, edited the default TMP/Sprite shader a bit
My bonus question is, it seems i cant make a new material for TMP sprite? Hence why i gotta edit the default shader (that is used by the default material)
Ah ok it seems i shouldnt change the "default material" that's already assigned, and double click and edit that directly (the shader n all that). It's hidden, and any sprite asset's default material got the same name, but apparently they're different..
I'm using the URL of a Texture2D asset as the cursor property in a USS file. The import settings specify it as a cursor. The image is 16 x 16, however when I mouse over the element it scales it up to 32 x 32. Any idea what I've done?
Hey all, any ideas on how to set a single word to a different colour using TextMeshPro?
Rich text documentation for TextMesh Pro.
Can someone help out @sonic coral he is sayi g that his sliders not working its working if he makes another scene but in the same scene it doesn't
They don't need you to ping other channels on their behalf.
Sorry
I was tryinna help him
And i pinged him to let him know that he can ask dedicated ppl about that topic on this chanell
U just target meh all the time u dont like my name or u dont like my pfp?
XD
I don't even know who you are. There are hundreds of people who pass through here a day.
...
But if you feel like you're getting targetted, try reading #๐โcode-of-conduct to see why.
...
Aa?
I learned another lesson today
Trying to help others is Bad
Yep, you can use:
https://docs.unity3d.com/ScriptReference/Screen-safeArea.html
https://www.youtube.com/watch?v=CGEoNW4RPmo
Do you know how Overwatch achieved this loading screen ? is it a video loop or some kind of image just being animated though scripts?
Havenโt done overwatch in a while #loadingscreensgameplay #overwatch #loading
definitely not a video
animations probably created in some external software
and orchestrated in-game with some kind of Timeline thing
afaik blizzard uses their own internal tools so there may not be 1:1 equivalents in the Unity world
As said it's made with their own specialized tools
Probably some form of keyframing and programmatic tweening
I'm not too sure why, but buttons aren't responding to being clicked in one specific scene...
they work in one, just not this one and I can't quite figure out why
does that scene have an Event System?
shit...
thank you very much :)
I am not a programmer so this is a bit new to me. Is there an easy way to control animation with keyframes of the material/shader values of textmeshpro?
Basically we have this big timeline animating a bunch of materials & objects in a scene and want to have some text reveal through the dilate effect in the shader
Can I use another button to change between these 2 onclick events?
If the dilate variable is exposed in the inspector, I think you can keyframe that to change as well?
it's easier to have one method that starts the on click method and inside of that method check if any other button is clicked to send commands somewhere else.
how to convert an image to sprite2d ?
i dragged and dropped it in the assets folder from canvas but the texture type doesn't show up in the inspector!!
You have to set it as a sprite in the import settings
thanks i figured it out ๐
it's positioned off screen
this white line is the canvas, if you put something outside of it.. then the camera won't see it
and why the camera see the other button?
keep the scale at 1,1,1 and change the size of things with width/height
I don't think it's part of the canvas
RectTransforms are for canvases.. UI is for canvases
Those are just names, not components
okay
Just Dance must be a canvas
"Quick Play" I suspect is a SpriteRenderer.. so is done incorrectly
quick play is just an image
there is the button on game part but on scene is super big
Yes, the UI in the scene view is huge - it's supposed to be
Select the "Just Dance" game object, then put your cursor over the scene view and press F
but what?
i cant make the canvas like the background size?
that white box is the canvas.. it is the correct size
it resizes to the size of the camera as needed
Anyone got tips on where to start with UI in a new project? What's the latest from the Unity team? Are we supposed to be using the new UIElements package ?
Nope, currently, you should continue to make your UI as normal. The UI toolkit isn't production ready.
when you say UI as normal.. what do you recommend?
Using the built in UI system. Creating a canvas object, putting child elements into it. The usual.
Hey everybody, i'm having this weird issue where one of my Sprites is only a fraction of the size of all the others, but appears in normal size in my game view. When I make it normal sized in the scene view, it disappears in the game view because it gets too big. Any idea where this issue is coming from?
no dice, it doesn't turn red and I can't add it as an animation track
It's because you're using SpriteRenderer instead of Image
sorry for the delayed answer there.
Everything else in the scene is a UI element - e.g. Image, Text, etc...
Omg it worked! I can't believe I missed that, thank you for the help! ๐
Is there no channel for discussing the Unity editor interface?
#โ๏ธโeditor-extensions might be the closest one
If not, #๐ปโunity-talk is for anything that doesn't fit a channel
hello everyone,i am making 2d andoid game and i have problem with screen resolutions
my ui is acting weird, buttons only work sometimes
you may have other invisible UI elements blocking them
i fixed it a couple minutes ago and forgot to put it here, my cursor was being locked by another script
Is there anyway to make textmeshpro objects toggle on and off with the gizmos tab?
No as they're real objects not gizmos. You can draw "gizmo text" with Handles.Label though
(editor only)
In certain games theres lines of text that are highlighted, and you can click on them for extra information, how could I do that in unity?
TextMeshPro link and color tags
https://www.feelouttheform.net/unity3d-links-textmeshpro/ something like this to detect when mouse is over the link
excellent thank you so much
Hi i tried the ui builder out and in the tutorial they added a ui document to the hierachy but i cant do i still have to add it or how can I add a ui
look there is no "UI Toolkit > UI Document"
@sterile wedge this is how it looks
your text isn't a child of the canvas..
umm in the scene it is
but thats not whats the trouble the text works
the button doesnt
@low pike
does your Canvas object have a canvas component on it?
"Doesn't work" is vague
so it's not a problem with the prefab, by the looks of it.. it's however it's setup/positioned in the scene
doesn't appear -> either game object is disabled or positioned off canvas
doesn't click -> there's something blocking it or you don't have an event system
event system is on its own gameobject - check the hierarchy.. if you cant see one, add one
probably easiest/ best to just type "event system" into the hierarchy search
oh I have it now
isn't 0.45 is less than half a pixel?
does that matter?
if it IS less than half a pixel.. do you think it would be visible?
half a pixel would not be visible
and the button appeared I did this before but they wouldnt appear but now they work cos u told me to add event system
so now it works
but wait how do I make it show on top of other things?
oh I had to add material
add a material to what?
the order of the hierarchy matters
ohhhh
ok
another problem now when I try to click the button it doesnt work bc of the text being on top of it
btw ty so far
because the text isn't a child of the button (like usual), the click events don't get passed up to the button
turn off raycasting on the text
it's under extra settings
it works perfectly now ty so much
it'll be worth doing some of these: https://learn.unity.com/search?k=["q%3Aui"]
yeah thanks I dont use UI that often
when i add vertical layout group my ui contents are mixing up!! what to do?
it was like this before adding vertical layout bar
you need to group them first
the layout group is going to affect everything that's a direct child below it
how to group them?
@rapid ferry you need to do these too
how to group it?
Hi guys! May I ask, I want to make this picture bigger, but I can't do it without making the border bigger as well. Is there any way I can do it while the square white boarder stays the same? Thanks!!
(picture meaning the button)
9 slicing
that's the main thing it works for
Oh and SpriteRenderer too
sorry for asking again but I think I am not doing this properly. I am guessing, that when you go to sprite editor and you put the borders around your image, then when you insert the picture, the borders will be around it correct? Well for some reason they are still not around it which sucks. But even if thats not the case, I guess what I have to use is the sliced mode, so I can make the picture bigger. But still it also makes the boarder bigger. Im sure im dumb and its something really obvious, but I cant see it so again sorry for sending a message
you have to use sliced mode, yes
how are you making the image bigger
you should be using the anchors and such
not using Scale
anchors are changed with the rect tool right?
they can be yes
that doesn't change the anchors it changes the offsets from the anchors
which is fine
yeah im using the rect tool and it makes the boarder and the picture bigger as well
ill do it from the start maybe I didnt do something correctly
You set up the borders in the sprite editor?
Like this?
And saved/applied everything?
You know what the problem was? I am guessing at least. Because the pictures pixels were 3k*3k, when it was so small they were scaling together. But when it reaches that size, the boarder sticks to the image and when you make it bigger it works as intended. Thankfully that's all I need right now so it works. Thank you so much for your time!! <33
Hey there got a probleme where my UI image show itself only in scene view and not in game view
Here is the material setting https://cdn.discordapp.com/attachments/493511037421879316/869315328784605215/unknown.png do you know what could be the problem ? It's on HDRP
After further investigation, it looks like HDRP does not support custom UI shader on Screen Space overlay
Is it possible to import the same image file twice, using different import settings, without needing to duplicate the file itself?
I have a custom cursor, but I need to use it both as a custom cursor and in an Image in the UI (the latter is used if the player is using a gamepad rather than a mouse). Using Texture Type โSpriteโ works for the UI Image, but it causes Cursor.SetCursor() to generate a warning. Texture Type โCursorโ fixes the warning, but now the UI Image can no longer use the texture.
Hey guys. How would I go and make some Pre Combat scene like this one? See that when you change from the Armory to the World Map they are different 3D models involved and there is not loading extra scenes.
I was thinking putting everything inside 1 scene and place it in different locations with different cameras? And then you activate the camera you need?
What is a good approach to this?
How do you know it's not multiple scenes. Because it switch instantaneously it doesn't mean it cannot be multiple scenes. The scenes can be loaded all together at startup.
You can also just put everything super far away of each other and activate deactivate camera yes it's a way to do it. You can also have a single camera and a script to switch it's position.
@crisp oxide hi, thanks for the answer, when I said multiple scenes I meant, loading and unloading... this could be some additive stuff for sure, but for the mechanic of switching menus I assume everything is already loaded
Is there a better way of achieving this than putting everything far away and switching cameras? Never had to deal with something like this
Was looking around and found nothing
Another approach would be a single camera and put everything under a different empty gameobject at the same place. Then you just activate and deactivate the gameobjects to switch your scene.
I would go for this one
you need the white part at the top of this to be transparent
and then you just overlay them?
Anyone has any experience using scroll rects in code, I have a scroll rect that we have set up to display items for a storage, and we have a custom navigation tool created for navigating menus and whatnot. And the scroll rect is set up like so and expands and works as intended. However, When navigating the menu using this code https://hatebin.com/bikqipsinp It does work when using this value for specific resolutions, but on changing the resolution it loses value, and it's likely because we have a scalar on our canvas to scale with screen size, matching x and y with a 0.5 value.
I know I likely need to determine the resolution and figure out some special mathematical calculation to do, how would I go about finding that information? I've messed around with it for awhile but no luck
I want to use a shader
@flat violet Don't spam the channel. #854851968446365696 on how to ask questins.
question about UI... I made my UI and it is working but I am not sure how I will make it deal with changing the resolution... any idea or help on the topic?
If I set "default is native resolution" to true in build settings, does it perfectly scale the game to whatever size? I know if I set a resolution that is smaller than my screen like 1280x720, the screen gets blurry when I fullscreen. I'm wondering if this still happens if I do default is native
thank you
question about scrol views... I want the content to change its size when a prefab (prefab is instantiated into it) .. because my problem is that I can't scroll through it correctly unless its size matches the number of the objects I have parented to it (it has a vertical layout)
any help on what I should do to fix it
so far I have managed to make the size of the content change.. but i am not sure how good it will work on a different resolution .. so I am still open to any suggestions on how I can change the size of the content game objects in the scrol view...
second.. when I change what button I am picking in the content, if I go out of the currently seen range of the view , the scro;l bar doesn't follow... how do I change that please
What's a good way of storing text for UI elements? Having the text in a script feels... weird.
Or like dialogue and such.
Is ScriptableObject the way to go when the text isn't Game of Thrones length?
Sure that, or a field on a MonoBehaviour. Or in a file, or in a database. Up to you really
localization files are a thing too ๐
Scriptable objects are perfect when you need them to have additional logic together with holding dialogue data, otherwise keeping it in Json would be just fine.
Is there a way to render ui elements behind world objects using the Screen Overlay canvas?
I have a script that will keep a marker above an object when the canvas is in screen overlay, but changing it to world space or screen camera messes up the position of the marker. It no longer stays above the object
hey ive made a canvas but in order to add a button in thee corner of my screen i have to move the button outside the canvas is this normal?
i have to do an afk ill be right back
....
cancel that i solved it
Hello everyone can someone tell me if it is Possible to make a sprite renderer appear On The UI canvas while its not under the Main Camera ?
What's the intended purpose?
My goal is to have an animated sprite In an UI component instead of a static image
Isn't it possible to animate images the same way as sprites
I dont know i tried to had an animator i created for a sprite renderer before on an image but it does not work (or maybe im forgetting something obvious)
Sprite renderers are for the game world. Image is for the UI
Is it possible to animate an image the same way as animate sprite renderer using Animator ?
of course
Ok thx im gonna try that (i tried to use an animator i made for a spride renderer on an image but it did not work ) im gonna try again !
why doesn't the main menu move with the camera?
the canvas doesn't scale with the camera
Probably because it's a world space canvas
do i need to adjust the UI for all resolutions?
Does it need to be world space?
You could use the Canvas Scaler if it was screen space
i needed it like that for a specific transition, but i worked around it by moving all the menus inside the canvas
its screen space now
but its still kinda off
@chrome kettle
You're not using the Canvas Scaler
does it have to be Scale with screen size?
I don't know what your intended result is
i just want the UI to scale with all resolutions
so the buttons dont go on top of each other
So why not scale with screen size
There's options in Canvas Scaler, and you also have the option of using anchor points
Experiment
yes i have those correctly
when the resolution was 100x100 it was all over the place
so i made it 1920 x 1080 and now its alright
Prioritize resolutions that your users' devices will likely have
How bad does this look? I was able to reduce re draws by 6 just by making sure ui elements don't overlap
use textmeshpro if u can
I was reading somewhere that text mesh pro is better on performance. I just havent switched over yet
just use it lol, it gives the text a more crisp look
instead of the normal unity pixelated text
and gives you more accessibility
Not stressing over the look yet. Trying to make sure it preforms great on a variety of devices. Yeah TMP is insanely flexible
Is there any ready-to-use asset that provides dropdown UI element with searchbar?
something like this
Hello I've just begun learning UI and have a query about the sizing of the UI in the game/scene view and in the actual game- they seem to be inconsistent
I added 3 buttons and an image just for an example, here is the game preview:
however when I maximise the game screen on play, the UI stays the same size.
That's based on the settings on your Canvas Scaler
Hi! I just need a bit of help for the inputfield, I want the placeholder text "//" to stay and be unable to be deleted when I type and not disappear like it normally does-- for example:
// text
is there a setting or script for this?
probably not, just try doing some UI tricks like for example try putting it outside the input field or add a text in the beginning that just says //
there is some ways around it
Ohh alright then, thank you!
question... when I get the available resolutions of my screen, to put it in a dropdown .. I get each of the resolutions a couple of times.. why is that happening? does anyone have a clue?
i want to make chess.I grabbed this chess board from google , made a canvas , made an ui image , and assigned its source image to the board
but it looks like this
how would i make it a square?
don't use Sliced image type
use simple, and there should be a "preserve aspect" box
Could someone take a look at my issue with zooming in UITK? I can't figure it out on my own
Had implemented uGUI solution before, but struggling to convert it to UITK
https://forum.unity.com/threads/zoom-in-and-out-around-the-cursor.1144190/
By using an image editing software to crop the image
Even Paint works for a simple job like that
The source image already is sqaure, they don't need to edit it. They need to fix the UI image. PraetorBlue gave the probable solution
The source image is 1500x1125 with a lot of wasted transparent space
"preserve aspect" works because it preserves the odd aspect ratio
He's got it set to sliced, it doesn't have the preserved aspect option
It does need cropping though, you're right. Expanding the image, I couldn't tell there was wasted space around it until putting it in PS
Not sure if I am being an idiot here, but I am wanting to have some cards in my game, much like common card games where you have some in your hand. The thing is I wanted the cards to be 3d so you can turn them round etc, and historically ive only done 2d UI style things, so is there any gotchas with doing 3d uis? as I basically want a 3d object and then put UI elements on it like text/images etc, any best practices/gotchas?
Always have the scale set to 1,1,1 on everything, but have a parent transform that you set the requried scale on
ScalarTransform - > scaled at say 0.002, 0.002, 0.002
|- Canvas -> set to world
|-- everything else
From the 2019 Unite video about UIElements the speaker says, for ListView, to populate it, he just needs to call it the right thing here https://www.youtube.com/watch?v=t4tfgI1XvGs&t=1650s
How does this work? How do I populate my listview with buttons?
YouTube
Unity
Building UI for games with the new UI Builder - Unite Copenhagen
A single, unified, UI editing tool in Unity โ that's our goal for UIElements. In this session, we cover what's available now, share what we're working on, and give a glimpse of what's coming in the future. Learn about UIElements for runtime, new UI authoring workflows, and how we're building the tools to benefit artists and creators.
Speaker:
...
question in buttons... I want a button that has a picture instead of a text, the button has an image component, I put my picture in the image component BUT IT IS NOT SHOWING ... do I have to add another game object and give it a sprite component or what?
nope, just add the sprite to the source image on the button.. and it should show
Is it posible to do something like map pins using UIToolkit?
help pls, not clickable when cursor in the middle part
My guess is it has to do w/ the alignment of the collider used for interaction and the text.
For pins on a map, is it better to spawn game objects to the corresponding world position, or to use UIToolkit & create the element & find the correct screenspace?
All pins are 2d.
hi all,
i'm trying to create a grid snapping system for UI objects i'm creating. i'm doing it by Mathf.rounding their position. Since an objects position is based on its center, my objects never line up. is their a way to base their position on the far left of the object?
the position of a UI element is usually based on the pivot, no?
You can change the pivot in the rect transform
i changed the pivot and it didn't seem to make a difference
all the objects are children if that makes a difference?
to expand: i have a system that creates x amount of buttons for the user. if there is 0 spacing between buttons i have no issues. it seems that creating space between each button makes the widths variable and then they stop lining up correctly
how do i add a .ttf font to my UI? when ever i apply the font my text disappears
I downloaded a ttf font and I'm trying to change it in stylesheet:
-unity-font: resource('Assets/Resources/Fonts/Coda-Regular.ttf');
that doesn't seem to work, is there an extra step I'm missing?
I can see it defined in the UI Builder but the font appearance doesn't change:
Guys, I need help, I have a multiple canvas system in my game and there are also buttons in these canvases, how should I make it so that I can navigate with a controller (I'm using the new Input System) the buttons even if they are in different canvases?
Not sure, but I think you'd have to program it yourself
You could create a simple component that holds references to the things you want to navigate to on left/right/top/bottom
Thanks, I thought I could do it without code
You definitely can within a single canvas, but idk how the situation is when navigating between childs of different canvas objects
Very much possible that I'm wrong and there is an easier way for your situation, did you look it up on Google?
You have to import it into unity (drag it into your project window), make sure it's a Sprite in the import settings, and then you should be able to assign that sprite to the image component of your button
But you should Google simple questions like that before asking them here
let it try
lmao how could I know I am not even aware of difference between png and a sprite
but ok
nvm thanks
You're welcome ๐
It's still a "png", just by marking it as Sprite you let unity recognize as a sprite so it can be used for sprite things
Type of "default" usually means 3D texture stuff
looks great
so i have this stamina wheel type thing, but I want it to be a much higher resolution, do I need to find higher resolution images or is there another method
Is it an image or a mesh or what
its an image i downloaded from google
The resolution judging from that image seems fine, rather it seems to have no filtering or mipmaps
Can you show the import settings
import settings?
Import settings of the image asset
Enable "generate Mip Maps"
See if that helps
No
Does it suggest anything by default
๐
final quick question, where do you think I should place this wheel? Its like the ammo charge level for the gun
Around the crosshair mayhaps?
i did try that but i felt like it blocked the view of enemies
i need to add a healthbar too
i looked at the one in breath of the wild which is in the middle with an offcentre but I feel it would look weird
Yeah, I did, but not much came up, I think I'll do it via code
How do I make a UI element always automatically stretch to fill the screen
use the full stretch anchor preset and set left/right/top/bottom all to 0
Just out of curiosity since Unity is having sale right now; I'm going to be doing a cutscene system that's comic panelly and I got
https://assetstore.unity.com/packages/tools/utilities/panoply-comics-splitscreen-for-unity-58506
In order to do that. Are there any other asset store buys that are worth it for making easier dialogue systems? I already got Pixel Crusher's Dialogue Systems aswell.
does anyone know why my canvas doesn't allow me to press buttons or use input fields?
I have a graphic raycaster
Do you have an EventSystem and Input Module?
All good now ty
Confirm that the sprite is in front of the camera on the Z axis
I fixed it already ty
Try moving the z of your camera
Not sure if this is the right channel to ask, but I have a font Sprite sheet (.png) and i'm trying to figure out if I can convert it into an actual .ttf file
Anyone know how I could go about doing this ?
๐ฅฒ
never done it before.. but I don't imagine you'll get good results..easily. Aren't fonts vectors? PNG's aren't.. so converting a png to a vector is going to result in... imperfections
Well yes, found a nice font on itch.io that I wanted to use but the person who published it published as a .png file
Text Mesh Pro converts fonts from vectors into signed distance fields
It can't do that with pngs as well?
Couldn't figure out how to do it, I'll look around a bit more
https://docs.unity3d.com/Manual/class-Font.html custom font creation down there
Not sure if this workflow is TMP compatible
The 'Font Asset Creator' for TMP wants a font file
https://forum.unity.com/threads/invalid_file_format-error-when-attempting-to-create-tmp-font.732050/ here's a thread where they're talking about the topic
...possibly
the dev there constantly goes back to talking about importing ttf files so I'm not even sure it actually concerns bitmaps
I think it's not worth my time to even continue looking for a solution to this
Might as well just find another similar font
Certainly
there are websites that allow you to upload an image, it'll scan it and tell you what the font is /suggest similar
There probably are similar services that let you create font files from images
Who knows how they work with pixel perfect fonts though
does anyone know why my screen space canvas works in play mode, but not in a standalone build?
define "not working"?
hang on the screen space canvas isnt the issue
i have a screen space canvas in my scene, and theres a background image with an aspect ratio fitter
but the background image doesnt appear in a build
the issue is the aspect ratio fitter
i removed it and it appears, but i still dont know why i cant use that
try setting your game window in the editor to the resolution of your target hardware
see if you can reproduce the issue
i tried that and also changing the player to/from fullscreen and the issue always appears in the build and never in the editor
i tried changing the sprite to one that does appear properly and the issue wasnt the sprite itself
something with the aspect ratio fitter
I'm creating a companion app for a game and one of the things I want to do for it is to have an interactive map of the game world. I know the game was made with Unity. I've been trying to figure out a way to export the 2D maps of each world (the maps in-game are 2D but the game is top-down 3D). Other people must have figured out how to do it because there are maps online but I don't just want to rip someone else's map. Is this possible and how would I go about it? I've tried downloading a few Unity asset explorer type applications and so far all I've been able to export is texture maps for 3D models which isn't what I'm looking for.
Such a thing might not exist in the game assets. If there's a map/minimap in the game it might be a 3D rendering of the terrain or something
I'm trying to implement UI item dragging using OnDrag() but the problem is that when my image is in "dragging state" it is invisible. My code and settings:
hi guys I have a problem why is the back button overlayed with the quit button
i have made a script but it doesnt seem to work
why isnt it working
Maybe void Start, capital S ?
Seems like just a layout problm. Are you using a VerticalLayoutGroup?
Also that yeah ^ Start needs to be capitalized
okay well that sorta fixed the problem
however
how when I click the options button the back button is now gone
What happens when you click "options" button, do you switch scenes?
the guys is saying to add the option script to the option menu unless im wrong
a couple problems
the text is still there and when I go to the options menu and press the back button it works but then I go back into the options menu and the back button is gone
One question, do you switch scenes when you click options button or are you using different approach (for example enable/disable buttons)?
Does anyone know how to make a rectTransform do this through code? (basically make it stretch to fit the parent)
How do I anchor my UI to the bottom of screen (or any side for that matter) so it adjusts depending on the device? I am setting the anchor and using the simulator but it doesn't keep within the size adjustments?
Nvm I had the UI under a panel and needed to set the panel to Stretch...
ui element following the object. how can i do this ui?
either world space or WorldToScreen
The churn is too much in main chat
is there any scenarios where a TMP text element would only have a really thin thickness even though you have like 70% ratio
i.e SP 46, Padding 32... thats over 60% ratio and I still get super thin lines like
Is there an easy way to have the same animation for any screensize? Or do I need to change keyframes through script?
can you animate the like, anchored relative offset stuff, instead of the actual pixel position?
I don't think so. I'm just gonna change the x keyframe to -width of rect
You can try increase the padding when generating the Font Asset, this will increase the SDF (Signed Distance Field) space.
Yes, first you have to guarantee that your Canvas has a Canvas Scaler component, with Scale With Screen Size properly set to a base resolution. After that you should be able to do operations using pixel values without a issue.
But note that if the Aspect Ratio changes, you should be careful with anchoring to get a UI and animations that adapts correctly.
@obsidian crag Yeah I had those settings and it still doesn't work
it is probably an issue with the anchoring, since 1440x2960 and 9x16 are different aspect ratios.
You can do its anchor at the middle right (like it is), but I recommend setting the pivot to X 0 Y 0.5
This way when animating you just need to put it X position to be its Width (but negative)
Also, the width of the object seems to be not adapting to the aspect ratio, making it thinner on 16:9
and not filling the entire screen
yeah I already wrote a script to fix that at runtime
Pointing it out would be easier than describing, sorry if it seems confusing haha
maybe that's why it's not working
hmm i'll figure it out tomorrow thanks for the help @obsidian crag
@undone sandal
Decided to make a quick video about it running on 3 different Aspect Ratios with the same animation clip. Hope it helps. Also no need to adjust on runtime*
What are the reasons why UI wont show up in the Scene & Game view?
thanks man! that helps a lot
Never mind I found the cause of the problem, my hand must of hit a key and zeroed out my UI's scale...
I already have the padding really high, as it's down to ratios right? I. E if I have sample point at like 60 and padding at 30 that should gov eme up to 50% thickness available right? But that's not what I see, I just get a line as shown above, even when I go up to like 70% ratio and have full thickness
So I wasn't sure if there was another issue causing it to not act like it should.
here are some settings I was messing with to get the image I showed before
So there should be more than enough padding to get a decent outline
also for some reason when I go to play mode and show the element containing the text it looks awful
Looks fine in scene though
oh fixed it, I needed to set it from SMOOTH to SDF
Are there any good approaches to managing prefabs that contain UI elements but dont contain a canvas? i.e to reduce draw calls there is a single canvas which contains all instances of the prefab so there is a containing canvas, but at prefab level it doesnt have a canvas, so its difficult to actually do anything in isolation
I assume you would need some form of translater right? in most cases you have a localisation database and translate them manually, unless this is some sort of puzzle game and you just want to change one character to another
oh in that case it would just be string replacement
unless you wanted it animated in some way
simplest would be just get the text element that contains your stuff and just do a string replace of each character or position
Anyone have any experience with trying to put UI elements over gameobjects heads? I assumed it would be a simple world to viewport style calculation, but I am using URP and have layered cameras and it doesnt seem to work as expected. i.e one camera for game objects in the world (in-game) one camera overlayed for just UI elements
Not the best approach, but a simple way is to use World Space Canvas set to their head.
If might generate some more extra draw calls for each Canvas, I dont remember if they are on the same Sorting Layer they are batched.
I did think about using a world space thing, but problem is the cameras may change slightly, i.e there is a top down and a chase style cam, and I would need to rotate the UI bits to simulate a billboard style approach between 2 cams
so it felt simpler to have a camera/screen canvas wrapping them and just have it get the world position and show it on screen/camera so you avoid the needing to make it always face the camera
Well, you can simply attach a script "LookAt(CameraPosition)" on the Canvas, like some old sprites games do
And they will act as a billboard
oh right I didnt know you could do that
I will keep that as a backup
but I assume there should be a way to do it via a camera/screen approach right? as I can see them moving about on the canvas but it seems to be really far off the screen
I assume if it was one camera it would be fine, but as its multiple they just have no idea whats going on
Well, this is a best approach. With only one canvas, and the elements being updated dynamic. Seems good
yeah its just not displaying as expected, but I dont really know which camera I should be using tbh, I assume I should be doing world to viewport on the in game cam
but as its rendering on another cam (to avoid post processing and other stuff)
So I can see they are shown on there and seem to have been moved around
but then the in game camera is like that
so as you can see the top picture has the camera (selected object) not showing the elements correclty but not sure where it all is going awry, I assume its because there are 2 cameras at different positions
but unsure
These icons were supposed to draw above the characters right? If so, it makes sense to have the 2 cameras at the same position. Since you get the character position to update the icons.
The UI Camera one should have a higher Depth and on Clear Flags you can use a Depth Only (to avoid clearing what the 3D Camera draw)
they unfortunatley live in different scenes ๐ฆ
I can make a script to make the cameras mimic the same position
(oh and yes they were meant to draw on the char, not fussed atm if its on their head, as long as its roughly where they are, as they will need resizing and other stuff)
(also worth noting in URP you only have a base and overlay camera, there is no specifics to Clear flags etc)
Ah yeah URP, forgot about that part hauauh
I was looking at my built-in project as a parameter guide :p
I have botched it to make the camera a child of the existing camera, so its in exactly the same position but the stuff is still drawn on the canvas miles away, but not sure how it translates that to camera view
public void SetUnit(Unit unit, Camera gameCamera, Camera hudCamera, Canvas canvas)
{
_gameCamera = gameCamera;
_hudCamera = hudCamera;
_canvas = canvas;
// other stuff
_canvasTransform = _canvas.GetComponent<RectTransform>();
_canvasOffset = new Vector2(_canvasTransform.sizeDelta.x / 2f, _canvasTransform.sizeDelta.y / 2f);
}
private void Update()
{
// Unit Transform Cache is a handle to the GO transform
if(UnitTransformCache == null) { return; }
var viewportPosition = _hudCamera.WorldToViewportPoint(UnitTransformCache.position);
var proportionalPosition = new Vector2(viewportPosition.x * _canvasTransform.sizeDelta.x, viewportPosition.y * _canvasTransform.sizeDelta.y);
_localTransform.position = proportionalPosition - _canvasOffset;
}
That is basically the logic atm
incase you see anything awry, its based off someone on the unity forum
oh I htink I may have solved it ๐
ok so one extra bit of info was that the prefabs seemed to have their own canvas, so removing that seems to fix it, as tbh I dont know why they needed it as they are all under a root one anyway
oh well it works as long as its in the same location as the game cam, if its at another location it doesnt, but thats something new I can work with
thanks for your help Alan
Hey everyone, Im doing a side project and was wondering if anyone knows a way for me to have the same resolution on all phones ( I don't want to deal with anchoring shit ), what I want is my game to always be in 1080x1920, but if a phone is smaller or bigger the size of 1080x1920 proportionally gets scaled up or down
what about different aspect ratios?
the hitbox of the button is based on the target graphic I think? Either that or the RectTransform
yo guys i designed a UI thingy in blender
how do i get this to work in unity? i've been completely and utterly failing for the past 2 days with zero clue how to find answers for the tiniest issue
i tried googling or reading documentation or tutorials and nothing is working... i feel stupid
use a canvas scalar, set it to whatever resolution you want and tell it to scale with width/height
Hi Guys, i have following question: I have a Canvas with Screen Space - Camera and i want to have a rect transform from another canvas with Screen Space Overlay to be on the same position as an other element in the Screen Space Camera Canvas. How convert screen space camera rect transform position to screen Space overlay position?