Hello. I’ve been searching about this for hours and have found multiple answers to similar questions but not similar enough for me to find a solution. Anyway my problem is:
I have a method GetResultMyTeam
that takes an object of class Match
and returns an int[2] result for it, based on user input. The problem for me is how can I wait for the user input inside this method?
The method I’m running is as follows:
int[] GetMyTeamResult(Match PlayedMatch)
{
int[] test = new int[2];
UIManager.GetComponent<UIManager>().HideOffers();
UIManager.GetComponent<UIManager>().HideMatchweek();
UIManager.GetComponent<UIManager>().ShowMatchday();
// it should wait here
test[0] = md_manager.GetComponent<MatchdayManager>().HomeTeamGoals;
test[1] = md_manager.GetComponent<MatchdayManager>().AwayTeamGoals;
return test;
Firstly I show the proper UI so that the user can input the result and then get the HomeTeamGoals
and AwayTeamGoals
variables and set them to the test array, which is returned. The problem obviously is that the test array gets filled before the user has a chance to input any data. So I want the method to wait until the user does input some data.
I tried
-
To create a couroutine only to wait. But time waits only inside the couroutine, the method returns the wrong value anyway.
-
To replace the whole method by a couroutine but it didn’t seem too good of an idea have some other results being given by methods and others by coroutines. Besides I couldn’t figure out how to set input paramaters to the couroutine and have it return values the same way the method would. If this is the way to go do tell me how I can implement it correctly.