Reputation: 1835
I have an InputField and I'm targeting my "FindSoftware" function for OnValueChanged but it won't pass the string of the InputField. I can manually type what it will pass beside where I select which function to call ("This_is_Static_Boo..." in the example below), but that's no good since I want the text I am currently typing into it. How do I make it dynamic?
public void FindSoftware(String s)
{
Debug.Log("Updated string = " + s); // Always blank or whatever I statically tell it to be
}
Upvotes: 0
Views: 630
Reputation: 90580
There are two types of callbacks for UnityEvent
s
When configuring a
UnityEvent
in the Inspector there are two types of function calls that are supported:
Static. Static calls are preconfigured calls, with preconfigured values that are set in the UI. This means that when the callback is invoked, the target function is invoked with the argument that has been entered into the UI.
Dynamic. Dynamic calls are invoked using an argument that is sent from code, and this is bound to the type of
UnityEvent
that is being invoked. The UI filters the callbacks and only shows the dynamic calls that are valid for theUnityEvent
.
So when setting up your method call just make sure you select the one from the Dynamic
section on the top where all callable methods are listed that take string
(or the given type(s)) as a parameter(s).
Upvotes: 3