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/codegenerator.git
Code Generator

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **Code Generator** 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/codegenerator.git
```

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

README

Code Generator

GitHub package.json version GitHub issues GitHub pull requests GitHub license GitHub last commit

Provides a collection of classes that will aid you with generating code.

Installation

  1. The package is available on the openupm registry. You can install it via openupm-cli.
openupm add net.tnrd.codegenerator
  1. Installing through a Unity Package created by the Package Installer Creator from Needle

Usage

The following example is based on the package Layers & Tags Generator

public void Generate()
{
    var tags = InternalEditorUtility.tags;

    var generator = new Generator();
    var tagsClass = new Class("Tags");

    foreach (var tag in tags)
    {
        tagsClass.AddField(
            new Field(Utilities.GetScreamName(tag), tag, typeof(string))
        {
            IsConst = true,
        });
    }

    generator.AddClass(tagsClass);
    generator.SaveToFile(Application.dataPath + "/Generated/Tags.cs");

    AssetDatabase.Refresh();
}

In the example above you can see the generator being used.

It starts with a Generator, which holds all of the items that will be generated. In this example a class named Tags will be added.

The Tags class contains some simple fields that have the name of the tag in SCREAM_CASE and are assigned the value. The type of the fields are of string and they are marked as constant for easy access.

Support

Code Generator is an open-source project that I hope helps other people. It is by no means necessary but if you feel generous you can support me by donating.

ko-fi

Contributions

Pull requests are welcomed. Please feel free to fix any issues you find, or add new features.

Comments

No comments yet. Be the first!