- Home /
How to include a custom editor in every project?
Hi there. I created a simple custom editor script. It's not project specific; it's something that could be useful no matter what project I'm in. Currently if I want it to be available in the project I'm working on, I need to manually copy the script to the project's editor folder. Is there some kind of "global" editor folder I can move the script to so it will always be there no matter what project I'm in?
You can save yourself the step of using File Explorer to copy the script around by making the script a package that you can import directly from Unity. It will preserve any folder structure you've created to store the file. Unity tends to remember locations you searched previously, so it should save a bit of time. I'm unaware if you can actually include the script as you want.
Answer by justDeek · May 11, 2018 at 02:42 PM
I have a similar setup, where I have a folder called "_SharedAssets" next to my Unity projects, that contains all the scripts and sprites that are basic enough to be useful in several projects. For that I create a directory hard-link from that _SharedAssets folder to an equally named empty folder in each Assets folder (either by console or you search for SymlinkCreator, at least if you're on Windows, which is a neat little GUI for creating symbolic links; it also doesn't matter if it has the same folder-name, but it keeps things organized).
With that you can also decide, which project should contain this folder (you need to create a hard-link for every project, that's why I suggest you to use the SymlinkCreator program) or have different folders for different projects and only link the folders you need depending on the project.
Short explanation: Symbolic links are like a reference to a folder and its content (like a link) and a directory hard-link accesses the same memory of the same content in different folders, which means that the system sees both folders as individually having the same content, but if you delete something in one of them, then it also removes it from the other folder (though I think deleting one of the folders doesn't remove the content as long as there's the other folder with that content | there are also two versions for both files and folders, so you should read up on that matter in general).
It's important that it's a hard-link because otherwise Unity doesn't use that folders content as if it would be directly in the Assets folder. If you've never used symbolic links before, you should be careful, what you enter as the source and what as the destination, since it could lead to one folder overwriting the wrong one, resulting in dataloss (that's why you should back up your files beforehand in case you're worried).
It all sounds harder than it is and will make your life a bit easier to know this sort of approach. I also haven't encountered any problems of using hard-links in Unity yet. If you create backups of your projects by copy-pasting for example, you should also note that the Assets/_SharedAssets folder of the backup will be empty, so you also need to backup the _SharedAssets folder directly, to also save the files in those folders.