Skip to content

HugoFang/UniEnum

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniEnum

Provides enumeration values utilities for Unity.

  • Fast utilitiy methods for enum. (GetValue, GetNames, IsDefined, TryParase etc..)
  • Automate the creation of Unity's constant values as enumerations. (Scene, Tag, Layer, SortingLayer)

Install

  1. Install from UnityPackage from Release Page
  2. Package Manager

UnityPackage

Download .unitypackage from Release Page

Package Manager

{
    "dependencies": {
        "com.xtaltools.unienum": "https://github.com/neptaco/UniEnum.git?path=src/UniEnum.Unity/Assets/UniEnum"
    }
}

Enum Utility Methods

.NET UniEnum
Enum.GetNames(typeof(EnumType)) UniEnum.GetNames<EnumType>()
Enum.GetValues(typeof(EnumType)) UniEnum.GetValues<EnumType>()
Enum.IsDefined(typeof(EnumType), v) UniEnum.IsDefined<EnumType>(v) 1
Enum.TryParse(typeof(EnumType)) UniEnum.TryParse<EnumType>(v)

Generate Unity constant values

Open ProjectSettings -> UniEnum and set the generation target.

Target Generated classes
Scene SceneId
SceneName
ScenePath
Layer LayerId
LayerMaskValue
SortingLayer SortingLyaerId
SortingLayerName
Tag TagName

How to manually update scene variables on batch build

Call the following method.

UnityConstantValuesGenerator.UpdateSceneValues(EditorBuildSettingScenes[] scenes)

License

This library is under the MIT License.

Footnotes

  1. UniEnum.IsDefined is case sensitive.

About

Enum Utilities for Unity

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 71.8%
  • ShaderLab 24.7%
  • HLSL 3.5%