Hello, it must be a stupid question to ask, but I’m getting this error whilst testing out with things in Section 2, the part where you add the code to manage and update the state.
The error is
Assets\AdventureGame.cs(28,32): error CS7036: There is no argument given that corresponds to the required formal parameter 'selection' of 'State.getNextStates(int)'
Here’s the code:
AdventureGame.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour
{
[SerializeField] Text SceneDescription;
[SerializeField] Text storyText;
[SerializeField] State initializingState;
State state;
void Start()
{
UpdateState(initializingState);
}
void Update()
{
ManageState();
}
private void ManageState()
{
var nextStates = state.getNextStates();
if (Input.GetKeyDown(KeyCode.Alpha1))
UpdateState(nextStates[0]);
else if (Input.GetKeyDown(KeyCode.Alpha2))
UpdateState(nextStates[1]);
else if (Input.GetKeyDown(KeyCode.Alpha3))
UpdateState(nextStates[2]);
}
private void UpdateState(State nextState)
{
state = nextState;
storyText.text = state.getSceneDescription();
storyText.text = state.getStateStory();
}
}
State.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "State")]
public class State : ScriptableObject
{
[TextArea(1, 1)] [SerializeField] string sceneDescription;
[TextArea(14, 14)] [SerializeField] string storyText;
[SerializeField] State[] nextStates;
public string getSceneDescription()
{
return sceneDescription;
}
public string getStateStory()
{
return storyText;
}
public State[] getNextStates(int selection)
{
return nextStates;
}
}
This lecture is cool, thanks! <3