Unity脚本错误(错误CS0118)

时间:2014-04-07 20:14:17

标签: c#

请帮我修复错误。 消息是: “Assets / Scripts / GameManager.cs(6,21):错误CS0118:GameManager.character' is a字段'但是'类型'是预期的” 错误发生(6,21)。感谢。

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {
public List<character> character = new List<character>(); <-- (ERROR CS0118)

bool ShowCharWheel;
public int SelectedCharacter;
public int xcount;
// Use this for initialization
void Start () {

}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.C)){
    {
            ShowCharWheel = true;
    }

    {
            ShowCharWheel = false;
    }


    //Camera.main.GetComponent<SmoothFollow>().target = characters[SelectedCharacter].

    if (ShowCharWheel)
    {
                    GUILayout.BeginArea(new Rect(Screen.width - 64, Screen.height - 192,64,192));
            {
                if(GUILayout.Button(c.icon,GUILayout.Width(64),GUILayout.Height(64)))
                foreach (character c in Characters)
                {
                    SelectedCharacter = character.IndexOf(c);
                }
            }
        }
        GUILayout.EndArea();
    }
}
}

[System.Serializable]
public class Character
{   
public string name;
public Texture2D icon;
public GameObject prefab;
public GameObject instance;
public Transform HomeSpawn;
}

除了代码之外需要更多细节,所以请忽略它。

1 个答案:

答案 0 :(得分:2)

您是否只需要资本化? C#区分大小写。

public List<Character> characterList = new List<Character>();

为了清晰起见,我还重命名了你的变量。

相关问题