11 Things You (Probably) Didn't Know You Could Do In Unity

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 17. 07. 2024
  • Sign up to Milanote for free with no time limit: milanote.com/gamedevguide0422
    Let's take a look at some not-so commonly known things that you can do in Unity and C#. Hopefully there's something useful in here, leave your own tips in the comments section below! đŸ‘‡đŸ»
    Chapters:
    00:00 - Intro
    01:05 - Sponsor
    02:11 - 01 - Start As A Coroutine
    02:45 - 02 - Find And Customize Shortcuts
    03:30 - 03 - Temporary Backup Files
    04:27 - 04 - Locking and Duplicating The Inspector
    05:11 - 05 - Reveal Serialized Property Names
    05:58 - 06 - Swap Inherited Components in Debug Mode
    07:00 - 07 - Polymorphic Lists
    08:07 - 08 - Get Icons from Unity Objects
    09:33 - 09 - Embedded Scriptable Object Editing
    10:42 - 10 - Modal Editor Windows
    11:34 - 11 - The [MovedFrom] Attribute
    12:42 - Bonus Tip - Auto-Fix Imports in VS
    13:06 - Outro
    References:
    Icons - github.com/halak/unity-editor...
    Scriptable Object Editing - forum.unity.com/threads/edito...
    --------------------------------------------------------------------------------
    Want to support the channel?
    ▶ Help fund new episodes by joining the Patreon - / gamedevguide
    💡 Get One-Month Free of Skillshare Premium - skl.sh/MKR826
    Use these links to grab some cool assets from the asset store:
    Get the Must Have Assets! - assetstore.unity.com/top-asse...
    Free Unity Assets! - assetstore.unity.com/top-asse...
    New on the Asset Store! - assetstore.unity.com/top-asse...
    Top Paid Asset Store Packages - assetstore.unity.com/top-asse...
    Asset Store Partners - assetstore.unity.com/lists/as...
    --------------------------------------------------------------------------------
    Socials and Other Stuff:
    ‱ Subscribe - czcams.com/users/gamedevguide?...
    ‱ Join the Discord - / discord
    ‱ Twitter - / gamedevguideyt
    ‱ Facebook - / gamedevguideyt
    ‱ Instagram - / gamedevguideyt

Komentáƙe • 196

  • @tharsis
    @tharsis Pƙed 2 lety +69

    Another tip I like using. If you're a fan of auto properties to do something like:
    public float SomeValue { get; private set; }
    (For those that don't know, this means that anything in code can see this value, but only the class that owns the object can set it, kind of like a 'secure' field/variable.)
    Say you want this to be editor inspectable? Normally, you would instead have to add a private field alongside it that's marked as [Serializable], and the inspector deals with that field rather than the property. This also means you'd need to type out the property in its full form rather than the shorthand above, adding getters and setters that interact with that field, which can take a bit of time and be a bit ugly. Thankfully, C# supports a method of applying attributes to the hidden field auto properties create, and this can be done by adding 'field:' before the attribute name. For example:
    [field: Serializable] public float SomeValue { get; private set; }
    With that alone, your property now appears in the inspector, can be read by any code, but can only be set in the inspector or the owning class. This is handy for things like broadcasting an entities stats (HP, MaxHP, Strength, etc) and allowing those values to be seen and used by a UI and other objects, but only the inspector and the owning class can modify them (So if something wants to apply damage, it needs to still go through a 'DealDamage' method on the class rather than adjusting HP directly. It can still see the HP value though if it needs to act based on it, for AI or whatever).

    • @Eclipsed_Archon
      @Eclipsed_Archon Pƙed 2 lety

      that's really useful to me actually, this deserves to be in a follow-up video if we get one.

    • @Eclipsed_Archon
      @Eclipsed_Archon Pƙed 2 lety +2

      I got this working as:
      [field: SerializeField] public float SomeValue { get; private set; }
      Just in case anyone else happens across this. For some reason [field: Serializable] was throwing an error, but with [field: SerializeField] it's working perfectly.

    • @DodgyAussies
      @DodgyAussies Pƙed rokem +1

      This is actually the first time someone's mentioned the get:set properties with an actual use case

  • @marcusaasjensen
    @marcusaasjensen Pƙed 2 lety +238

    Quick tip: You can use equations inside textboxes of the transform inspector. For example, if I want to move my object from 125 to 135 on the x axis, I can type in the x axis "x+10" to move my object to 10 steps further.

    • @ulicesisaia4518
      @ulicesisaia4518 Pƙed 2 lety +8

      And this is also useful when you want to scale something without touching the "Scale" field on the Transform, you change the width and height multipliyng the values for the same factor and it will keep the aspect ratio: like "Height: 504 * 1.2/Width: 213 * 1.2"

    • @fongaming101
      @fongaming101 Pƙed 2 lety +3

      Same in #blender 😉

    • @arthurjvnb
      @arthurjvnb Pƙed 2 lety +6

      I think any field using a number support equations :D

    • @__dane__
      @__dane__ Pƙed 2 lety +2

      This is something I’ve always known since day one so it’s always interesting seeing people discover it

    • @Mempler
      @Mempler Pƙed rokem +1

      I use that one all the time. I learned it through blender lol

  • @Erveon
    @Erveon Pƙed 2 lety +63

    Polymorphic lists was something I had wanted for a while, didn't know it was actually possible, thank you! Took me a little bit of fiddling and Googling to get it to work for my use case but it works like a charm and makes things a lot cleaner than making new scriptable object instances every time I need a different variable

    • @bin9294
      @bin9294 Pƙed rokem +1

      Can you share your code to me? I really want this but this tutorial does not provide complet code to me.

    • @junaidywijaya
      @junaidywijaya Pƙed 11 měsĂ­ci

      The only problem for me is that the list doesn't specify which class the element belongs to, it just says element 0, element 1, and so on

  • @JasonStorey
    @JasonStorey Pƙed 2 lety +126

    I'll be honest, Normally these lists are things I already know... but I learned 2 things this time! There was also a couple of new things in the comments section too.
    Great video as always,
    It's always great when you learn new things about the tools you use daily.

    • @Ryan-ww7un
      @Ryan-ww7un Pƙed 2 lety +1

      Preserving polymorphism in lists using [SerializeReference] was especially eye-opening for me personally.

  • @neetosu2853
    @neetosu2853 Pƙed 2 lety +12

    this video is many years worth of editor scripting knowledge baked under 15 minutes
    what an absolute BANGER

  • @JudahMantell
    @JudahMantell Pƙed 2 lety +34

    At 5:00 and on, you show your Day/Night cycle script in the inspector. This looks super useful and I'd love a tutorial on it!

  • @ligofleyens9131
    @ligofleyens9131 Pƙed 2 lety +6

    Worst than not knowing some of the tools you did show here, is that I had already forgot those were still existing and could have helped me out.
    Thanks for the reminder!

  • @ChaineDeQualite
    @ChaineDeQualite Pƙed 2 lety +13

    Please do more of these.
    This is amazing.

  • @mrtruman4339
    @mrtruman4339 Pƙed rokem

    THANK YOU. I've been wanting to make polymorphic lists for so painfully long. I was praying for that to appear here. This will make things so much easier.

  • @Nialyah
    @Nialyah Pƙed 2 lety +4

    I'll be honest, atleast half of these I didn't know about. Haven't tackled much with GUI and custom inspectors but I really want to get into this some more, so thanks for this video. I'll try my hand at some of these :)

  • @notlaw1567
    @notlaw1567 Pƙed 2 lety

    These tips are really handful when it comes to developing. There were a few that I've found really useful and I didn't know about. Thanks for this video!

  • @elvismd
    @elvismd Pƙed 2 lety

    Amazing tips! Especially the one where we can get icons from the editor! It helped me a lot!

  • @richiebee33
    @richiebee33 Pƙed 11 měsĂ­ci

    Awesome video! Thanks for the tips 🎉

  • @javiermorin3110
    @javiermorin3110 Pƙed 2 lety

    Your videos are awesome. This one here is particularly helpful.

  • @joshbishop
    @joshbishop Pƙed 2 lety +1

    Holy cow, the [SerializeReference] attribute was literally something I needed for my tool I'm making right now. Thanks a million for this video my dude, it's been enlightening!

  • @ZeeKhar
    @ZeeKhar Pƙed 2 lety +4

    - In Transform we can enter equation for irrational numbers, ex (3^0.5)/2, we can also use the module operator like 5%2.
    - Surface snapping (Shift+Control) and Vertex snapping (V) are very useful to place object in the world.
    - We can rotate an object by previously selected vertex (with vertex snapping).
    - in Transform, when clicking on the letter X Y Z and drag left and right we can change the value.

  • @Eclipsed_Archon
    @Eclipsed_Archon Pƙed 2 lety +1

    Never knew about polymorphic lists! I need this often (more than I should) and this is kind of a game changer for me, so thank you.

  • @coderaven1107
    @coderaven1107 Pƙed 2 lety

    I only knew the one with the locked inspector tab, everything else was completely new to me :D Sick Video dude!

  • @mementomori7160
    @mementomori7160 Pƙed 2 lety +4

    Thank you for not using shorts format, they may be good for some things, but not for educational/informational videos, you can't fast forward, go back, etc etc(actually it's 2 2nd time I'm writing exactly this) and with programing and similar stuff, those functions are needed

  • @DevDunkStudio
    @DevDunkStudio Pƙed 2 lety

    Great one! Actually quite some things I did not know and will keep in mind when developing!

  • @user-xx8ws1qk3v
    @user-xx8ws1qk3v Pƙed 3 měsĂ­ci

    It's so cool! A lot of useful attributes and code hacks! I've been working at Unity for the last 5 years, but I didn't know much about it!

  • @TylerGreen
    @TylerGreen Pƙed 2 lety

    Some of these were some really nice tips!

  • @joaquinfraustoalfarorocco8177

    i just started doing a multiplayeer game and i just made a LateStart() coroutine everytime i needed something like that, but the start itself being a coroutine just makes it cleaner! i never could have thought of something like that its amazing! loved this video

  • @harshmudhar96
    @harshmudhar96 Pƙed 2 lety +2

    Half of these points are simply awesome. MovedFrom, Backup, Change inheritance of component.

  • @LautaroArino
    @LautaroArino Pƙed 2 lety

    Really good tips. Several that I didn't know that I will surely use. Thanks.

  • @thetra00
    @thetra00 Pƙed 2 lety

    very well made and thanks for these little helpers!

  • @RobinDoesUnity
    @RobinDoesUnity Pƙed rokem

    Thanks for this video, very informative!

  • @logiis6
    @logiis6 Pƙed 2 lety

    I am glad I didnt skip the add. I was looking for this exact thing :D

  • @venenifer3569
    @venenifer3569 Pƙed 2 lety

    2 Days ago I had to extend LayoutElement and Slider for some extra functionality and didn't know about Tip 6, wasted a lot of time copying and pasting values to the new components. Great video as always!

  • @user-gd2uw6tg2q
    @user-gd2uw6tg2q Pƙed měsĂ­cem

    thanks , after some years of programming in unity, you have just taught me new things

  • @NameUnknown-
    @NameUnknown- Pƙed 2 lety +3

    The polymorph list is really cool, also the expandable editor with a reference details

  • @personalgamedevyt9830
    @personalgamedevyt9830 Pƙed rokem

    The debug mode in the Unity is something I did not know about, and will use more.
    Thank you!

  • @Wolfos530
    @Wolfos530 Pƙed 2 lety +1

    I love that even after 12 years of using Unity, I can watch one of those videos and still learn something new.

  • @bischoffdev
    @bischoffdev Pƙed 2 lety

    The list serialization tips are really cool!

  • @darkman237
    @darkman237 Pƙed 2 lety

    Milanote is absolutely worth it!!! We've been using it for months.

  • @shankdixit
    @shankdixit Pƙed rokem

    Superb content..Thank you !

  • @alfonzo6320
    @alfonzo6320 Pƙed 3 měsĂ­ci

    that serialize reference keyword blew my mind. i had that exact issue in the past and couldn't figure out how to solve it!
    Thanks a lot !

  • @ofiryehudar12
    @ofiryehudar12 Pƙed 2 lety

    You are awsome! New and different tips!

  • @drottningu
    @drottningu Pƙed rokem

    You did a great job picking new tips! I only knew 3 of those.

  • @rafaaccr
    @rafaaccr Pƙed 2 lety

    Really, really, reeeeeaally useful
 as always :)

  • @Evert-JanN
    @Evert-JanN Pƙed 2 lety +4

    Yay! I made it into a GameDevGuide video :) at 2:58

    • @skydrag4227
      @skydrag4227 Pƙed 2 lety +2

      Same here ! Feeling proud right now.

  • @Mouton_redstone
    @Mouton_redstone Pƙed 2 lety

    very useful, thank you very much !

  • @ferdinandkasangati5089
    @ferdinandkasangati5089 Pƙed 2 lety

    thanks with milanote bro, really brilliant

  • @lemonade3532
    @lemonade3532 Pƙed rokem

    Very humbling video. I have much more to learn

  • @ArmanNobari
    @ArmanNobari Pƙed 2 lety

    Indie dev with 1 shipped title here, and the last tip about CTRL+. blew my mind. Had no idea. Thank you so much for making this compilation!

  • @adamodimattia
    @adamodimattia Pƙed 2 lety

    This video alone made me subscribe! Thanks

  • @LegoDinoMan
    @LegoDinoMan Pƙed rokem

    Locking and duplicating the inspector helped me out so much, thank you!

  • @kmud7750
    @kmud7750 Pƙed 2 lety

    More videos like this! Great video.

  • @LilayM
    @LilayM Pƙed 2 lety

    Nice! Had no idea about lots of these.

  • @GrahamOfLegend
    @GrahamOfLegend Pƙed 2 lety

    Omg omg omg, the embedded scriptable object editor is a GAME CHANGER!!!! This list is golden, thank you so much

  • @Kabeza00
    @Kabeza00 Pƙed rokem

    thanks for that valuable data!

  • @leonardo6631
    @leonardo6631 Pƙed 2 lety

    Great video!

  • @alexdacat
    @alexdacat Pƙed 2 lety

    Swapping inherited components in debug is super cool! Going to use that one forsure

  • @JayaTemara
    @JayaTemara Pƙed rokem

    Damn nice info, thanks mate

  • @majeric
    @majeric Pƙed 2 lety

    I didnt know the Editor icon ones. So Thanks!

  • @PanzerTF
    @PanzerTF Pƙed 2 lety +1

    Tip 6 is super useful, I wish I knew about this when extending my UI buttons.

  • @mattw_dev
    @mattw_dev Pƙed 2 lety

    Thank you Matt!

  • @Alzimovich2
    @Alzimovich2 Pƙed 2 lety

    Great uncommon tips, a new subscriber here

  • @ClipperRoad
    @ClipperRoad Pƙed 2 lety +1

    I want to be a game dev so badly, thank you for a great video - subbed and looking forward for more tips and guides in Unity and Blender, any recommendations for learning would be greatly appreciated 🙂 thank you

  • @nv7287
    @nv7287 Pƙed 2 lety

    finally the equivalent to blender secrets list Yay! Yes please make mooooooorrrre

  • @harrogance3404
    @harrogance3404 Pƙed rokem

    The component swapping holding inheritance is a lifesaver ❀

  • @nightmarexgr7252
    @nightmarexgr7252 Pƙed rokem

    Me randomly watching this one week ago thinkining there is nothing new i would learn... me today remembering about this one inheritance replace script thing and coming back to see how to do it, cheers

  • @ethancodes7134
    @ethancodes7134 Pƙed rokem

    I watch videos like this pretty frequently and they are always very disappointing. This one was a pleasant surprise! I've worked in Unity full time for 4 years and I didn't know any of these except the last one! Thanks for the useful tips!

  • @supercyclone8342
    @supercyclone8342 Pƙed 2 lety

    Extremely helpful! Just yesterday I set up a new enemy and then realized I needed to change it from my EnemyBase class to a child turret class, but I thought I needed to re-set up everything. I'm also pretty sure I ran into a situation where I could've just made Start a coroutine XD

  • @Tomatech
    @Tomatech Pƙed 2 lety +5

    For the ExposedScriptableObjectAttribute, there was a missed step about creating a dummy editor for all monobehaviors to fix a bug in unitys UI. The referenced thread in the description includes this step

  • @branidev
    @branidev Pƙed 2 lety

    such useful video thanks

  • @dimaformaniuk3710
    @dimaformaniuk3710 Pƙed 2 lety

    Nice video!

  • @Icewind007
    @Icewind007 Pƙed 2 lety

    This video is rich with new stuff for me! I want to remember it all!

  • @felfar197
    @felfar197 Pƙed 4 měsĂ­ci

    thank you!!!

  • @TedThomasTT
    @TedThomasTT Pƙed 2 lety

    Cool video 👍

  • @Tomatech
    @Tomatech Pƙed 2 lety

    There were a lot more things I didnt know than I expected, i might need to rewatch it again another day so that I dont forget

  • @Thomason1005
    @Thomason1005 Pƙed 2 lety

    uh, tips 6 and 7 are đŸ”„. that would have saved me quite some time in the past...

  • @xAjido
    @xAjido Pƙed 2 lety +2

    Jason Weimann did a similar video recently with many of the same tips, though this one had a couple extra which were nice.

  • @pandaengine
    @pandaengine Pƙed 2 lety

    Thank you for this! Now I can stop worrying about using inheritance because I may change the script in the future.

  • @DevilN94
    @DevilN94 Pƙed 2 lety +5

    You can hover over any window in the editor and press Shift + Space to maximize it, then press Shift + Space again to return the window to it's original state.
    I use this for the Game window instead of "Maximize on play" option, because when I pause the game the windows stays maximized

    • @richiebee33
      @richiebee33 Pƙed 11 měsĂ­ci

      Amazing tip, thanks 🙏

  • @workflowinmind
    @workflowinmind Pƙed 2 lety

    Very cool one, I would add the UnityCsReference as it's THE thing I keep referring to

  • @slash7076
    @slash7076 Pƙed 2 lety

    Amazing!)))))))

  • @darkModeYT
    @darkModeYT Pƙed 2 lety

    Preserve polymorphism!!! Oh my God! You are a legend!!! God blessed me when I subscribed to you! Thank you!! Thank you!!❀❀❀❀❀❀

  • @francescagreetham1804
    @francescagreetham1804 Pƙed 2 lety

    Double inspector windows!! Why didn’t I know this before. So useful

  • @afterEffects_0
    @afterEffects_0 Pƙed 2 lety

    thanks bro

  • @broganking9830
    @broganking9830 Pƙed 2 lety

    OMG number 6 blew my mind!

  • @awesomemike3857
    @awesomemike3857 Pƙed 2 lety

    I knew 6 of them and didn't know 6 of them
    So awesome video

  • @jarokgames
    @jarokgames Pƙed 2 lety

    Hey thanks for video. New subscriber here. I m very new in programming games, so every tip counts! Can i ask you, how to add that buttons to add elements into scriptable objects? thank you

  • @Cyberfoxxy
    @Cyberfoxxy Pƙed 2 lety

    that one with script swapping is pretty neat. Previously the way i solved this is by opening the scene in a text editor and swap out the script GUID.

  • @apubetico
    @apubetico Pƙed 2 lety

    i think i saw it in a video of yours but how you handle the hierarchy groups? because making everything child of a clean empty makes me use local cordinates and so..

  • @dhedarkhcustard
    @dhedarkhcustard Pƙed 8 měsĂ­ci

    I've been using unity for about 5 years and I'm so annoyed with this video, only because I would have prevented so much stress and frustration if I knew these. And I mean, ALL of these I didn't know, and I'm really good at googling. Thank you so much for this.

  • @Foodkiller17
    @Foodkiller17 Pƙed 2 lety

    Wow thanks

  • @waflicek
    @waflicek Pƙed 2 lety

    Hello, where could I find that documentation in 2:14 ? Can't find it. Great video!

  • @DagothDaddy
    @DagothDaddy Pƙed 2 lety

    Are there any resources to help make a tactical pause menu. Something like Mass effect on PCs pause and issue commands UI in unity?

  • @bike_n_fish
    @bike_n_fish Pƙed 2 lety

    Until the 7th I was like "Is that even tips ? Everybody know that" and then you drop da bomb - Thanks for thoses they're pretty usefull

  • @MaharbaRacsoChannel
    @MaharbaRacsoChannel Pƙed 2 lety +1

    The Properties... menu item it's also available for assets in the project view, for GameObjects in the hierarchy, and for any object assigned in an object field. With this, I never need to lock an inspector anymore. I also prefer this to embedding an editor inside another: I just right-click in an object field and select Properties..., It takes a lot less space.

  • @SilverAura
    @SilverAura Pƙed 2 lety

    Not sure if Unity fixed this or not but your tip on duplicating the inspector is one I found was incredibly useful... till I discovered it was the reason my editor kept crashing. You're better off sticking strictly with the "Properties" method.

  • @chocholatebunny
    @chocholatebunny Pƙed 2 lety

    Hey GDG, TaroDev here on CZcams has a great autosave script for the editor that you just drag and drop into your editor!

  • @yudanaim6849
    @yudanaim6849 Pƙed rokem

    Awesome

  • @MuftahDev
    @MuftahDev Pƙed 2 lety

    one quick tip: by hover over any method or variable and click CTRL + Left mouse button, you can access where this method was written even if it's from another class

  • @batnikelam-mavzer443
    @batnikelam-mavzer443 Pƙed 2 lety

    thx

  • @ChadGatling
    @ChadGatling Pƙed 11 měsĂ­ci

    The shortcuts were causing problems in play mode when I was trying to use control + number to assign unit control groups. I had to rebind those shortcuts and it saved me a lot of annoyance.

  • @DavidVille
    @DavidVille Pƙed 2 lety

    Implementing auto save correctly is a lot more complicated than just a checker.
    For example I often work with multiple scenes open, and One of them is my "working now scene" that I do want to be saved, but the other ones, I may or may not make changes to them temporally, that I do not want to be saved (mostly because other people is working on them on source control)
    Auto save would have to be enabled "per scene", that would work.

  • @HAWXLEADER
    @HAWXLEADER Pƙed 2 lety

    Regarding 11, The Moved From...
    Can I remove that attribute after Unity compiles and finds everything?
    What If I want to do another Move?

  • @R3zShark
    @R3zShark Pƙed 2 lety

    Ctrl+Period?
    12:42 Never heard of doing that but I always use the "Show potential Fixes" option whenever I hover my mouse over the code.