- I am trying to get the input with numbers, but it’s not happening when it’s working if I give any other keywords.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour
{
[SerializeField] Text textComponent;
[SerializeField] State StartingState;
int[] oddNumbers = { 1, 3, 5, 7, 9 };
string[] weekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
State CurrentState;
State Stage;
// Start is called before the first frame update
void Start()
{
CurrentState = StartingState;
textComponent.text = CurrentState.GetStateStory();
Debug.Log(oddNumbers[4]);
}
// Update is called once per frame
void Update()
{
ManageStates();
if (Input.GetKeyDown(KeyCode.T))
{
Debug.Log(weekDays[2]);
}
}
private void ManageStates()
{
var nextStates = CurrentState.GetNextStates();
if (Input.GetKeyDown(KeyCode.A))
{
CurrentState = nextStates[0];
}
else if (Input.GetKeyDown(KeyCode.S))
{
CurrentState = nextStates[1];
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
CurrentState = nextStates[2];
}
textComponent.text = CurrentState.GetStateStory();
}
}
State.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = “State”)]
public class State : ScriptableObject
{
[TextArea (14,14)] [SerializeField] string storyText;
[SerializeField] State nextStates;
public string GetStateStory()
{
return storyText;
}
public State[] GetNextStates()
{
return nextStates;
}
}
- I’m getting this error continuously.