2014年10月18日土曜日

自作クラスとグローバルな変数

適当なスクリプトに書いておく

using UnityEngine;
using System.Collections;

//グローバル変数(整数)と自作クラス、構造体の定義

public class Global : MonoBehaviour {
    public static int TILESIZE = 16;
}

[System.Serializable]
public struct Vector2Int
{
    public int x;
    public int y;
}

Hierarchyに存在しなくても読み込まれるっぽい。
Global.TILESIZEみたいにアクセスする。

http://unity2dgame.blogspot.jp/2013/06/unity-2d-game-public-static.html
参考

http://panzersoft.blog.fc2.com/blog-entry-65.html
参考

DontDestroyOnLoad()は便利そう

0 件のコメント:

コメントを投稿