Skip to content
This repository was archived by the owner on Jul 5, 2018. It is now read-only.

umm/enum_tryparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What?

  • Enum.TryParse を Unity でも使えるようにする

Why?

  • 2017年7月時点の Unity C# は .NET 3.5 を利用しており、 Enum.TryParse は .NET 4.0 以降の機能である
    • 一応 Unity 2017 では Experimental の機能として .NET 4.6 は使えるけどね
  • チョイチョイ使いたいシーンがあるので、無理矢理実装してみた

Install

$ npm install github:umm-projects/enum_tryparse.git

Usage

using ForwardCompatibility;

class Sample {
    enum Hoge {
        Unknown,
        Foo,
        Bar,
    }
    void Fuga() {
        Hoge hoge;
        if (!Enum.TryParse("Fuga", out hoge)) {
            hoge = Hoge.Unknown;
        }
    }
}

License

Copyright (c) 2017 Tetsuya Mori

Released under the MIT license, see LICENSE.txt

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published