I am creating a new game in unity. And I like to create walkthrough guidance for my game that will show after the first signup, like, click here to grab the coins. After collecting coins it should show, click here to buy things. these are the things I want to do. How can I do this
CodePudding user response:
Of course, your question is very broad and you have to have a plan for each step. Here is a very accurate and simple method that uses IEnumerator
.
public void Start() => StartCoroutine(Guidence());
Example Guidence:
Now you have to adjust the body of the Guidance with consecutive conditions, remember that access to different conditions is not always easy. But in general the delegate have to return a bool in WaitUntil
.
public IEnumerator Guidence() // E.g guidence
{
Debug.Log("Click on map button watch the map.");
anim.SetTrigger("Flash_Help_1");
mapButton.interactable = true;
yield return new WaitUntil(() => mapButtonClicked);
Debug.Log("Good Job!.");
mapButton.interactable = false;
anim.SetTrigger("Map_Open");
yield return new WaitForSeconds(5f);
anim.SetTrigger("Flash_Help_2");
settingsButton.interactable = true;
Debug.Log("Here is settings button. with setting button you can adjust game settings..");
yield return new WaitUntil(() => settingButtonClicked);
Debug.Log("Good job.");
// do more...
}
Extra
Some conditions, such as hitting one of the input keys, will simply work with () => Input.GetKeyDown
. Some conditions, such as reaching a certain point, can also be applied with Vector3.Distance < distance
. But clicking on the UI buttons requires the following combination.
public bool mapButtonClicked;
public bool settingButtonClicked;
public void Start()
{
mapButton.onClick.AddListener(() => mapButtonClicked = true);
settingsButton.onClick.AddListener(() => settingButtonClicked = true);
StartCoroutine(Guidence());
}