Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        // オーディオマネージャーが存在するかの確認
        //if(!AudioManager.Instance){
        // 存在しなければ生成
        // Instantiate(audioManagerPrefab, Vector3.zero, Quaternion.identity);
        //Debug.Log("AudioManager.Instanceを生成します");
        //}

        // BGMがなっていなければ、ゲーム用のBGMを鳴らす
        //if(!AudioManager.Instance.IsPlayingBGM()){
        //   AudioManager.Instance.PlayBGM(BGM_OUTGAME);
        //}

        // ボリュームを下げる
        //AudioManager.Instance.BgmVolume(0.5f);

        // ステージクリア数
        int clearMax = PlayerPrefs.GetInt("StageClear", 0);

        // 子オブジェクトを全削除
        foreach (Transform n in contents.transform)
        {
            GameObject.Destroy(n.gameObject);
        }

        // stageMax 分 buttonPrefab を生成
        for (int i = 0; i < stageMax; i++)
        {
            // contents 内に buttonPrefab を生成
            GameObject obj = Instantiate(
                buttonPrefab,
                Vector3.zero,
                Quaternion.identity,
                contents.transform
                ) as GameObject;

            // ボタンの情報を変更
            ButtonStage button = obj.GetComponent <ButtonStage>();

            // ステージをセット
            int stage = i + 1;

            // クリアを確認
            bool flag = false;

            // クリアしているステージより下なら選択できるようにする
            if (i <= clearMax)
            {
                flag = true;
            }

            // ボタンを設定
            // Debug.Log(stage);
            button.SetStage(flag, stage);
        }
    }