Unity 3D : Menus Part 2 (Text-Mesh-PRO in 5 Minutes!!)

  Рет қаралды 5,763

Royal Skies

Royal Skies

Күн бұрын

Пікірлер: 50
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
For anyone wondering what the website was for all the fonts here it is: www.dafont.com/theme.php?cat=303&page=3 Code for the tutorial can be found below! { public TMPro.TextMeshProUGUI myText; public int myScore; public RectTransform myRect; void Update() { myText.text = "Your score is: " + myScore; myText.fontStyle = TMPro.FontStyles.Bold; myText.color = new Color(1, 0, 0, 1); myRect.transform.localPosition = new Vector3(30, 80, 0); myRect.localScale = new Vector3(1, .5f, 1); myRect.sizeDelta = new Vector2(360, 600); } }
@Build_the_Future
@Build_the_Future 3 жыл бұрын
hope you keep going with Unity tutorials I'm really enjoying them. I hope you can cover, Animations, Ik, explain how and why to use quaternion, Animation stats, Animation controllers/avatars, blending, physics, How to speed up FPS, Useful assets on the store, Unity apps, etc.
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
@@Build_the_Future So glad to hear you're enjoying the content - You'll be happy to hear that the vast majority of those will be covered in the "Advanced Unity Animation Programming Series". It's probably gonna be in a month or two :)
@TonyAnima_Projects
@TonyAnima_Projects 3 жыл бұрын
Nice tutorial of menus in Unity3D. Now just a small question. I've been trying based on some FPS tutorials and I had the idea of making the color for the magazine / clip to change from white to red when it is less than 3 and to gray when it is zero. However, after I coded to the UIController script of my mini-game, it didn't loaded properly. using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIController : MonoBehaviour { public Font fontHUD; public PlayerBehaviour player; public static UIController instance; public AimUIBehaviour aimUI; // Start is called before the first frame update void Start() { instance = this; } // Update is called once per frame void Update() { } void OnGUI() { GUI.skin.font = fontHUD; GUI.contentColor = Color.white; GUI.Label(new Rect (Screen.width - 100, Screen.height - 85, 200, 80), player.weapons[0].currentAmountAmmo+" / "+player.weapons[0].currentAmountAmmoTotal); if (player.weapons[0].currentAmountAmmo > 3) { GUI.contentColor = Color.red; } } } Originally the currentAmountAmmo and currentAmountAmmoTotal were private classes and were picking up the information from ammoUsed and ammoTotal (public classes), but I had to change them to public while I was trying to test it. And I know I should share the other scripts in case you want to have some basic idea from what I was working on, but I'm still working at some intervals, which from one moment to another the scripts might be modified. In the future, do you plan to make a tutorial in how to code the text to change from one color to another by some conditions in Unity3D - like from white or other color when - for example: 30/30, yellow when 15/30, red when 3/30 and gray when 0/30? That will help for sure.
@IchigoFurryModder
@IchigoFurryModder 3 жыл бұрын
@@TonyAnima_Projects First of all, that's not quite how you do singletons, you need to check that instance is null before doing anthing, and it's good practice to do that stuff in Awake, like so: void Awake() { if (instance == null) instance = this; else Destroy(gameObject); //DontDestroyOnLoad(gameObject); // You usually do this with singleton components, like with an AppManager or GameManager class, but in your specific case I don't suppose you want that. } I'm guesing your problem is the label stays white? I'm pretty sure you're supposed to change the content color *before* rendering your element, try it like so: if (currNumber > 3) GUI.contentColor = Color.white; else if (currNumber == 0) GUI.contentColor = Color.grey; else GUI.contentColor = Color.red; GUI.Label(new Rect (Screen.width - 100, Screen.height - 85, 200, 80), $"{currNumber} / {maxNumber}"); But consider using the UI system.
@TonyAnima_Projects
@TonyAnima_Projects 3 жыл бұрын
@@IchigoFurryModder Thanks for the tips and indications, Ichigo. That will surely help. :D
@nocturne6320
@nocturne6320 3 жыл бұрын
A few tips for optimisation. If you're going to change the text often (like a score display) don't enable the font auto size, instead just set the size manually. If you don't actually need the extra effects like outline or shadow, leave them unchecked in the material settings. Also as others mentioned, use String.format, or the $ sign with {} in strings instead of + and just use "using TMPro;" at the top of your code. Or if you're working with a lot of text you want to concatenate each frame, use the StringBuilder class and store it in a variable at the top of your script, don't just do "new StringBuilder" each time in the update method.
@issacthompson330
@issacthompson330 3 жыл бұрын
The best part of TMPro is how much you can do with it with ease. TMP has a variable in its Info that tells how many characters of the text are visible so you can use an update function or a corutine to make it fill in the text as fast as you want.
@gnosisdarkmatter
@gnosisdarkmatter 3 жыл бұрын
I got distracted after I read this. 3:28 "This is a paragraph. It's like, the best paragraph ever -" "This is the second paragraph. It's like, the second best paragraph ever -" "This is the last paragraph. It's totally the worst paragraph ever -"
@apatsa_basiteni
@apatsa_basiteni 2 күн бұрын
Still Awesome some 3 years later. Thanks.
@ArkTheDuckh
@ArkTheDuckh 3 жыл бұрын
Oh nice. Congrats on 100K btw
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
Thank you -!
@Antonybae
@Antonybae 3 жыл бұрын
Nice tutorial! "Your score is: " + myScore uses concatenation which creates 3 new string variables in memory. for strings its better to write: $"Your score is: {myScore}" which uses interpolation and creates only one string variable). Its not a big optimization but using '+' operator is kinda bad practice(especially in enterprise)
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
My mind is Blown - Thank you for sharing this, I didn't know that was a thing, I will definitely try and get into the habit of using this instead!
@MikeKing710
@MikeKing710 3 жыл бұрын
Best exploration of what we have in Text Mesh!
@MarkChong
@MarkChong 3 жыл бұрын
This guy will save your time and NEVER WASTE IT
@WeeGification
@WeeGification 3 жыл бұрын
You mad lad, I've been avoiding TMPro because of not being able to use any Fonts, that font object conversion changed my life. I'd followed you for blender tips but I've been using unity for 2+ years so when you switched to intro unity tutorials I wasn't sure I get anything out of it, but here I am getting taken to school. Good stuff!
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
No problem man - I'm glad you got something new out of it, and thank you for sticking around for so long. If you've been here since Blender, you're probably a Legacy sub lol. It's good to see you guys in these vids :)
@WeeGification
@WeeGification 3 жыл бұрын
@@TheRoyalSkies Yeah man, some of the best tutorials on youtube, some of the only that don't waste your time. I heard you're gonna be making more advanced unity stuff soon, looking forward to it. Keep doing what you're doing man
@noirlavender6409
@noirlavender6409 3 жыл бұрын
Thank you man. Once I get out of poverty because of your wisdom and awesome tutorials I'll put your name and links on the credits
@paulorodriguez6288
@paulorodriguez6288 3 жыл бұрын
yes this is the quick info a beginner like me needs. thankyou
@CleisonRodriguesComposer
@CleisonRodriguesComposer 3 жыл бұрын
The best tutorial about Text-Mesh-Pro! Thank you!
@mynameisearlb
@mynameisearlb Ай бұрын
I just learned about TMPro and this was the video i needed, thanks!
@ColdOneK
@ColdOneK 3 жыл бұрын
For using Text Mesh Pro w/ script, you can add using TMPro; For creating font assets, I tend to add a bunch at a time, so I go Window/TextMeshPro/FontAssetCreator -- add your font - generate font atlas - then save -- you can then drag the created file to where you keep your fonts, so if you want to use that font in another project, you can simply drag both the font + the font atlas file into the new project.
@FlappyBandAid
@FlappyBandAid 3 жыл бұрын
Man THANK YOU! Worked like a charm!
@CreativeSteve69
@CreativeSteve69 3 жыл бұрын
I love coming back here for help as I"m making my first simplistic game. :D
@pixspaces4777
@pixspaces4777 3 жыл бұрын
Really helpful, I knew about using TMP for static text but using it for score system always gave me errors and bugs, thanks a lot for simplifying it! Also congratulations on 100k+sub!
@flicker_117
@flicker_117 3 жыл бұрын
AYYY...100K
@TheKnightDark
@TheKnightDark 3 жыл бұрын
As always great tutorial. Thanks!
@vellyxenya3970
@vellyxenya3970 3 жыл бұрын
Congrats on 100K!!!
@UnderfundedScientist
@UnderfundedScientist 3 жыл бұрын
keep up the great work
@Thesupperals
@Thesupperals 3 жыл бұрын
Yo. Don't forget to tell the script that you're using Unity's TMP library. This will help you access a all of things that TextMeshPro offers that you otherwise wouldn't be able to access.
@IchigoFurryModder
@IchigoFurryModder 3 жыл бұрын
And if you're using assembly definition files *as you probably should* don't forget you need to reference TMP in there
@animatrix1490
@animatrix1490 3 жыл бұрын
Thank you so much for making these
@kriegs8315
@kriegs8315 3 жыл бұрын
yes
@Hyphen3372
@Hyphen3372 3 жыл бұрын
thanks
@CrimsonGamer23
@CrimsonGamer23 3 жыл бұрын
Let’s say I’ve designed some number for score and I have them set up individually as a png. Can I use the png or set them up as fonts?
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
You can use the png if you want. If you have a png for each number you could have an array of each png, and set them to appear based on the number for the score -
@CrimsonGamer23
@CrimsonGamer23 3 жыл бұрын
@@TheRoyalSkies Thanks!
@Caden_Burleson
@Caden_Burleson Жыл бұрын
@3:35 Same 😂
@officialsquadrilogystudio
@officialsquadrilogystudio 3 жыл бұрын
Game coding reminds me a lot of algebra class
@kittentacticalwarfare1140
@kittentacticalwarfare1140 3 жыл бұрын
The Aliens are *AMOGUS*
@technofeeliak
@technofeeliak 3 жыл бұрын
You had 69 likes. Sorry to ruin your fun but I added one.
@TheRoyalSkies
@TheRoyalSkies 3 жыл бұрын
I legit almost chocked on my coffee reading this comment - Haha, It's OK to ruin my fun if it's for the good of the channel -!
@PlanetXtreme
@PlanetXtreme 3 жыл бұрын
ur funi
Unity 3D : Menus Part 3 (BUTTONS in 4 Minutes!!)
4:01
Royal Skies
Рет қаралды 6 М.
Controlling Sound In Unity - (In 5 Minutes!!)
5:25
Royal Skies
Рет қаралды 10 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Unity 3D : Menus Part 5 (Text Fields & USER-INPUT)
2:22
Royal Skies
Рет қаралды 3,1 М.
A new way to generate worlds (stitched WFC)
10:51
Watt
Рет қаралды 548 М.
Unity 3D : Menus Part 4 (Resolution-Based ADAPTIVE BUTTONS)
2:26
Royal Skies
Рет қаралды 2,9 М.
I Coded a Nuclear Physics Simulator to Play God in VR
44:21
Thomas Wald
Рет қаралды 47 М.
I Tried Re-creating Death Stranding Terrain Scan
18:46
Game Dev Buddies
Рет қаралды 102 М.
Unity 3D : Programming Flappy Bird Gameplay (In 4 Minutes!!)
4:08
Blazingly Fast Greedy Mesher - Voxel Engine Optimizations
23:35
Get started with UI Toolkit in Unity
12:29
Sasquatch B Studios
Рет қаралды 51 М.
1 Year of Learning Game Development In 6 Minutes
6:01
Giedzilla
Рет қаралды 2,6 МЛН
Indie-Dev Tries - IMAGE to 3D!
6:48
Royal Skies
Рет қаралды 9 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН