Use these 5 amazing Visual Studio tips to help speed up your dev time INSTANTLY!
How would you like to INSTANTLY save more time and energy coding your games? Over the years I've learned many fun tips and tricks that have helped me to speed through things in Visual Studio. I share with you some of those tricks that have helped me plow through MASSIVE code...I'm talking 100k+ lines of code with massive amounts of scripts. These are just some of the many useful tips and tricks I've learned over the years but figured I'd write some of them down here in this post. May these tips and tricks serve you well in your own coding endeavors as you build the next hit game in Unity!
Such a neat little trick, I love this one a lot! Basically ANYWHERE you write the word TODO with a colon in comment format, Visual Studio has an internal tool JUST to find these all within your code instantly!
Here is how you do it:
a. Anywhere you want to leave an item that you know you need to do or a note to remember something simply type in the following:
// TODO: [Place Your Todo Item Here]
b. Now inside of Visual Studio simply click on (View => Next Task) and you'll be able to see all your To Do items and even cycle through them!
NOTE: One issue you do need to keep in mind is that YOU are not the only one who will be using this trick. Other assets (Other developers whose assets you may purchase and download) also use this technique so in some cases you may end up seeing their TODO items as well. Simply remove those if you want to or skip over them, but keep that in mind when you are using assets that other devs have made.
2. Fast Refactoring
There are so many times where we have code that is repeated over and over again. To reduce the amount of lines and to keep code clean we want to put those into functions. However sometimes just trying to write those functions can take a bit of time.
One neat trick to help out in refactoring these blocks of code comes directly within visual studio! Here is how it works:
a. Select the code block you want to make into a function and then right click on it and select "Quick Actions and Refactoring" (You may also use keyboard shortcut CTRL + . )
b. Next select "Extract Method"
c. At this point Visual Studio will create a new function with the highlighted code. Now simply type in a function name and your new function will be ready to be used and reused anytime you want! HOW COOL IS THAT?
3. Jump to Definition (F12)
Have you ever been writing code and then forgot where something was defined? This happens a lot and sometimes you're just trying to figure out where something was created in the first place.
To solve this, Visual Studio has a simple keyboard shortcut to instantly go to a definition of any item. Simply Select the item and then hit the F12 key! It's that simple and really REALLY helpful!
4. Attach to Unity with Breakpoints
This one is really helpful in debugging. Basically you simply click on the side of ANY line of code to place a break point. You then select Attach to Unity at the top and then run your game in Unity.
The second the break point comes up, you will see it all inside of Visual Studio! It's a great way to do some serious debugging within Visual Studio itself while having Unity open. It's also a great way to NOT have to add any additional lines of code to your app/game and still get outputs. This is a preferred method of debugging because of this reason.
Step by Step:
a. Click on the side (It is a LIGHT grey vertical bar) with your mouse to get a RED break point on the specific line you want.
b. Click on 'Attach to Unity' at the top
c. Hit the PLAY button inside of Unity
d. Finally, you should see your break point show up if everything went right and Visual Studio will halt your app/game and show you the information ready for you to debug (The best part is there is NO CODE CHANGES REQUIRED!!!)
e. Hit the STOP button at the top of Visual Studio (It's the RED SQUARE) to stop the break point debugging so you can continue coding!!!
5. Alt + Up; Alt + Down
This one is a fun one, you simply go to any line of code and you can instantly move the ENTIRE line of code using Alt + Up on your keyboard and Alt + Down on your keyboard. It can save you some time for sure in moving around in your code. Give a try and see how useful it can be!
So there ya go, enjoy those tips and tricks as you code your next hit game using Visual Studio and C#. Though some of these tips may have been simple they have been quite helpful for me and have saved me some serious time! ENJOY!
Now go make some awesome games! You are a super star! Keep up the great work and NEVER GIVE UP! You Got This!! BE A CHAMPION!
Nav is a Unity Live Expert and Mobile Game and App Developer
MY BLOG => http://www.AcademyOfGames.com
"I'm a game dev making fun awesome RPG and Fantasy Games. Check out my games on Steam and all major mobile platforms today => Game Scorpion Inc.!"