Hello, I am currantly working on a game where the player must collect orbs, every time the player collects an orb the score goes up.
The only problem is that I keep getting this error that I have no clue what it means.
here is the error:
ArgumentException: You are not allowed to call Internal_Create when declaring a variable.
Move it to the line after without a variable declaration.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEngine.Texture2D..ctor (Int32 width, Int32 height) (at E:/BuildAgent/work/68355d6e5d19d587/Runtime/Export/Generated/Graphics.cs:922)
Score..ctor ()
And here are the 2 scripts I am useing (one for the orb and one for the GUI texture)
using UnityEngine;
using System.Collections;
public class Orb : MonoBehaviour {
public Transform target;
void OnCollisionEnter(Collision target){
Score.score += 1;
Destroy(transform);
}
}
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
static public int score = 0;
public Texture2D Score0 = new Texture2D (64, 64);
public Texture2D Score1 = new Texture2D (64, 64);
// Update is called once per frame
void update () {
switch(score){
case 1:
guiTexture.texture = Score1;
break;
case 0:
guiTexture.texture = Score0;
break;
}
}
}
any help would be greatly appreciated.