Last active
January 3, 2016 02:29
-
-
Save Suzeep/8396190 to your computer and use it in GitHub Desktop.
シングルトンクラスのオブジェクトを起動時に自動生成するスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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