How can I create a walkthrough guidance in Unity?

80 views Asked by At

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?

1

There are 1 answers

0
KiynL On BEST ANSWER

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 Guidance:

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 Guidance() // E.g., guidance
{
    Debug.Log("Click on the map button to 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 the settings button. With the setting buttons, 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());
}