Skip to content

Instantly share code, notes, and snippets.

@Suzeep
Last active January 3, 2016 02:29
Show Gist options
  • Save Suzeep/8396190 to your computer and use it in GitHub Desktop.
Save Suzeep/8396190 to your computer and use it in GitHub Desktop.
シングルトンクラスのオブジェクトを起動時に自動生成するスクリプト。
using UnityEngine;
using System;
//=====================================================================================
// class SystemInstance
//=====================================================================================
public class SystemInstance : Singleton<SystemInstance>
{
//=====================================================================================
// constant
//=====================================================================================
// system class type tables
private static Type[] SYSTEM_INSTANCES =
{
// typeof( SysApp ),
// typeof( SysInput ),
// ...
};
//-------------------------------------------------------------------------------------
// Initialize
//-------------------------------------------------------------------------------------
protected override void Initialize()
{
Debug.Log( "Instantiate Systems." );
for( int i=0; i < SYSTEM_INSTANCES.Length; ++i )
{
Type class_type = SYSTEM_INSTANCES[ i ];
var obj = new GameObject();
obj.transform.parent = this.transform;
obj.transform.name = class_type.Name;
obj.AddComponent( class_type );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment