团结3D - 错误太多

问题描述:

两个脚本生成由它的外观这些错误,他们列举如下:团结3D - 错误太多

------------------- ------------ GameInformation - 编码如下: -------------------------- -----

using UnityEngine; 

using 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;

公共类SaveInformation {

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 for PlayerLevel”

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(7,29):错误 CS1502 :用于 `UnityEngine.PlayerPrefs.SetInt(字符串,整数)”最好的重载的方法匹配有一些无效 参数

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(7,29):错误 CS1503:参数#2' cannot convert object'表达式到'int'类型

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(8,69):错误 CS0117:GameInformation' does not contain a definition for PlayerName”

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(8, 29):错误 CS1503:参数#2' cannot convert对象 '表达键入 '字串'

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation。CS(9,64):错误 CS0117:GameInformation' does not contain a definition for速度”

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(9,29):错误 CS1502:最好重载方法 匹配`UnityEngine .PlayerPrefs.SetString(字符串,字符串) '已经一些无效 参数

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(9,29):错误 CS1503:参数#2' cannot convert对象' 表达键入 `string'

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(10,68):错误 CS0117:GameInformation' does not contain a definition for 耐力”

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(10,29) :错误 CS1502:用于 `UnityEngine.PlayerPrefs.SetString(字符串,字符串)最好重载的方法匹配”具有一些无效 参数

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(10,29 ):错误 CS1503:参数#2' cannot convert对象 '表达键入 '字串'

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(11,67):错误 CS0117:GameInformation' does not contain a definition for强度”

资产/标准 资产/脚本/SavingAndLoading/SaveInformation.cs(11,29):错误 CS1502:用于 `UnityEngine.PlayerPrefs.SetString(字符串,字符串,最好重载方法匹配)”具有一些无效 参数

资产/标准 个资产/脚本/ SavingAndLoading/SaveInformation.cs(11,29):错误 CS1503:参数#2' cannot convert对象 '表达键入 '字串'

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(12 ,65):错误 CS0117:GameInformation' does not contain a definition for健康”

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(12,29):错误 CS1502:用于 `UnityEngine.PlayerPrefs最好重载方法匹配。 SetString(string,string)'有一些无效 参数

资产/标准 资产/脚本/ SavingAndLoading/SaveInformation.cs(12,29):错误 CS1503:参数#2' cannot convert对象 '表达键入 '字串'

----- --------------------------

请回答时,请记住,我是比较新的编码。谢谢!

-------------------------------

在编程世界这些都是非常基本的错误,如果你了解它们,你会发现进步要容易得多,而不仅仅是下载脚本并希望它们全部结合在一起。下面我所描述的每个错误的原因让你开始:

GameInformation' does not contain a definition for 
    PlayerLevel' 
// This one means you're talking about PlayerLevel 
// in GameInformation, but GameInformation doesn't have PlayerLevel 

The best overloaded method match for `UnityEngine.PlayerPrefs.SetInt(string, int)' has some invalid arguments 
// This means that you're trying to call SetInt with something that isn't a string 
// or something that isn't an int 

Argument #2' cannot convert object' expression to type `int' 
// Same as above, trying to give *object* to something that expects *int* 

GameInformation' does not contain a definition for 
    PlayerName' 
// GameInformation doesn't have PlayerName either 

Argument #2' cannot convertobject' expression to type `string' 
// Can't put an *object* Type into *string* 

GameInformation' does not contain a definition forSpeed' 
// You can probably guess that this means that there is no Speed in GameInformation 

GameInformation' does not contain a definition for 
Endurance' 
// You guessed it, no Endurance in GameInformation :) 

The best overloaded method match for `UnityEngine.PlayerPrefs.SetString(string, string)' has some invalid arguments 
// Based on the other errors, you're probably trying to pass *object* as 
// a *string* 

基本上,所有的错误都归结为一点:你GameInformation类没有,你引用的属性(耐力,速度等),这让编译器感到不安。

+0

所以,如果我需要解决这个问题,我会... – 2014-12-06 21:06:24

+0

我该如何解决它? – 2014-12-06 22:18:07

+0

从我的答案可以推断,可以添加属性或删除对不存在的属性的引用。我的回答的第二个含义是,如果你*不能*修复它,你*可以*学习。以下是一组教程,以便您可以实际学习如何编程:http://www.tutorialspoint.com/csharp/index.htm – 2014-12-06 22:37:56