Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created July 28, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/8cc88c45cb61702911851d81a3c41cf8 to your computer and use it in GitHub Desktop.
Save tsubaki/8cc88c45cb61702911851d81a3c41cf8 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.Assertions;
public class Spawn : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Init()
{
// 凄い重要なオブジェクトの生成して、staticに登録
var sio = Resources.Load ("sugoi juyou na obujekuto") as GameObject;
sioi = GameObject.Instantiate (sio);
}
static GameObject sioi = null;
void Awake()
{
Assert.IsNotNull (sioi); // Initが値を設定したのでnullではない(2周めは知らない)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment