Комментарии:
Loved that last tip!!!
ОтветитьThanks for the tips! :)
Ответить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.
Careful with the '?' operator. That bypasses the lifetime check on monobehaviors. You should actually get a warning for that either in VS or Unity
ОтветитьProperties in Component without Locking Inspector really going to help me out
ОтветитьNice tips, thanks!
Ответить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!
Ответить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
ОтветитьThank you. This is a great time saver!
ОтветитьThose were some solid tips, noted! thank you!
ОтветитьI watched in 2X speed, so I learned 20 new tips!
ОтветитьSuper useful stuff, cheers!
Ответить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.
Ответить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)
Ответить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.
MORE
Ответить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!
ОтветитьThanks For Sharing
Ответить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 :)
Did you know that there is [-] thing on the left when you create a summary?
You can click it to simply wrap the summary.
Empty at Origin and Properties for Array
Ответить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!
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.
its a shame that I don't know everything. thanks btw
ОтветитьHe doesnt stop !! Great vid yet again
ОтветитьSuper useful video for me, thanks for making it. In the future, I would like to see more content like this.
Ответить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?
Ответить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
Ответить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.
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.
ОтветитьThanks for the last tip, I literally said "mother******" out loud after seeing that lol
Ответить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.
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.
Great tips! actually very valuable and can save some time
ОтветитьI really liked you tip #8, it was completely new to me. Thanks.
Ответить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.
Ответить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.
ОтветитьVery Useful, thanks for sharing!
Ответить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
Ответить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!
Why not use public for all variables when you are solo dev?
ОтветитьThese tips are ALL very useful! Thanks a lot!
Ответить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