- Home /
how to reuse the code in monodevelop
I have some pieces of code and i want to store it , so that, i can easily use it later.
Save the scripts in a folder? Or you can make a git repository that keeps all your little scripts.
Across different projects or the same project?
If you're using C# and want to reuse bits within the same project, then Namespaces might be what you're looking for.
If you're using C# and want to use code across different projects, you could either write a DLL for yourself or make a Unity asset for use across your projects.
Answer by UnityCoach · Jul 28, 2017 at 06:17 PM
You can create Code Templates. Preferences > Text Editor > Code Templates.
Templates are extremely powerful. You can add variables, using $variablename$ so that is get replaced everywhere when you use the template.
You also add a shortcut to use the template quickly. Example :
public $type$ $name$ {get; set;}
thanks , UnityCoach
your solution is really helpful for me.
Answer by megabrobro · Jul 27, 2017 at 03:24 PM
I'm not sure I understand the question, its seems too simple. The code is basically a text file and you could go as simple as copy-pasting the code block you need into notepad to save it.
You could of course, save a copy of the script .cs file into any folder you want (eg. your desktop; or C:/MyDocuments/MyScripts/ and just drag it in to each project you want in unity.
I often do paste some code straight into Notepad++ . Its a free app that has some of the features of an IDE , and loads really fast and stores all the recent documents as open, so you dont have to keep re-opening files. But you're better off editing it within an IDE tbh.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to delete prefabs without warning popping up? 0 Answers
How to reference an inactive GameObject? 2 Answers
JsonUtility with openweatherAPI 1 Answer