Skip to content

Instantly share code, notes, and snippets.

@JonRurka
Created January 28, 2015 23:15
Show Gist options
  • Save JonRurka/5bb20a48936d83c10b8a to your computer and use it in GitHub Desktop.
Save JonRurka/5bb20a48936d83c10b8a to your computer and use it in GitHub Desktop.
public object Call_CMD(params string[] args)
{
if (args.Length >= 3)
{
Type compType = null;
foreach (Assembly assm in Assemblies.Values)
{
Type testType = assm.GetType(args[1]);
if (testType != null)
{
compType = testType;
object[] components = GameObject.FindObjectsOfType(compType);
if (components.Length > 0)
{
foreach (object comp in components)
{
MethodInfo method = compType.GetMethod(args[2]);
if (method != null)
{
ParameterInfo[] parameters = method.GetParameters();
object[] paramObjs = new object[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
{
Type paramType = parameters[i].ParameterType;
if (paramType.IsPrimitive)
{
// iterate through parameters, convert to the types, add to paramObjs, and
// call method.Invoke.
}
}
}
}
}
}
}
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment