WienerWiener
  • はじめに
  • 競合比較
  • 価格・入手
  • FAQ
  • 向いているケース
  • ライセンス
  • Unity Asset版とStandalone版の違い
  • 簡易難読化・改ざん検知
  • 整合性検知・デバッグ
  • ローカライズ
  • バージョン管理
  • Google Sheets入力
  • Excel
  • YAML
  • 設定ファイル
  • データフォーマット
  • マスターデータコンバート
  • ValueOnlyフォーマット
  • スタートアップ
  • サンプル
  • Converter
  • YAML Editor
  • Setting Editor
  • 日本語
  • English
  • はじめに
  • 競合比較
  • 価格・入手
  • FAQ
  • 向いているケース
  • ライセンス
  • Unity Asset版とStandalone版の違い
  • 簡易難読化・改ざん検知
  • 整合性検知・デバッグ
  • ローカライズ
  • バージョン管理
  • Google Sheets入力
  • Excel
  • YAML
  • 設定ファイル
  • データフォーマット
  • マスターデータコンバート
  • ValueOnlyフォーマット
  • スタートアップ
  • サンプル
  • Converter
  • YAML Editor
  • Setting Editor
  • 日本語
  • English
  • サンプル

    • サンプル
    • 220万セルサンプルデータをコンバートする
    • アイテムマスターを作成する
    • ホットリロードを体験する
    • ユニットマスターを作成する
    • 報酬マスターを作成する
    • 装備マスターを作成する
    • ローカライズを体験する
    • 既存のYAMLにキーを追加する

アイテムマスターを作成する

サンプル開始前の準備

  • Unityスタートアップが完了している

概要

このサンプルでは、次の内容を扱います。

  • 列挙とアイテムデータを作成する
  • YamlEditorでExcelからYAMLファイルを作成する
  • Dictionary形式のマスターデータを作成する

アイテムマスターフォーマット

  • id(int) ID
  • name(string) 名前
  • description(string) 説明
  • type(enum:item_type) アイテムタイプ
  • value(int) 値
  • sale(int) 売却額

アイテムタイプフォーマット

  • Recovery
  • Buff
  • SellOnly

手順は次の通りです。

  1. Excel列挙ファイルの作成
  2. Excelデータファイルの作成
  3. YAMLの作成
  4. コンバート
  5. 動作確認

Excel列挙ファイルの作成

Excel列挙ファイルの作成を参考にEnumBaseを編集します。
Assets/Wiener/Data/excel/EnumBase.xlsx

item_type

Image from alias

to	from	value
none	None	0
recovery	Recovery	1
buff	Buff	2
sell_only	SellOnly	3

Excelデータファイルの作成

Unity Asset版では、Assets/Wiener/Data 配下にExcelファイルを配置します。

Assets/Wiener/Data/excel/Item/Item.xlsx

Assets
+-- Wiener
    +-- Data
        +-- client
        +-- excel
            +-- Const
            |   +-- Const.xlsx
            +-- Item
            |   +-- Item.xlsx
            +-- EnumBase.xlsx

Image from alias

int	string	string	item_type	int	int
id	name	description	type	value	sale
0	Invalid		None	0	0
1000000001	Potion (S)	Restores a small amount of HP	Recovery	100	10
1000000002	Potion (M)	Restores HP	Recovery	300	50
1000000003	Potion (L)	Restores a large amount of HP	Recovery	1000	100
1010000001	Power Up (S)	Slightly increases Power	Buff	1	20
1010000002	Power Up (M)	Increases Power	Buff	3	40
1010000003	Power Up (L)	Greatly increases Power	Buff	6	80
1020000001	Koban	Can be sold at shops for a high price	SellOnly	0	1000
1020000002	Oban	Can be sold at shops for a high price	SellOnly	0	5000

YAMLの作成

YamlEditorを使用してYAMLを作成します。

YamlEditorを開く

Tools > Wiener > Open Yaml Editorを選択してYamlEditorを開きます。

Image from alias

item_type.yamlを作成

左のツリーのenumフォルダを右クリックしてCreate From Enumを選択します。

Image from alias

入力ファイルを指定

Excel

SourceでExcelを選択します。
ダイアログのBrowseボタンを押下して、EnumBase.xlsxを選択します。

Excelファイル指定

Google Sheets

SourceでSpreadsheetを選択します。
Spreadsheet URLにEnumBaseのスプレッドシートURLを入力して、Loadボタンを押下します。

Spreadsheet指定

Google Sheetsを使用する場合は、事前に Google Sheetsの設定 を完了してください。

Enumを作成

Createボタンを押下してYAMLを作成します。

Image from alias

item_type.yamlが作成されたことを確認

Image from alias

itemフォルダを作成

左のツリーのyamlフォルダを右クリックしてCreate Folderを選択します。

itemフォルダ作成メニューitemフォルダ作成後

item.yamlを作成

左のツリーのitemフォルダを右クリックしてCreate From Inputを選択します。

Image from alias

入力ファイルを指定

Excel

SourceでExcelを選択します。
ダイアログのBrowseボタンを押下して、Item.xlsxを選択します。

Excelファイル指定

Google Sheets

SourceでSpreadsheetを選択します。
Spreadsheet URLにアイテムマスターのスプレッドシートURLを入力して、Loadボタンを押下します。

Spreadsheet指定

Google Sheetsを使用する場合は、事前に Google Sheetsの設定 を完了してください。

Sheet項目を設定

必要な項目を設定してCreateボタンを押下します。

Image from alias

item.yamlが作成されたことを確認

Image from alias

WienerDictionaryに変更

container_typeをWienerDictionaryに変更してSaveボタンを押下します。

Image from alias

コンバート

コンバータを開く

Tools > Wiener > Open Converterを選択してコンバータを開きます。

Image from alias

コンバート実行

Run Developを押下してコンバートを実行し、エラーが出ないことを確認します。

Image from alias

出力ファイル

正常にコンバートした場合は、次のパスにバイナリとソースが出力されます。

Assets
+-- Resources
|   +-- basic
+-- Scenes
+-- Scripts
    +-- Wiener

動作確認

以下のSample.csスクリプトを作成してシーンに配置し、正常にログが出力されることを確認してください。

Sample.cs

using UnityEngine;
using Wiener;
using WienerLib;

public class Sample : MonoBehaviour
{
    void Start()
    {
        var wm = new WienerManager();
        var textAsset = Resources.Load("basic") as TextAsset;
        var result = wm.LoadBasicPack(textAsset.bytes);
        if (result != Result.Success)
        {
            Debug.LogError($"Failed to load basic pack: {result}");
            return;
        }

        OutputItem(wm);
    }

    void OutputItem(WienerManager wm)
    {
        foreach (var item in wm.Item.Values)
        {
            Debug.Log($"Id: {item.Id}, Name: {item.Name}, Value: {item.Value}");
        }
    }
}

実行結果

Image from alias

補足

Item.xlsxのitem_typeに入力する値は、EnumBase.xlsxのitem_typeシートにあるfrom列の値を指定します。

Image from alias

多言語対応を行う場合、from列には英語の値を入れておくことをおすすめします。英語を基準にしておくと、ゲーム内の表示言語が増えた場合でも、データ上の識別名を共通化しやすくなります。

一方で、単一言語のゲームを作成する場合は、母国語を入力しても問題ありません。以下は日本語で記述した場合の例です。

Image from alias

C#で出力される列挙のコードはitem_typeのtoの項目をUpperCamel化したものになります。

namespace Wiener
{
	public enum ItemType
	{
		None = 0, // なし
		Recovery = 1, // 回復
		Buff = 2, // 強化
		SellOnly = 3, // 売却専用
	}
}
最終更新:: 2026/06/14 18:21
Contributors: artisan-sawasaka
Prev
220万セルサンプルデータをコンバートする
Next
ホットリロードを体験する