10 Unity Tips You (Probably) Didn't Know About

10 Unity Tips You (Probably) Didn't Know About

Sasquatch B Studios

1 год назад

34,686 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Nathan Coleman
Nathan Coleman - 22.09.2023 02:14

Loved that last tip!!!

Ответить
Péter N.
Péter N. - 04.09.2023 13:45

Thanks for the tips! :)

Ответить
ZOM
ZOM - 22.08.2023 05:22

Double hit ctrl R in your code on a variable to rename it. The new variable name is applied to everwhere this variable exists. Anywhere in your project. Any script.

But ignores variables that happen to have the same name but are declared in a different class.

Ответить
Lint and Buttons
Lint and Buttons - 17.08.2023 22:59

Careful with the '?' operator. That bypasses the lifetime check on monobehaviors. You should actually get a warning for that either in VS or Unity

Ответить
Bylem
Bylem - 16.08.2023 16:59

Properties in Component without Locking Inspector really going to help me out

Ответить
Professor Farnsworth
Professor Farnsworth - 15.08.2023 01:29

Nice tips, thanks!

Ответить
Owen Hey
Owen Hey - 13.08.2023 22:51

Favorite one, surprisingly, was creating objects at the world origin. I hate empty game managers at some random 4.2434, 234.2, 123.1 position!

Ответить
Shibe
Shibe - 02.08.2023 00:28

you can declare a bunch of variables of similar types in one line by using a comma, like «float one, two, three, four» and you can even serialize it by putting [SerializeField] in front of it, which is very helpful for quick testing. You can also order variables in groups by using the [Header(«name»)] syntax so they are easier to read in the inspector

Ответить
K Ahmed
K Ahmed - 30.07.2023 17:17

Thank you. This is a great time saver!

Ответить
Just Wes
Just Wes - 29.07.2023 19:31

Those were some solid tips, noted! thank you!

Ответить
Vaqquixx8
Vaqquixx8 - 26.07.2023 11:52

I watched in 2X speed, so I learned 20 new tips!

Ответить
Pertti Hakala
Pertti Hakala - 14.07.2023 01:07

Super useful stuff, cheers!

Ответить
Marcus79
Marcus79 - 12.07.2023 12:31

I have a tip too if anyone finds it useful. I recently discovered you can organize your tags by adding a slash so it makes a dropdown menu. For instance I use it to categorize footstep audio in my game. Like you make a tag called "Footsteps/Wood" or "Footsteps/Metal" and in your tag list you see a dropdown menu that you can select from. Of course you can customize your tag list to whatever you want.

Ответить
Attila Steigervald
Attila Steigervald - 11.07.2023 14:23

an extra tip for the XML Tag (Comment) Documentation. Visual Studio 2022 can hide the comment section out of the box (without region or anything)

Ответить
elsporko321
elsporko321 - 08.07.2023 19:44

I have two tips that newer devs may find useful:

Tip #1: Add color tinting to Unity when in Play mode so you have a visual indicator whether you're in edit/play mode. Helps to avoid losing changes if you overlooked the fact you are still in play mode (changes aren't saved in runtime...for the most part). Preferences -> Colors -> "Playmode tint" and change it to something that pops (I use green)

Tip #2: Instead of moving your mouse all the way to the edge of the screen to disable/enable gameobjects using the checkbox, you can bind it to something like the tilde key for quick access. Edit -> Shortcuts -> look for "Toggle Active State" and change it to whatever works best for you.

Ответить
Gin Ra
Gin Ra - 04.07.2023 15:58

MORE

Ответить
ethancodes
ethancodes - 03.07.2023 15:17

I come into almost every single "Unity tips" video extremely skeptical because rarely is there something useful and not already common knowledge. This video though was filled with stuff I didn't know! Great work!

Ответить
Sufian Ahmad
Sufian Ahmad - 03.07.2023 06:58

Thanks For Sharing

Ответить
Tom Tomkowski
Tom Tomkowski - 02.07.2023 22:35

I would add one more I'm always using when prototyping or testing, etc
Go to Project Settings -> Editor -> Enter Play Mode Options and uncheck Reload Domain
Thanks to this your scene will start in milliseconds after you press the Play button :)

Ответить
LC Studios MC
LC Studios MC - 01.07.2023 04:53

Did you know that there is [-] thing on the left when you create a summary?
You can click it to simply wrap the summary.

Ответить
Waleed
Waleed - 28.06.2023 01:18

Empty at Origin and Properties for Array

Ответить
WurstOnAir
WurstOnAir - 26.06.2023 10:09

There are some extremely helpful tips I actually didn't know!
BUT!!!
Tip 9 might be a dangerous one since for Unity this tip is just partially true!

When you use the ? operator you are checking if the value is actually null. But Unity is handling object destruction differently. The references to the object will not get null. Therefore the ? operator will let the function be called. The == operator on the other hand is overloaded and will check this behaviour!

Ответить
ProrokLebioda
ProrokLebioda - 24.06.2023 14:08

Useful tips! Some of them are general programming/IDE tips, but useful nonetheless. One about extended ColorPicker is a really good one.
I'm currently working on a turnbased game on hexgrid. I've tried following an A* tutorial (regular square grid), but it's not going great. Learned from my mistake I'd advise to: create debugging only code(meaning not for released game) that shows all the background calculations in game world. That saved me a lot of headaches.

Ответить
Gakebagiannama
Gakebagiannama - 22.06.2023 17:58

its a shame that I don't know everything. thanks btw

Ответить
Mason Crowe
Mason Crowe - 21.06.2023 08:35

He doesnt stop !! Great vid yet again

Ответить
Trex B
Trex B - 20.06.2023 21:11

Super useful video for me, thanks for making it. In the future, I would like to see more content like this.

Ответить
TorchWind Games
TorchWind Games - 20.06.2023 09:54

the problem with [fiel: seriaized... is that if you already have a public variable you've used a whole bunch and want to make it private get; while keeping it in the inspector you are going to have to fill all the values again in all the prefabs and objects you had. hope you got source control, otherwise you are going to have to balance the game again. that being said, its great. Anyone know a solution for this?

Ответить
gareths
gareths - 18.06.2023 03:53

I love the fact you can make public properties appear in the inspector, the only catch is that (at least as far as I'm aware) you can't edit the look of them in your editor scripts as FindProperty and FindPropertyRelative will just return null. This may have changed, but idk

Ответить
322ss
322ss - 17.06.2023 19:17

Thanks! Here are some more / not sure how much "didn't know" category these are though.
1. You can do basic math operations in Inspector fields (+,-,*, /)
2. To remove Unity Objects from Inspector fields, click the field then press backspace. No need to browse that "None" from list.
3. Maybe quite obvious, but when in editor, you can show debug draw stuff in game view, if you press that "Gizmos" button in top right corner of the Game view window.
4. Don't like the fact that viewport selection always opens the object hierarchy? There is a lock in Hierarchy window top right corner which prevents this.
5. You can alt left mouse click to completely open deep hierarchies in Hierarchy window.
6. Using [ContextMenu] Attribute on a method is a easy way to allow calling methods to run editor code, without custom editors. Simply open you MonoBehaviour's Inspector component menu and your method will appear there.

Ответить
SpartanFanDMD
SpartanFanDMD - 17.06.2023 17:09

I had no idea about the property popout window, that will be a big time saver. I use the coroutine start function now and again but as another tip, you can also make those methods virtual and override them in child classes.

Ответить
YoItsMerlin
YoItsMerlin - 17.06.2023 09:03

Thanks for the last tip, I literally said "mother******" out loud after seeing that lol

Ответить
Steve Williams
Steve Williams - 17.06.2023 07:46

Useful tip that uses debug mode in the Inspector. If you want to change the script a component uses but not lose the property values, switch the Inspector to debug mode and drag the new script into the Script field.
You can use equations in numeric fields in the Inspector. For example, if you want to add 53.4 to the existing value of 67.8, add "+53.4" to the end of the existing value and press Enter. Unity will evaluate the equation and assign the result to the field.

Ответить
Steve Williams
Steve Williams - 17.06.2023 07:33

Do NOT use the ?. or ?? or ??= operators with Unity objects or component references. The Unity integration with Visual Studio even warns against this. Unity overrides the ==, != operators and the Equals method to support the C++ native object being destroyed before the C# wrapper is destroyed, but the null propagation and coalescing operators are at the compiler level and therefore have no knowledge of the C++ native object being destroyed first. So you may still end up calling a method or property on a C# object that has had the C++ native part already destroyed. That is bad.
If you want to save a few characters, just drop the "== null" in the if condition. Unity also overrides the bool operator to return true if the object is still valid but not necessarily null.

Ответить
Matan Naveh
Matan Naveh - 17.06.2023 01:09

Great tips! actually very valuable and can save some time

Ответить
Riddhesh Zaveri
Riddhesh Zaveri - 16.06.2023 23:53

I really liked you tip #8, it was completely new to me. Thanks.

Ответить
zORg alex
zORg alex - 16.06.2023 23:41

What about extensions for stupid things, like image.SetSprite(Sprite sprite) that will check if (image) exists before signing. Same with TMP_Text. SetText(string text). Or simplify Mathf usage by extending float with some of its methods, like Abs, so someFloatValue.Abs() is way more readable and easier to type.

Ответить
CoffeeCaveman
CoffeeCaveman - 16.06.2023 19:11

Or maybe what would be useful (which is beyond my current ability) would be to have all your descriptions within their own file, and have them assigned to functions in other scripts.

Ответить
Chris Diplock
Chris Diplock - 16.06.2023 16:31

Very Useful, thanks for sharing!

Ответить
RogerFK
RogerFK - 16.06.2023 15:56

Another Unity tip is you can ask for a publisher and fund your game. Actually, that's not an Unity tip, is a tip for you. Good video as always, btw

Ответить
Keith Hirst
Keith Hirst - 16.06.2023 15:13

This was a fun video.

Fun fact! I ONLY knew about serialising properties! All the tutorials I followed used it, so this was kind of a reverse tip haha!

Ответить
Patryk
Patryk - 16.06.2023 14:11

Why not use public for all variables when you are solo dev?

Ответить
Cherry Chou
Cherry Chou - 16.06.2023 13:52

These tips are ALL very useful! Thanks a lot!

Ответить
saftmeister rüffel
saftmeister rüffel - 16.06.2023 13:50

WOOOO this SHIFT-ALT dual/triple/quadro writing is INSANE. I am using visual studio for 15 years now and i never knew this xD
Thanks man, also the other stuff is exciting to me <3

Ответить