K
K
keltkelt2020-01-27 21:24:25
Unity
keltkelt, 2020-01-27 21:24:25

How to make a callback (or something like that) in Unity3D?

Why "like that": I'm still new to this topic, so I know what I want, but I don't know which tool is suitable.

I have a main script. You need to call a script from it located on another object - manipulate the object, then get some feedback (for example, the user selects a certain option) and return it to the first script. It is not necessary to do this asynchronously.

Google coroutines, callbacks, events, await, in general, mess in my head.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2020-01-27
@GavriKos

If it's not asynchronous AT ALL, then you simply call the method of the second script from the first script. The method should return what you need + you need a link to the script, of course.
If at least somehow asynchronously (and the input is like this) - then google Action and and lambda. Pass it to the method, the second script will remember and pull when necessary.
And learn seasharp before you get into the unit.

A
Argumentus, 2020-01-28
@Argumentus

Use https://docs.unity3d.com/ScriptReference/Events.Un...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question