2014-10-08 105 views
0

我試圖在我的統一遊戲中創建一個開始菜單,當我發現這個腳本在遊戲開始後立即啓用隱藏的精靈。當玩家按下鼠標左鍵或空格時,腳本會禁用它。當我嘗試使多個精靈出現並消失時,使用相同的腳本,只出現一個精靈。我還試圖找到一種方法來更改scipt,以便付款人必須點擊實際的精靈來禁用它,而不是隻按空格鍵。在Unity 3D中創建開始菜單

這是腳本:

using UnityEngine; 
using System.Collections; 

public class StartScreen : MonoBehaviour { 

    static bool sawOnce = false; 

    // Use this for initialization 
    void Start() { 
     if(!sawOnce) { 
      GetComponent<SpriteRenderer>().enabled = true; 
      Time.timeScale = 0; 
     } 

     sawOnce = true; 
    } 

    // Update is called once per frame 
    void Update() { 
     if(Time.timeScale==0 && (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))) { 
      Time.timeScale = 1; 
      GetComponent<SpriteRenderer>().enabled = false; 

     } 
    } 
} 

回答