using UnityEngine;
using System.Collections;
public class objectControl : MonoBehaviour {
public char slected_item = 'F';
public int selected_model = 0;
public GameObject f,o,d;
// Use this for initialization
void Start () {
f = GameObject.Find("f");
o = GameObject.Find("o");
d = GameObject.Find("d");
selected_item = 'F';
}
// Update is called once per frame
void Update () {
selected_item = 'F';
if (Input.GetKey(KeyCode.F)){
selected_item = 'F';
doSelectedAnimation();
}
}
void doSelectedAnimation(){
iTween.MoveTo(f,iTween.Hash("y",-3,"time",4));
}
}
在我试图从3个不同的地方访问“selected_model”的代码中。但不是它们有效。调试器出现以下错误。
Assets / Scripts / objectControl.cs(15,17):错误CS0103:当前上下文中不存在名称`selected_item
答案 0 :(得分:6)
您将其定义为public char slected_item = 'F';
错过了e
;)
selected
它并没有抱怨selected_model
,只是你选错了拼写错误。当然这应该在IDE中很容易看到了吗?