1
\$\begingroup\$

I'm developing several games at once, and they all use the same helper C# class which I have named "Helpers.cs".

This script contains common helper functions.

I'm still making changes to this Helper.cs files quite often, and I have to take care to update this file for all of my projects: If I work at 3 projects as once, I have to make sure I didn't forget to update

Project 1\Assets\Scripts\Helpers.cs
Project 2\Assets\Scripts\Helpers.cs
Project 3\Assets\Scripts\Helpers.cs

This is error prone.

I would like to know if there is a way to have only 1 "Helper.cs", for example in

d:\dev\games\common\Helpers.cs

... and all projects would use this. Then I would only have to update the file once if edit it.

I'm using Windows.

Is this possible?

\$\endgroup\$
1
  • \$\begingroup\$ Presumably you considered making a symbolic link to this shared folder from inside your assets folder, so to Unity it looks like it's a sub-folder of Assets as usual? That would be more of a Super User question, since it's about working with your OS file system, not game development specific. \$\endgroup\$
    – DMGregory
    Jun 6 '20 at 12:27
2
\$\begingroup\$

We have a framework shared among our various projects which we have as a git repository. Each project has its own git repository, and references the framework repository as a submodule.

This doesn’t automatically update the different projects, but does make it easier to share code between projects in general.

If you want to avoid using git submodules, you can create a hard link. Note that the source and destination files must be on the same volume. Here’s how to make a hard link in Windows 7, which I think should still apply in Windows 10.

https://superuser.com/questions/255731/make-a-hard-link-without-extra-programs-in-windows-7

If you want to include more than one source file, you could create a symbolic link to an entire directory, but that could cause issues with .meta files shared between projects. Unity has complained about doing that sort of thing in the past. I’m not sure if it still does.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.