I have such a problem. I created a Character class. Also I created an ".asset" file and called it "Alice". I try to run a code:
[CreateAssetMenu(fileName = "New Character", menuName = "Character data", order = 51)]
public class Character : ScriptableObject {
[SerializeField]
public new string name;
[SerializeField]
public Color color;
}
public class TextPrinting : MonoBehaviour {
public Text nameText;
public Character Alice;
void say (Character ingamecharacter) {
nameText.text = ingamecharacter.name;
nameText.color = ingamecharacter.color;
}
void Start() {
say(Alice);
}
}
But I have a NullReferenceException error on 15 line. I wrote a definition for nameText.
nameText = GameObject.Find("Canvas/Panel/NamePanel/NameText").GetComponent<Text>();
But I still have this error. So (I guess) the problem is that I need to write a definition for Alice Character. But I don't understand how can I do this if it's a Scriptable Object and I need to use file from Assets folder to do this.
What should I do? Or I do totally wrong thing?
Thanks.