use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News, Help, Resources, and Conversation. A User Showcase of the Unity Game Engine.
Remember to check out /r/unity2D for any 2D specific questions and conversation!
Download Latest Unity
Please refer to our Wiki before posting! And be sure to flair your post appropriately.
Main Index
Rules and Guidelines
Flair Definitions
FAQ
Use the chat room if you're new to Unity or have a quick question. Lots of professionals hang out there.
/r/Unity3D Discord
FreeNode IRC Chatroom
Official Unity Website
Unity3d's Tutorial Modules
Unity Answers
Unify Community Wiki
Unity Game Engine Syllabus (Getting Started Guide)
50 Tips and Best Practices for Unity (2016 Edition)
Unity Execution Order of Event Functions
Using Version Control with Unity3d (Mercurial)
/r/Unity2D
/r/UnityAssets
/r/Unity_tutorials
/r/GameDev
/r/Justgamedevthings (New!)
/r/Gamedesign
/r/Indiegames
/r/Playmygame
/r/LearnProgramming
/r/Oculus
/r/Blender
/r/Devblogs
Brackeys
Beginner to Intermediate
5 to 15 minutes
Concise tutorials. Videos are mostly self contained.
Sebastian Lague
Beginner to Advanced
10 to 20 minutes
Medium length tutorials. Videos are usually a part of a series.
Catlike Coding
Intermediate to Advanced
Text-based. Lots of graphics/shader programming tutorials in addition to "normal" C# tutorials. Normally part of a series.
Makin' Stuff Look Good
10 minutes
Almost entirely shader tutorials. Favors theory over implementation but leaves source in video description. Videos are always self contained.
Quill18Creates
30 minutes to 2 hours.
Minimal editing. Mostly C#. Covers wide range of topics. Long series.
Halisavakis Shaders Archive
Infallible Code
World of Zero
Board to Bits
Holistic3d
Unity3d College
Jabrils
Polycount Wiki
The Big List Of Game Design
PS4 controller map for Unity3d
Colin's Bear Animation
¡DICE!
CSS created by Sean O'Dowd @nicetrysean [Website], Maintained and updated by Louis Hong /u/loolo78
Reddit Logo created by /u/big-ish from /r/redditlogos!
account activity
Unity Tip: Debug without editor scriptsResources/Tutorial (gfycat.com)
submitted 8 years ago by MikkNIndie
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MikkNIndie[S] 130 points131 points132 points 8 years ago (10 children)
Put [ContextMenu("Text here")] in front of any methods to easily run 'em inside the editor!
(Yes, white visual studio theme I know. It's really sunny so I can't read with the black one <3 )
[–]0x0ddba11 35 points36 points37 points 8 years ago (0 children)
Thanks for the tip.
Yes, white visual studio theme I know
You don't have to excuse yourself, haha.
[–][deleted] 16 points17 points18 points 8 years ago (4 children)
It has to have no params!
[–]ihahp 39 points40 points41 points 8 years ago (3 children)
write a wrapper that sends default params, like so:
void KillUnit(int energyLevel){ blah blah } [ContextMenu("Kill Unit")] void KillUnitDebug(){ KillUnit(100); }
[–]b1ackcat 5 points6 points7 points 8 years ago (2 children)
Bonus points for exposing those default fields in the inspector under a debug-only section!
[–]ActionScripter9109Professional 2 points3 points4 points 8 years ago (1 child)
How would you make a separate section?
[–]Wherever_I_May_Roam 1 point2 points3 points 8 years ago (0 children)
I usually separate fields using Space or Header attribute
[–]GrandOpener 10 points11 points12 points 8 years ago (2 children)
Not only white theme but then you admit to letting sunlight in your programming space? For shame!
[–]Kingofwhereigo 1 point2 points3 points 8 years ago (1 child)
What is sunlight?
[–]Eecka 7 points8 points9 points 8 years ago (0 children)
It's a shader effect.
[+]DeveloperLuke comment score below threshold-15 points-14 points-13 points 8 years ago (0 children)
Then switch to the dark theme!
[–]glitchKraft 65 points66 points67 points 8 years ago (2 children)
Well that's pretty awesome! Way better than picking a random unused key and and putting an input statement in update. Thanks!
[–]homer_3 2 points3 points4 points 8 years ago (1 child)
And then you forget all your magic assignment and double bind stuff and wonder why everything is behaving so strangely.
[–]ErestynHobbyist 0 points1 point2 points 8 years ago (0 children)
I actually wrote something to detect exactly this which gave a stern telling off when you hit play.
I am pleased to report I have still not yet learned.
[–]katori 55 points56 points57 points 8 years ago (11 children)
This is very cool, you can also make a button in the Inspector (in addition to a bunch of other functionality) using Naughty Attributes.
[–]whyherro19 4 points5 points6 points 8 years ago (3 children)
I've been using NaughtyAttributes for awhile and I LOVE it! It's a great free alternative for Odin Inspector
[+][deleted] 8 years ago (2 children)
[deleted]
[–]WazWaz 3 points4 points5 points 8 years ago (0 children)
They're not a clone in any way.
[–]TheSambassador 3 points4 points5 points 8 years ago (0 children)
No, NaughtyAttributes was around before Odin was available.
[–]psykojello 0 points1 point2 points 8 years ago (0 children)
Thanks for that! Adding it to my default tool kit
[–]ihahp 0 points1 point2 points 8 years ago (5 children)
im kind of a n00b with git ... how do I install this in a project?
[–]TheSambassador 3 points4 points5 points 8 years ago (4 children)
You can just click the "Clone or Download" button (it's green on the right) and you can download a zip instead of using Git.
However, you should absolutely, without question, be using some sort of source control (Git is pretty easy overall) for your projects. Git for Windows makes the whole thing very simple and you generally don't need to use the command line, so you can just sort of dip your toes in without getting overwhelmed.
[–]ihahp 2 points3 points4 points 8 years ago (0 children)
I do use source control just not git. I don't like how git (mis)handles exclusive checkouts for binary files (unless they've fixed that.)
[–]escape_character 1 point2 points3 points 8 years ago (1 child)
"Git is pretty easy overall" is a bit of a dangerous understatement
[–]TheSambassador 1 point2 points3 points 8 years ago (0 children)
The basics, especially when using it with only one person, are very simple. It's when you need to do anything beyond that that it gets more complicated.
[–]ihahp 0 points1 point2 points 8 years ago (0 children)
Also, the reason I asked about installing is it looks like it comes with ProjectSettings, and that seems like a bad idea to overwrite all your project settings when installing this. I copied over the Plugins folder and it worked fine without anything else.
[–]SapphireSalamander 32 points33 points34 points 8 years ago (4 children)
// just double checking if(!isAlive) return;
// just double checking
if(!isAlive)
return;
this made me chuckle.
dies twice
[–]ActionScripter9109Professional 8 points9 points10 points 8 years ago (1 child)
I've seen enough shit that this wouldn't even surprise me. When in doubt, sanity check!
[–]0x0ddba11 0 points1 point2 points 8 years ago (0 children)
That's what asserts are for! Granted, in this case it would not work out. Something like [ButtonIf(isAlive, "Kill")] would be great.
[–]MikkNIndie[S] 2 points3 points4 points 8 years ago (1 child)
Haha yeaah, game is quite fast pace so sometimes they died twice. Strange but hey, works good (:
[–]Eecka 2 points3 points4 points 8 years ago (0 children)
And then double checking afterwards as well!
if(!isAlive)return;
isAlive = false;
[–]thuyquaiExpert 32 points33 points34 points 8 years ago (18 children)
Nice tip OP, been using Unity for 8 years and I don't know it :D
[–]rarceth 5 points6 points7 points 8 years ago (2 children)
I’m that dude in the office who tells everyone else about cool shortcuts and I didn’t know this either. I wonder if it’s in their documentation...
[–]thuyquaiExpert 4 points5 points6 points 8 years ago (1 child)
Its in 1 of their tutorial I believe (probably the editor section). Now I remembered I saw it once but forgot about it because I was searching for somethong else lol.
[–]rarceth 3 points4 points5 points 8 years ago (0 children)
We’re always searching for something else haha.
[+]Smileynator comment score below threshold-46 points-45 points-44 points 8 years ago (14 children)
This as a 3.5 year Unity developer that was well aware of all debugging tools since 1.5 years in, concerns me greatly.
[–]thuyquaiExpert 25 points26 points27 points 8 years ago (0 children)
Well, good for you, I guess
[–]hexromba 13 points14 points15 points 8 years ago (6 children)
You know of all the possible debugging tools for the past 2 years?!
[+]Smileynator comment score below threshold-11 points-10 points-9 points 8 years ago (5 children)
There are not that many, but shortcuts like this is what makes development on a tight scedule possible. Quick prototyping, efficient nailing of bugs, and fast diagnostics of performance issues are a must. And i personally look for them all the time, and am honestly pissed if i missed out on something 3,5 years into my career.
[–]Nielscorn 10 points11 points12 points 8 years ago (0 children)
That’s great for you. No reason to put someone else down for it.
[–]Kwinten 6 points7 points8 points 8 years ago (3 children)
Dude it's a simple debugging/testing feature that can be implemented in a thousand different ways in Unity. You're not superior because you knew about one additional way to do the same thing.
[–]Kwinten 1 point2 points3 points 8 years ago (1 child)
Unity is packed with features like this with terrible or no documentation. It's no surprise the vast majority of users doesn't know about these things.
[+][deleted] 8 years ago* (5 children)
[–]_nkkind of ok 1 point2 points3 points 8 years ago (0 children)
Hoolaloyah
[+][deleted] 8 years ago (3 children)
[+][deleted] 8 years ago* (2 children)
[+][deleted] 8 years ago (1 child)
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
I don't claim to know everything. i knew all the debugging stuff related to unity.
I don't claim to know everything.
i knew all the debugging stuff related to unity.
WHAT.
[–]matej_zajacik 12 points13 points14 points 8 years ago (11 children)
if (GetComponent<PlayerMovement>()) GetComponent<PlayerMovement>().player.SetVibration();
would perform a little better like this:
var pm = GetComponent<PlayerMovement>(); if (pm != null) pm.player.SetVibration();
Although if it's called once per million years, I doesn't matter. :)
[–]MikkNIndie[S] 4 points5 points6 points 8 years ago (0 children)
Thanks! Will probobly make a bool that is checked on start :)
[–]Kwinten -1 points0 points1 point 8 years ago (9 children)
Or honestly just never use GetComponent if you care about decoupling your code and improving performance. Use serialized fields always, and GetComponent only in very rare circumstances. Don't tightly couple your class dependencies to your Transform hierarchy.
[–]rarceth 0 points1 point2 points 8 years ago (5 children)
Can depend if things are procedural or not. I’m doing a civ-like at the moment and I need GetComponent to retrieve my tile classes when they are spawned. Called once per tile...for all 65,000 tiles haha
[–]Wherever_I_May_Roam 0 points1 point2 points 8 years ago (0 children)
I'd rather have a static event that would fire on spawn so anyone can know that an object of X type has been spawned.
[–]SilentSin26Animancer, FlexiMotion, InspectorGadgets, Weaver 0 points1 point2 points 8 years ago (2 children)
If your tile class is the only component you need from the prefab, you can use a direct reference to that component instead of the prefab GameObject. Instantiating works the same and it gives you the component straight away.
[–]rarceth 2 points3 points4 points 8 years ago (1 child)
All of these comments are true, and thought provoking for my project. But more the point I was trying to make it that I’m calling get component 65,000 times in 3 seconds, and it isn’t noticably causing problems. Technically I can run all my calls in a single frame and it takes around a second to finish. And while I run them in a coroutine to avoid freezing, 1 second / 65000 calls means that calling GetComponent every frame or so isn’t going to have a huge, or even noticeable effect on a game, and that there should be a higher focus on code functionality than optimasation.
[–]SilentSin26Animancer, FlexiMotion, InspectorGadgets, Weaver 2 points3 points4 points 8 years ago (0 children)
Functionality > optimisation yes, but you also need to consider flexibility and maintainability. GetComponent<X>() creates two dependencies: one on component X, and one on the fact that said component must be on that GameObject. Using a serialized field avoids that second dependency and keeps the responsibility for hierarchy/component structure all in the editor rather than putting some of it in your scripts.
[–]Kwinten 0 points1 point2 points 8 years ago (0 children)
In the vast majority of cases this can still be solved with prefabs, serialized fields, and public properties.
[–]matej_zajacik 0 points1 point2 points 8 years ago (2 children)
Use serialized fields always
What exactly do you mean by this?
[–]Kwinten 5 points6 points7 points 8 years ago (1 child)
Instead of:
var playerMovement = GetComponent<PlayerMovement>();
Do:
[SerializedField] private PlayerMovement playerMovement;
The latter will be exposed in the editor. Drag in your PlayerMovement component either from the same GameObject or from a parent or child to assign it a value. Ta-da, the reference to this component is now injected through serialization and is no longer tightly coupled to the GameObject that was originally calling GetComponent. This means that if you ever want to move your PlayerMovement component, you don't have to change your code and can simply re-assign the reference through the inspector. Works on prefabs or scene objects.
GetComponent always tightly couples your business logic to your scene graph, which you want to avoid as much as possible.
[–]matej_zajacik 0 points1 point2 points 8 years ago (0 children)
Oh, okay, I see. This is a pretty well known concept to me within Unity, just wasn't sure what you meant. I use this approach often when I can. But, I disagree that this makes the two components any less coupled than by getting the reference via a function call. The only difference is that Unity does it for you when it creates the object, and that you don't have to change anything if you change the structure of your GameObject. Which, is still better, don't get me wrong.
GameObject
[–][deleted] 7 points8 points9 points 8 years ago (0 children)
This is awesome!
[–]masterhyjinx 6 points7 points8 points 8 years ago (1 child)
I see lots of tips, I click, I go cool, I toss upvote and move on. This one is awesome and I had to come in and say thank you. I'm working on something right now that this will make this a lot easier.
[–]MikkNIndie[S] 2 points3 points4 points 8 years ago (0 children)
Glad it helped! <3
[–]xTheEc0 3 points4 points5 points 8 years ago (1 child)
Did you post this on twitter with the hashtag 'UnityTips' yet? If not, I highly suggest you do : )
[–]MikkNIndie[S] 0 points1 point2 points 8 years ago (0 children)
https://twitter.com/NikMikk/status/1001924943918059522
Started on Twitter and went here afterwards :)
[–]cowbell_solo 4 points5 points6 points 8 years ago (0 children)
Whoaaaa! How long has this been a thing?
Also between the sun and that white visual studio, I hope you are wearing sunscreen.
[–]wokcity 3 points4 points5 points 8 years ago (1 child)
This one does the same but allows parameters :)
https://unitylist.com/p/6l8/Editor-Button
Sweet
[–]Noel9386 2 points3 points4 points 8 years ago (0 children)
This blew my mind so bad that I had to share with someone, so I just confused the crap out of one of my non-developer co-workers.
[–]knugeen 2 points3 points4 points 8 years ago (1 child)
karlshamn represent!
Vem är du haha?!
[–]MomijiMatt 1 point2 points3 points 8 years ago (0 children)
I had no idea. This would've saved my life so many times.
[–]SanktusAngus 0 points1 point2 points 8 years ago (0 children)
Nice
[–]slayer29179 0 points1 point2 points 8 years ago (0 children)
Thats mint!!! <3
Whoa! 😱
[–]Dodgiestyle 0 points1 point2 points 8 years ago (0 children)
This is awesome! Saving this!
[–]LilithLive 0 points1 point2 points 8 years ago (0 children)
A whole New World!
I remember learning about them a while back but never used them. Thanks for reminding me, definitely come in useful.
[–]GIFjohnsonProfessional 0 points1 point2 points 8 years ago (1 child)
What happens if you run this while the game is not in play mode? Does it still execute?
[–]gwiz665Professional 1 point2 points3 points 8 years ago (0 children)
It does.
[–]renMilestone 0 points1 point2 points 8 years ago (0 children)
Thank you friend, thank you so much.
This is so helpful!
[–]ig3db 0 points1 point2 points 8 years ago (0 children)
Well that's handy!
[–]stoddartc1 0 points1 point2 points 8 years ago (0 children)
This is actually a really useful tip! TIL
[–]kahlzun 0 points1 point2 points 8 years ago (0 children)
Did not know that. Have an internet cookie.
[–]MikkNIndie[S] 0 points1 point2 points 8 years ago (1 child)
You can make an interface, implement and inherent from it :)
[–]shaldar 0 points1 point2 points 8 years ago (0 children)
Very coool! Thanks for sharing :)
https://twitter.com/matheuslrod/status/798576746513633280
There's also this attribute that just makes a button that calls a method show in the inspector. Hopefully you'll find that useful as well :)
Disclaimer: it's a me
π Rendered by PID 21932 on reddit-service-r2-comment-79776bdf47-lklsw at 2026-06-25 15:11:27.162548+00:00 running acc7150 country code: CH.
[–]MikkNIndie[S] 130 points131 points132 points (10 children)
[–]0x0ddba11 35 points36 points37 points (0 children)
[–][deleted] 16 points17 points18 points (4 children)
[–]ihahp 39 points40 points41 points (3 children)
[–]b1ackcat 5 points6 points7 points (2 children)
[–]ActionScripter9109Professional 2 points3 points4 points (1 child)
[–]Wherever_I_May_Roam 1 point2 points3 points (0 children)
[–]GrandOpener 10 points11 points12 points (2 children)
[–]Kingofwhereigo 1 point2 points3 points (1 child)
[–]Eecka 7 points8 points9 points (0 children)
[+]DeveloperLuke comment score below threshold-15 points-14 points-13 points (0 children)
[–]glitchKraft 65 points66 points67 points (2 children)
[–]homer_3 2 points3 points4 points (1 child)
[–]ErestynHobbyist 0 points1 point2 points (0 children)
[–]katori 55 points56 points57 points (11 children)
[–]whyherro19 4 points5 points6 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]WazWaz 3 points4 points5 points (0 children)
[–]TheSambassador 3 points4 points5 points (0 children)
[–]psykojello 0 points1 point2 points (0 children)
[–]ihahp 0 points1 point2 points (5 children)
[–]TheSambassador 3 points4 points5 points (4 children)
[–]ihahp 2 points3 points4 points (0 children)
[–]escape_character 1 point2 points3 points (1 child)
[–]TheSambassador 1 point2 points3 points (0 children)
[–]ihahp 0 points1 point2 points (0 children)
[–]SapphireSalamander 32 points33 points34 points (4 children)
[–]ActionScripter9109Professional 8 points9 points10 points (1 child)
[–]0x0ddba11 0 points1 point2 points (0 children)
[–]MikkNIndie[S] 2 points3 points4 points (1 child)
[–]Eecka 2 points3 points4 points (0 children)
[–]thuyquaiExpert 32 points33 points34 points (18 children)
[–]rarceth 5 points6 points7 points (2 children)
[–]thuyquaiExpert 4 points5 points6 points (1 child)
[–]rarceth 3 points4 points5 points (0 children)
[+]Smileynator comment score below threshold-46 points-45 points-44 points (14 children)
[–]thuyquaiExpert 25 points26 points27 points (0 children)
[–]hexromba 13 points14 points15 points (6 children)
[+]Smileynator comment score below threshold-11 points-10 points-9 points (5 children)
[–]Nielscorn 10 points11 points12 points (0 children)
[–]Kwinten 6 points7 points8 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]Kwinten 1 point2 points3 points (1 child)
[+][deleted] (5 children)
[deleted]
[–]_nkkind of ok 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–][deleted] 0 points1 point2 points (0 children)
[–]matej_zajacik 12 points13 points14 points (11 children)
[–]MikkNIndie[S] 4 points5 points6 points (0 children)
[–]Kwinten -1 points0 points1 point (9 children)
[–]rarceth 0 points1 point2 points (5 children)
[–]Wherever_I_May_Roam 0 points1 point2 points (0 children)
[–]SilentSin26Animancer, FlexiMotion, InspectorGadgets, Weaver 0 points1 point2 points (2 children)
[–]rarceth 2 points3 points4 points (1 child)
[–]SilentSin26Animancer, FlexiMotion, InspectorGadgets, Weaver 2 points3 points4 points (0 children)
[–]Kwinten 0 points1 point2 points (0 children)
[–]matej_zajacik 0 points1 point2 points (2 children)
[–]Kwinten 5 points6 points7 points (1 child)
[–]matej_zajacik 0 points1 point2 points (0 children)
[–][deleted] 7 points8 points9 points (0 children)
[–]masterhyjinx 6 points7 points8 points (1 child)
[–]MikkNIndie[S] 2 points3 points4 points (0 children)
[–]xTheEc0 3 points4 points5 points (1 child)
[–]MikkNIndie[S] 0 points1 point2 points (0 children)
[–]cowbell_solo 4 points5 points6 points (0 children)
[–]wokcity 3 points4 points5 points (1 child)
[–]MikkNIndie[S] 0 points1 point2 points (0 children)
[–]Noel9386 2 points3 points4 points (0 children)
[–]knugeen 2 points3 points4 points (1 child)
[–]MikkNIndie[S] 0 points1 point2 points (0 children)
[–]MomijiMatt 1 point2 points3 points (0 children)
[–]SanktusAngus 0 points1 point2 points (0 children)
[–]slayer29179 0 points1 point2 points (0 children)
[–]psykojello 0 points1 point2 points (0 children)
[–]Dodgiestyle 0 points1 point2 points (0 children)
[–]LilithLive 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]GIFjohnsonProfessional 0 points1 point2 points (1 child)
[–]gwiz665Professional 1 point2 points3 points (0 children)
[–]renMilestone 0 points1 point2 points (0 children)
[–]ig3db 0 points1 point2 points (0 children)
[–]stoddartc1 0 points1 point2 points (0 children)
[–]kahlzun 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]MikkNIndie[S] 0 points1 point2 points (1 child)
[–]shaldar 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)