Unity3d错​​误CS0119

时间:2015-08-24 20:34:13

标签: unity3d

我正在开发Unity3D游戏,我在这一行上收到错误:

Cube[i] = new Cube(S.ObjProp,S.TypeProp,S.MoveProp,S.AllergieProp,S.VisabilityProp,S.MainMaterial,S.SecondaryMaterial);

我用Google搜索了错误,发现当你不使用构造函数的新单词时会发生错误。我正在使用新单词,所以我不明白,这是错误:

Assets/Resources/Scripts/Classes.cs(66,41): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

这是我的构造函数所在的类:

    public class Cube{

                public Transform CubeObj{get; set;}
                public string CubeType{get; set;}
                public Vector3[] CubeMovement{get; set;}
                public string[] CubeAllergies{get; set;}
                public bool CubeVisability{get; set;}
                public Material CubeMainMat{get; set;}
                public Material CubeSecondaryMat{get; set;}

                public Cube(Transform _cubeObj, string _cubeType, Vector3[] _cubeMovement, string[] _allergies, bool _visability, Material _mainMat, Material _secondMat)
                {
                    CubeObj = _cubeObj;
                    CubeType = _cubeType;
                    CubeMovement = _cubeMovement;
                    CubeAllergies = _allergies;
                    CubeVisability = _visability;
                    CubeMainMat = _mainMat;
                    CubeSecondaryMat = _secondMat;
                }
            }

这就是我收到错误的类:

public static Cube[] LoadLevel (int _currentLevel)
        {
            // Bouw errors in als er geen levels in de map staan of de naam niet kopt met de levels.
            string levelName = "Level" + _currentLevel;
            GameObject levelObj = Resources.Load("Prefabs/Levels/" + levelName) as GameObject;
            throwLevelLoadError(levelObj);
            Cube[] cubes = new Cube[levelObj.transform.childCount];
            throwMissingCubesError(levelObj.transform.childCount);

            GameObject rotateXObj = new GameObject("RotateXObj");
            GameObject rotateYObj = new GameObject("RotateYObj");
            rotateYObj.transform.SetParent(rotateXObj.transform);

                for(int i = 0; i < cubes.Length; i++)
                {
                    GameObject curCube = MonoBehaviour.Instantiate(levelObj.transform.GetChild(i).gameObject) as GameObject;
                    curCube.transform.SetParent(rotateYObj.transform);
                    CubePropertiesS S = curCube.GetComponent<CubePropertiesS>();
                    Cube[i] = new Cube(S.ObjProp,S.TypeProp,S.MoveProp,S.AllergieProp,S.VisabilityProp,S.MainMaterial,S.SecondaryMaterial);
                }

        return cubes;

        }

1 个答案:

答案 0 :(得分:0)

Cube是一种类型,cubes是数组的名称

我确定你的意思是:cubes[i] = new Cube(S.ObjProp,S.TypeProp,S.MoveProp,S.AllergieProp,S.VisabilityProp,S.MainMaterial,S.SecondaryMaterial);