Game Development Reference
In-Depth Information
void Start ()
{
//Subscribe my delegate to my parameterized UnityEvent Manager
myParameterizedEvent.AddListener(MyOtherDelegate);
// Execute all registered delegates with the string parameter
myParameterizedEvent.Invoke("Hello World");
}
//My parameterized Delegate function
private void MyOtherDelegate(string arg0)
{
Debug.Log("Some Message - " + arg0);
}
public void RunMeFromTheInspector(stringĀ arg0)
{
Debug.Log("What are you telling me? : " + arg0);
}
}
If we then add this to our scene as before on a new empty GameObject called
SimpleParameterizedEventObject and also configure it in the editor as before using
the static version of the RunMeFromTheInspector(string) method as shown in
the following screenshot, we get the same as before but we are now passing it some
additional information in the call using the new value field:
So when we run the project with the previous configuration, we get one message
from the code saying Some Message - Hello World and one message from the editor
configuration saying " What are you telling me? : Inspector Gadget ".
It's a little more complicated but also gives you a little more freedom.
 
Search WWH ::




Custom Search