2016-07-15 40 views
0
using UnityEngine; 
using System.Collections; 

public class NewBehaviourScript : MonoBehaviour { 
    // Use this for initialization 
    void Start() { 
    } 

    // Update is called once per frame 
    void Update() { 
     if (
     } 
    } 

裏面的,如果(我型輸入,但它不存在 我試着在上面using.System.Io增加;但是這並不是解決在統一的C#腳本爲什麼輸入不存在?

在我的統一的項目我點擊菜單on Assests>打開C#項目,它打開了一個新的單聲道開發腳本窗口

在我的團結項目中,我有一個第一人稱字符,並且在它下面有一個聚光燈 我想在腳本中創建一個關鍵觸發器,在關鍵F上它會打開聚光燈,如果我再次點擊F,它將關閉聚光燈。

+0

找到它我需要將c#腳本圖標拖到聚光燈對象。 –

+0

但是腳本仍然存在一些問題。編輯我的問題? –

回答

0

enter image description here

如果沒有輸入,你應該檢查腳本:

1.fix編譯器錯誤

2.如果你沒有,你不能訪問輸入或等庫?

using UnityEngine;使用System.Collections的 ;

3.如果您不能訪問輸入,你應該從monodevelop.com

using UnityEngine; 
    using System.Collections; 

    public class ExampleClass : MonoBehaviour { 
    public bool mybool; 
    void Update() { 
    if (Input.GetKeyDown(KeyCode.F)) 
    GetComponent<Light>().enabled = !mybool; 
     } 
} 

安裝新版本的MonoDevelop解釋:!

假=真

真=假

相關問題