Last active
August 29, 2015 14:15
-
-
Save kankikuchi/a00571f2609ccc60c745 to your computer and use it in GitHub Desktop.
ConstantsClassCreator使用例【Unity】
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Text; | |
using UnityEditor; | |
using UnityEditorInternal; | |
using UnityEngine; | |
using System.Collections.Generic; | |
/// <summary> | |
/// ファイル名を定数で管理するクラスを作成するスクリプトの例 | |
/// </summary> | |
public static class ConstantsClassCreatorExample{ | |
// コマンド名 | |
private const string COMMAND_NAME = "Tools/Create/Example"; | |
/// <summary> | |
/// ファイル名を定数で管理するクラスを作成します | |
/// </summary> | |
[MenuItem(COMMAND_NAME)] | |
public static void Create() | |
{ | |
if (!CanCreate()) | |
{ | |
return; | |
} | |
CreateScript(); | |
} | |
/// <summary> | |
/// スクリプトを作成します | |
/// </summary> | |
public static void CreateScript() | |
{ | |
Dictionary<string, string> exampleDic = new Dictionary<string, string> (){ | |
{"KeyExaple", "Exaple"}, | |
{"BGMName" , "bgm"}, | |
{"key_KEY" , "key"}, | |
}; | |
ConstantsClassCreator.Create ("Example", "定数で管理するクラスの例", exampleDic); | |
} | |
/// <summary> | |
/// 定数で管理するクラスを作成できるかどうかを取得します | |
/// </summary> | |
[MenuItem(COMMAND_NAME, true)] | |
private static bool CanCreate() | |
{ | |
return !EditorApplication.isPlaying && !Application.isPlaying && !EditorApplication.isCompiling; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment