【发布时间】:2014-12-06 16:07:25
【问题描述】:
从外观上看,有两个脚本会产生这些错误,它们在下面列出:
------------------ GameInformation - 编码如下: -------------------
using UnityEngine;
使用 System.Collections;
公共类 GameInformation : MonoBehaviour {
void Awake(){
DontDestroyOnLoad (transform.gameObject);
}
public static string PlayerName{ get; set; }
public static int PlayerLevel{ get; set; }
public static BaseCharacterClass PlayerClass{ get; set; }
public static int Speed{ get; set; }
public static int Endurance{ get; set; }
public static int Strength{ get; set; }
public static int Health{ get; set; }
}
------------------ 另一个脚本是 SaveInformation: -------------------
using UnityEngine;
使用 System.Collections;
公共类保存信息 {
public static void SaveAllInformation(){
PlayerPrefs.SetInt("PLAYERLEVEL", GameInformation.PlayerLevel);
PlayerPrefs.SetString("PLAYERNAME", GameInformation.PlayerName);
PlayerPrefs.SetString("SPEED", GameInformation.Speed);
PlayerPrefs.SetString("ENDURANCE", GameInformation.Endurance);
PlayerPrefs.SetString("STRENGTH", GameInformation.Strength);
PlayerPrefs.SetString("HEALTH", GameInformation.Health);
}
}
------------------ 错误: -------------------
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(7,67):错误 CS0117:
GameInformation' does not contain a definition forPlayerLevel'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(7,29):错误 CS1502:最好的重载方法匹配 `UnityEngine.PlayerPrefs.SetInt(string, int)' 有一些无效 论据
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(7,29):错误 CS1503:参数
#2' cannot convertobject' 表达式类型为 `int'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(8,69):错误 CS0117:
GameInformation' does not contain a definition forPlayerName'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(8,29):错误 CS1503:要键入的参数
#2' cannot convertobject' 表达式 `字符串'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(9,64):错误 CS0117:
GameInformation' does not contain a definition forSpeed'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(9,29):错误 CS1502:最好的重载方法匹配 `UnityEngine.PlayerPrefs.SetString(string, string)' 有一些无效 论据
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(9,29):错误 CS1503:要键入的参数
#2' cannot convertobject' 表达式 `字符串'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(10,68):错误 CS0117:
GameInformation' does not contain a definition forEndurance'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(10,29):错误 CS1502:最好的重载方法匹配 `UnityEngine.PlayerPrefs.SetString(string, string)' 有一些无效 论据
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(10,29):错误 CS1503:要键入的参数
#2' cannot convertobject' 表达式 `字符串'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(11,67):错误 CS0117:
GameInformation' does not contain a definition forStrength'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(11,29):错误 CS1502:最好的重载方法匹配 `UnityEngine.PlayerPrefs.SetString(string, string)' 有一些无效 论据
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(11,29):错误 CS1503:要键入的参数
#2' cannot convertobject' 表达式 `字符串'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(12,65):错误 CS0117:
GameInformation' does not contain a definition forHealth'资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(12,29):错误 CS1502:最好的重载方法匹配 `UnityEngine.PlayerPrefs.SetString(string, string)' 有一些无效 论据
资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(12,29):错误 CS1503:要键入的参数
#2' cannot convertobject' 表达式 `字符串'
-------------------
在回复我时请记住,我对编码还比较陌生。谢谢!
-------------------
【问题讨论】: