有没有办法在游戏开始前进行介绍?
Is there a way to put an intro before the game starts?
我想在 "Powered by Unity" 介绍之后放一个介绍(例如 intro.jpg),我希望介绍显示 2 秒。
我假设你的第一个场景叫做 Game
。
创建一个名为 "Introduction".
的新场景
在此场景中,添加您的图像元素并为其分配一个脚本:
using UnityEngine;
using System.Collections;
public class Intro : MonoBehaviour {
bool shouldGo = false;
float timeout = 2.0f;
void Update () {
if (shouldGo) {
timeout -= Time.deltaTime;
if (timeout <= 0.0f) Go();
return;
} else {
int percentageLoaded = (int)(Application.GetStreamProgressForLevel("Game") * 100.0f);
}
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
if (Application.CanStreamedLevelBeLoaded("Game")) shouldGo = true;
}
if (Input.GetMouseButtonDown(0)) {
if (Application.CanStreamedLevelBeLoaded("Game")) shouldGo = true;
}
}
void Go() {
Application.LoadLevel("Game");
}
}
然后在 Build Settings
中,添加新的 Introduction
场景并通过在列表顶部拖动将其移动到 0 位置。
我想在 "Powered by Unity" 介绍之后放一个介绍(例如 intro.jpg),我希望介绍显示 2 秒。
我假设你的第一个场景叫做 Game
。
创建一个名为 "Introduction".
的新场景
在此场景中,添加您的图像元素并为其分配一个脚本:
using UnityEngine;
using System.Collections;
public class Intro : MonoBehaviour {
bool shouldGo = false;
float timeout = 2.0f;
void Update () {
if (shouldGo) {
timeout -= Time.deltaTime;
if (timeout <= 0.0f) Go();
return;
} else {
int percentageLoaded = (int)(Application.GetStreamProgressForLevel("Game") * 100.0f);
}
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
if (Application.CanStreamedLevelBeLoaded("Game")) shouldGo = true;
}
if (Input.GetMouseButtonDown(0)) {
if (Application.CanStreamedLevelBeLoaded("Game")) shouldGo = true;
}
}
void Go() {
Application.LoadLevel("Game");
}
}
然后在 Build Settings
中,添加新的 Introduction
场景并通过在列表顶部拖动将其移动到 0 位置。