Hey,
so I ran into this problem
I saw few fixes but nothing worked for me.
Does anyone know what to do with this?
Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextInput : MonoBehaviour
{
public InputField inputField;
GameControlller controller;
void Awake()
{
controller = GetComponent<GameControlller>();
inputField.onEndEdit.AddListener(AcceptStringInput);
}
void AcceptStringInput(string userInput)
{
userInput = userInput.ToLower();
controller.LogStringWithReturn(userInput);
char[] delimiterCharacters = { ' ' };
string[] seperateInputWords = userInput.Split(delimiterCharacters);
for (int i = 0; i < controller.inputActions.Length; i++)
{
InputAction inputAction = controller.inputActions[i];
if (inputAction.keyWord == seperateInputWords[0]) ;
{ }
}
{
InputAction.RespondToInput (controller, seperateInputWords);
}
InputCompete();
}
void InputCompete()
{
controller.DisplayLoggedText();
inputField.ActivateInputField();
inputField.text = null;
}
}
system
January 14, 2020, 7:42pm
2
Please, post the entire error message otherwise we can only guess what could be the problem.
You should always post the error message since it gives line numbers, but a quick glance I assume this is your error.
InputAction.RespondToInput (controller, seperateInputWords);
You have a capital “I” so it’s pointing to the class and not the instance that you you maybe meant to create. However, you also have a lot of extra curly brackets and the instance you did create above it is within a for loop, which means the line I reference would not access the instance.
system
January 14, 2020, 8:18pm
4
Brathnann:
You should always post the error message since it gives line numbers, but a quick glance I assume this is your error.
InputAction.RespondToInput (controller, seperateInputWords);
You have a capital “I” so it’s pointing to the class and not the instance that you you maybe meant to create. However, you also have a lot of extra curly brackets and the instance you did create above it is within a for loop, which means the line I reference would not access the instance.
I suspected this as well.
So sorry about that!
The full error is:
An object reference is required for non-static field, method, or propety ‘InputAction.RespondToInput(GameController,string[ ])’
Brathnann:
You should always post the error message since it gives line numbers, but a quick glance I assume this is your error.
InputAction.RespondToInput (controller, seperateInputWords);
You have a capital “I” so it’s pointing to the class and not the instance that you you maybe meant to create. However, you also have a lot of extra curly brackets and the instance you did create above it is within a for loop, which means the line I reference would not access the instance.
So sorry about that!
The full error is:
An object reference is required for non-static field, method, or propety ‘InputAction.RespondToInput(GameController,string[ ])’
Brathnann:
You should always post the error message since it gives line numbers, but a quick glance I assume this is your error.
InputAction.RespondToInput (controller, seperateInputWords);
You have a capital “I” so it’s pointing to the class and not the instance that you you maybe meant to create. However, you also have a lot of extra curly brackets and the instance you did create above it is within a for loop, which means the line I reference would not access the instance.
Hello,
I lowered the I in inputAction but now it just says:
The name ‘inputAction’ does not exist in the current context
system
January 18, 2020, 4:30pm
8
You need to learn more about scripting.
You need to declare and define inputAction to fix the problem.
You need to learn about the scope of variables. inputAction doesn’t work there because where you declared it is in a for loop. As I said, you can’t access it. When you declare a variable in a for loop, it belongs to that for loop and can’t be accessed outside of it.