I get the error message " An object reference is required for the non-static field, method or property ‘State.GetStateStory()’ "
I have no idea how to fix this and I’ve searched the internet quite a bit. Any help would be greatly appreciated!
State.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "State")]
public class State : ScriptableObject
{
[TextArea(10, 14)] [SerializeField] string storyText;
public string GetStateStory()
{
return storyText;
}
}
AdventureGame.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour
{
[SerializeField] Text textComponent;
[SerializeField] State startingState;
State currentState;
// Use this for initialization
void Start()
{
currentState = startingState;
textComponent.text = State.GetStateStory();
}
// Update is called once per frame
void Update()
{
}
}