Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/text-transform.git?path=src/GameDevWare.TextTransform.Unity/Packages/com.gamedevware.text-transform

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **T4 Text Templates for Unity** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/text-transform.git?path=src%2FGameDevWare.TextTransform.Unity%2FPackages%2Fcom.gamedevware.text-transform
```

[![pkglnk](https://www.pkglnk.dev/badge/text-transform.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/text-transform)

README

Introduction

This Unity editor extension provides T4 text templates processor. T4 template is a mixture of text blocks and control logic that can generate a text file. The control logic is written as fragments of program code in C#. The generated file can be text of any kind, such as resource file, source code or web page.

T4 template example:

<html><body>
 The date and time now is: <#= DateTime.Now #>
</body></html>

Use cases

How to use

Create or copy file with .tt extension. Select this file in Project window (Window -> Project), then in Inspector window (Window -> Inspector) setup T4 template's parameters. Click "Generate" button. Inspector window for T4 template contains following parameters:

  • Output Type - type of generated file
    • Text - normal template's output. It corresponds to "Design-time T4 text templates" in Microsoft's terminology.
    • Text Generator - generator-class which can generate content when TransformText() is called. It corresponds to "Run time T4 text templates" in Microsoft's terminology.
  • Output Path - path to generated file. If not specified, generated file will have file name of template and file extension from output directive.
  • Auto-Gen Triggers - list of events which trigger auto-generation.
    • Code Compilation - after each code compilation
    • Asset Changes - after watched assets are changed, look for Assets to Watch
  • Auto-Gen Delay (Ms) - delay before triggered auto-generation starts
  • Assets to Watch - list of assets and folders which trigger auto-generation

Details

T4 template can use hostspecific=true property to access Host.ResolvePath method, which maps path relatively to template's location.

By default UnityEngine.dll and UnityEditor.dll assemblies are referenced in all templates. You can reference project's assemblies Assembly-CSharp and Assembly-CSharp-firstpass by adding assembly directive:

<#@ assembly name="Assembly-CSharp" #>
<#@ assembly name="Assembly-CSharp-firstpass" #>

Target Runtime

The template always uses the current runtime and core libraries of Unity Editor.

Language Version

You could specify C# language version with language= directive. List of available language versions:

  • language="C#v3.5" - C# version 3.5.
  • language="C#" - C# up to version 7, depending on Unity Editor's version.
  • unspecified - It is currently the equivalent of "C#".

MSBuild Macros are not available.

You can run template generation from your code with UnityTemplateGenerator.RunForTemplate(templatePath) call.

Contacts

Please send any questions at support@gamedevware.com

License

MIT

Comments

No comments yet. Be the first!