//tips
//soundの音切れ
SEを再生中にシーン遷移が発生すると、BGMのゲームオブジェクトが消えてしまうため、音切れが発生してしまう。
シーン遷移前に単純に音を止める処理を追加したが効果はなかった。
public void NextScene(int stageNo)
{
//音楽停止
audioSource.Stop();
// ロード画面UIをアクティブにする
loadUI.SetActive(true);
// コルーチンを開始
StartCoroutine("PushStageSelectButton" + stageNo);
}
ちなみに、Destroy(audioSource);にしても効果なし。
逆に音を止めないで遷移中も鳴らすようにスクリプトを追加する。
下記スクリプトをaudiosourceに付加することで音切れを解消できる。
using UnityEngine;
using System.Collections;
public class MainSoundScript : MonoBehaviour
{
public bool DontDestroyEnabled = true;
// Use this for initialization
void Start()
{
if (DontDestroyEnabled)
{
// Sceneを遷移してもオブジェクトが消えないようにする
DontDestroyOnLoad(this);
}
}
// Update is called once per frame
void Update()
{
}
}
//新規ステージゴール時点でのCPointの追加
新しく攻略したステージのゴールでCPointを1point追加する。
point_num = PlayerPrefs.GetInt("CPoint", 2);の追加とアニメーションの追加を行い、setactiveで新しいステージのゴール時のみにあらわれるように設定した。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class TitleManage : MonoBehaviour
{
[SerializeField] UnityEngine.UI.Text textbox;
[SerializeField] GameObject item;
void Start()
{
//PlayerPrefs.DeleteAll();
int clearStageNo = PlayerPrefs.GetInt("CLEAR", 0); //どのステージまでクリアしているのかをロード(セーブされていなければ「0」)
int playstage = PlayerPrefs.GetInt("playstage", 1);
int laststage = PlayerPrefs.GetInt("Last", 0);
int point_num = PlayerPrefs.GetInt("CPoint", 2);
//Debug.Log("c"+clearStageNo);
//Debug.Log("p" + playstage);
//Debug.Log("l" + laststage);
item.SetActive(false);
if (clearStageNo > laststage)
{
//if (clearStageNo == 0) DeleteALLの場合
item.SetActive(true);
if (clearStageNo == 1)
{
textbox.text = "お散歩の達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
if (clearStageNo == 2)
{
textbox.text = "スキップの達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
if (clearStageNo == 3)
{
textbox.text = "回転の達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
if (clearStageNo == 4)
{
textbox.text = "襲歩の達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
if (clearStageNo == 5)
{
textbox.text = "転身の達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
if (clearStageNo == 6)
{
textbox.text = "変身の達人";
laststage = clearStageNo;
PlayerPrefs.SetInt("Last", laststage);
point_num += 1;
PlayerPrefs.SetInt("CPoint", point_num);
PlayerPrefs.Save();
}
}
else
{
textbox.enabled = false;
}
}
}
//loadingへのanimationの追加
Loading画面にアニメーションを追加した。
一瞬しか映らないのとそこまで動きは良くないのでもし追加するとしたら非同期も考えて摂家した方が良いかもしれない。
現状の重さではそこまで必要ない。