This is a package to automatically or manually generate C# accessor classes to reach various Unity data like Localization.
Next I am planning to add support for scenes in build settings or in Build Profiles and elements having IDs in UiDocuments (some restriction probably will apply).
If you any of the packages or services above is not present in your project/editor, the corresponding CodeGen service will be disabled.
This package is using Unity's EditorCoroutines package. If it is not installed this package will attempt to install it.
You can choose manually install this package or install from GitHub source.
Use the Package Manager's +/Add package from git URL
function.
The URL you should use is this:
https://github.com/LurkingNinja/com.lurking-ninja.input-codegen.git?path=Packages/com.lurking-ninja.input-codegen
- Download the latest
.zip
package from the Release section. - Unpack the
.zip
file into your project'sPackages
folder. - Open your project and check if it is imported properly.
This tool is generating C# classes automatically whenever possible. When it is not, you can always run the generator from the menu: You can open up the Project Settings and set some data to help generate C# classes. This will change over time when I add support for other services.
If this checked, the generator will automatically run when data gets changed in supported services. Please read through the usage of the individual service support usage when automatic generation isn't possible because of lack of support from Unity.
If you want to enforce a specific namespace for the generated C# code you can add here.
This should be a folder (if it doesn't exists it will be created) to place all the C# code generated for this specific service.
These depend on the specific service and used to generate the C# code including class and individual elements.
CodeGen used to support the Input System, over time Unity improved their codegen for this package so that support is discontinued.
The Localization service help Unity's Localization package's entries. After creating String Tables all entries become accessible from C#. Example:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Generated: 10/25/2024 10:31:27 PM
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Collections.Generic;
using UnityEngine.Localization.Settings;
public static partial class I18N
{
public static class @Test
{
private const string @NAME = "Test";
public static string @New_Entry1 => LocalizationSettings.StringDatabase.GetLocalizedString(NAME, 11827220480);
public static string @xfvxvx => LocalizationSettings.StringDatabase.GetLocalizedString(NAME, 4700304117760);
}
}
You can access the entries through I18N.<Stringtable Name>.<Entry>
, this returns with the string translated to the active, selected language.