Пример #1
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this);
            return;
        }

        instance = this;

        DontDestroyOnLoad(gameObject);
    }
Пример #2
0
    public static KeyCodeCheats GetInstance()
    {
        if (instance == null)
        {
            instance = (KeyCodeCheats)GameObject.FindObjectOfType <KeyCodeCheats>();
            if (instance == null)
            {
                GameObject g = new GameObject("KeyCodeCheats");
                instance = g.AddComponent <KeyCodeCheats>();
            }
        }

        return(instance);
    }