Hi,
I feel like i need to re-raise this issue. I have seen many questions on the problem that arises when using T4 templates with Unity (they are dropped during compile) but have not seen any solutions or official respons.
Apologies if I have missed something but is there a way to either force Unity to include .tt files or is there oficial support for T4 somehow?
This is an old one indeed.
In an old post on my blog, i discussed T4 with Unity - T4 Code Generation Fun with Unity — Random BitsRandom Bits
I just went back to that post to get the URL for the bug i submitted for making T4 supported (e.g: not dropping it from the generated solution every time) - it seems to have been dropped though: Unity Issue Tracker - Add T4 templates to user script projects
This link is dead… weird.
Anwyay - nothing has been done to support it unfortunately. I use preprocessed templates that are managed in another project (outside of Unity).
1 Like
Thanks liortal, I think i have searched every post on this and followed all of the posted links. I saw that you can manually add the template into the project file but that seems a bit of a pain.
It seems hard to believe that there is no way to force Unity to compile these files. Anyone with more knowledge on this who can help here?
what do you mean for “Unity to compile these files” ?
Do you mean the .tt files ? you can process them manually using a command line tool called TextTransform.exe
This functionality is baked into IDEs (e.g: MonoDevelop or Visual Studio) but you can also do it yourself.
The annoying issue is that Unity will remove the reference to the .tt file every time it compiles…
As an interim step can you explain how you can use TextTransform in Mono please
The tool is located in this path (on OSX, for Windows it’ll be slightly different):
/Applications/Unity/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe
Here are the usage instructions:
So you basically launch it like:
TextTransform.exe <path to .tt file> -o=