Все просто, это рефлексия
obj.GetType().GetMethod("MyMethod").Invoke(obj, arguments[])
Пара ссылок
https://msdn.microsoft.com/ru-ru/lib...eflection.aspx
https://msdn.microsoft.com/ru-ru/lib...v=vs.110).aspx
https://msdn.microsoft.com/ru-ru/lib...v=vs.110).aspx
Правда в Unity не просто рефлексия, а там несколько сложнее. Но принцип один, в Unity ничего не объявлено, все ищется по по именам.
Вот вам пример:

using UnityEngine;
using System.Reflection;
/// <summary>
/// Аналог SendMessage с более продвинутыми функциями.
/// Посылает сообщения даже выключенным объектам.
/// </summary>
public static class Message
{
public static void InvokeMethod(this GameObject gameObject, string methodName)
{
foreach (Component c in gameObject.GetComponents<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, null);
}
}
public static void InvokeMethod(this GameObject gameObject, string methodName, params object[] parameters)
{
foreach (Component c in gameObject.GetComponents<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, parameters);
}
}
public static void InvokeMethodUpwards(this GameObject gameObject, string methodName)
{
Transform t = gameObject.transform;
while (t)
{
foreach (Component c in t.gameObject.GetComponents<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, null);
}
t = t.parent;
}
}
public static void InvokeMethodUpwards(this GameObject gameObject, string methodName, params object[] parameters)
{
Transform t = gameObject.transform;
while (t)
{
foreach (Component c in t.gameObject.GetComponents<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, parameters);
}
t = t.parent;
}
}
public static void BroadcastMethod(this GameObject gameObject, string methodName)
{
foreach (Component c in gameObject.GetComponentsInChildren<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, null);
}
}
public static void BroadcastMethod(this GameObject gameObject, string methodName, params object[] parameters)
{
foreach (Component c in gameObject.GetComponentsInChildren<Component>())
{
MethodInfo m = c.GetType().GetMethod(methodName);
if (m != null)
m.Invoke(c, parameters);
}
}
}