Hi hope its not too dumb a question. I'm trying to see if i could drag the text in a button onto the on Click method of the button. The drag drop doesn't work.
If not, is the only way on script? Whats the best way to get the text via script?
(The text is added via a script).
CodePudding user response:
Seemingly your DialogueManager.continue
method takes a string
as parameter
public void continue(string text)
{
...
}
-> No! You can't simply drag in a component into a string
field.
Try to make your method rather take a Text
/TMP_Text
component as parameter
public void continue (Text /* or TMP_Text accordingly*/ text)
{
Debug.Log(text.text);
...
}
CodePudding user response:
You can do something like that. The function you are calling needs to take what you want to pass as a parameter though. So in this example the function is taking a GameObject.
public void DialogueButtonPressed(GameObject textGameObject)
{
}
You can pass whatever type you want though. Maybe you want to pass a UI.Text component.