Bodkin
1
Hi,
I would like to replicated something like the event system in my script. I would want the user to specificity what script to use and what function to call in the inspector.
Can this be done without a custom editor?
thanks for all the help,
Yea it can be done. Without an Editor script, but you’re limiting yourself though, such as you won’t be able to have a drop down of functions in the inspector to choose from, similar to how the UI Event system looks. Without using an Editor script, you could simply have a script that contains a public GameObject and a public string. Executing the command would be a SendMessage on the GameObject. It’s crude, as this example doesn’t send values:
public class MessageSender : MonoBehaviour {
public string FunctionName;
public GameObject Sender;
public void ExecuteCommand()
{
Sender.SendMessage(FunctionName);
}
}
I assume you want to use delegates and Reflection, but I can’t see that happening without an Editor script.