// Start is called before the first frame update
    void Start()
    {
        GameObject         obj       = GameObject.FindGameObjectWithTag("");
        SingletonPattern01 singleton = obj.GetComponent <SingletonPattern01>();

        gameObject.GetComponent <SingletonPattern01>();

        GetComponent <SingletonPattern01>();

        //= FindObjectOfType<SingletonPattern01>();
        life = singleton.Hp;
    }
Exemple #2
0
    void Start()
    {
        singleton = GameObject.FindObjectOfType <SingletonPattern01>();

        if (singleton)
        {
            Debug.Log(singleton.ToString());
        }
        else
        {
            Debug.LogError("オブジェクトが見つかりませんでした");
        }
    }
    private void OnDestroy()
    {
        SingletonPattern01 singleton = FindObjectOfType <SingletonPattern01>();

        singleton.Hp = life;
    }