unity开发总结

阶段总结:

unity5.3.x 加载场景SceneManager.LoadScene().

一个按钮3次不同响应的方法:num++;Switch(num):case 1:响应1 break;case 2:响应2 break;case 3:响应3 num=0;break;

游戏音乐一直存在场景中的方法:

一个单例物体加载场景不销毁

 if (gameStart == null)
        {
            GameObject start = new GameObject("GameStart");
            gameStart = start.AddComponent<GameStart>();
            gameStart.gameObject.AddComponent<AudioSource>();
            gameStart.GetComponent<GameStart>().source = gameStart.GetComponent<AudioSource>();
            gameStart.GetComponent<GameStart>().source.clip = sound;
            gameStart.GetComponent<GameStart>().source.loop = true;
            gameStart.GetComponent<GameStart>().source.Play();
            DontDestroyOnLoad(gameStart);
        }



猜你喜欢

转载自blog.csdn.net/liuleitheone/article/details/51445326