Skip to content

Instantly share code, notes, and snippets.

@jmickle66666666
Created July 30, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmickle66666666/161c7ea0d6e13c9cdba7fd3d3a89d344 to your computer and use it in GitHub Desktop.
Save jmickle66666666/161c7ea0d6e13c9cdba7fd3d3a89d344 to your computer and use it in GitHub Desktop.
MethodInfo method = thisType.GetMethod(curLine[0]);
if (method != null) {
ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length == curLine.Length-1) {
object[] inputParameters = new object[parameters.Length];
for (int i = 0; i < parameters.Length; i++) {
if (parameters[i].ParameterType.Equals(typeof(int))) {
inputParameters[i] = ReadVar(curLine[i+1]);
} else if (parameters[i].ParameterType.Equals(typeof(Vector2Int))) {
inputParameters[i] = ReadPos(curLine[i+1]);
} else if (parameters[i].ParameterType.Equals(typeof(float))) {
inputParameters[i] = ReadFloat(curLine[i+1]);
}
}
method.Invoke(this, inputParameters);
} else {
Warning("Incorrect number of parameters. Expected "+parameters.Length.ToString()+" got "+(curLine.Length-1).ToString());
}
} else {
Warning("Couldn't find function: "+curLine[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment