Skip to content

Instantly share code, notes, and snippets.

@kankikuchi
Last active August 29, 2015 14:15
Show Gist options
  • Save kankikuchi/a00571f2609ccc60c745 to your computer and use it in GitHub Desktop.
Save kankikuchi/a00571f2609ccc60c745 to your computer and use it in GitHub Desktop.
ConstantsClassCreator使用例【Unity】
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