纳金网
标题:
关于singleton
[打印本页]
作者:
烟雨
时间:
2013-6-28 07:18
标题:
关于singleton
using UnityEngine;
using System.Collections;
public class LevelManagerScript : MonoBehaviour {
private static LevelManagerScript _instance;
public static LevelManagerScript Instance
{
get
{
if (!_instance)
{
_instance = GameObject.FindObjectOfType(typeof(LevelManagerScript)) as LevelManagerScript;
if (!_instance)
{
GameObject container = new GameObject();
container.name = "LevelManagerScriptSingleton";
_instance = container.AddComponent(typeof(LevelManagerScript)) as LevelManagerScript;
DontDestroyOnLoad(container);
}
}
return _instance;
}
}
}
这段代码怎么转成JS的啊,我就改了他的语法,但是不可用·····
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5