Unity Code Examples, Snippets, Quick Codes, References, Tutorials

When using unity I found myself in need of lot of common codes, unity code examples etc. Hence decided to dedicate a page to things I found helpful scattered across the web to a single page. This page is for myself and ones who run into similar problems. Enjoy this Unity Code Examples and snippets.


Unity Code Snippets for MonoDevelop / VSCode / Visual Studio – [Get it Here]
For MonoDevelop Download the Unity.template.xml and create a folder called Snippets inside the C:\Users{your_pc_name_here}\AppData\Roaming\MonoDevelop-Unity-5.0 (or in Windows Press Win+R -> %appdata%) and Copy this file to that folder. On Restarting Monodevelop, the code snippets will be working.

Unity Canvas UI

Unity Canvas Fading / Fader Script for fading Canvas UI – [Get it Here]

Small And Useful Unity Code Snippets

Shuffle Array in Unity (source)

MonoDevelop Create Method / import package / Getter Setter code generate

You can just write a function like, addTwoNumbers(a,b); and keep your cursor over addTwoNumbers and press alt+Enter. It will show a menu with create method. Move the line to where the function definition would be. It’ll be generated. Also if you need to import a package (if you’re using Image you need to add using UnityEngine.UI) just place cursor over Image and press alt+enter. Similar for setter and getter for private variables.


154 Total Views 6 Views Today