0
\$\begingroup\$

I am new to Game Dev and I am following a Tutorial. Within this tutorial, we create a quest system, that allows you to accept or decline a quest. This tutorial is based on Unity 5 and I am using 2020.1 so there could be version differences that could be causing the issue.

I have a script called:

Quest001Buttons.cs

public class Quest001Buttons : MonoBehaviour {
    public GameObject ThePlayer;
    public GameObject NoticeCam;
    public GameObject UIQuest;
    public GameObject ActiveQuestBox;
    public GameObject Objective01;
    public GameObject Objective02;
    public GameObject Objective03;

    public void AcceptQuest() {
        Debug.Log("Accept Registered");
        ThePlayer.SetActive(true);
        NoticeCam.SetActive(false);
        UIQuest.SetActive(false);
        StartCoroutine(SetQuestUi());
    }

    IEnumerator SetQuestUi() {

        ActiveQuestBox.GetComponent<Text>().text = "My First Weapon";
        Objective01.GetComponent<Text>().text = "Reach the Clearing";
        Objective02.GetComponent<Text>().text = "Open Chest";
        Objective03.GetComponent<Text>().text = "Get Weapon";
        QuestManager.ActiveQuestNumber = 1;
        yield return new WaitForSeconds(0.5f);
        ActiveQuestBox.SetActive(true);
        yield return new WaitForSeconds(1);
        Objective01.SetActive(true);
        yield return new WaitForSeconds(0.5f);
        Objective02.SetActive(true);
        yield return new WaitForSeconds(0.5f);
        Objective03.SetActive(true);
        yield return new WaitForSeconds(9);
        ActiveQuestBox.SetActive(false);
        Objective01.SetActive(false);
        Objective02.SetActive(false);
        Objective03.SetActive(false);

    }
}

I have an Empty GameObject called "QuestButtonManager" which I have assigned the above script to. I also have a UI GamObject called "Accept" and I have attached the QuestButtonManager GameObject to the OnClick() Event within that component. I have selected: "Runtime Only" and the function of "Quest001Buttons.AcceptQuest".

When I run the game and press the Accept Button...the game seems to not function after that and is stuck on that screen, with the button highlighted...not even the Debug.Log text is printed in the console.

Any help is greatly appreciated before I give it up and look for a more updated version to learn on.

\$\endgroup\$
4
  • \$\begingroup\$ That video is over a half hour long. Can you point us to the section which is actually relevant for this question? YouTube allows you to create a link to the middle of a video by right-clicking and selecting "copy video URL at this position". \$\endgroup\$ Commented Nov 16, 2020 at 15:10
  • \$\begingroup\$ Here is the link to the point where I was following along and did not get the same result [link] (youtu.be/…) \$\endgroup\$ Commented Nov 16, 2020 at 16:28
  • \$\begingroup\$ Is your button in a Canvas? Is there an EventSystem in the scene? Did you do anything with the default setting of either which could break things? \$\endgroup\$ Commented Nov 16, 2020 at 17:31
  • \$\begingroup\$ @Philipp The button is within a canvas. There is an EventSystem, but not sure what the defaults are supposed to be. The Event System does not have a GameObject assigned to "First Selected" . It also has "Standalone Input Module" component, with carious axis etc...but no idea what this is \$\endgroup\$ Commented Nov 16, 2020 at 17:50

1 Answer 1

0
\$\begingroup\$

After trying to resolve the issue and to understand why it was doing what it was doing. I removed the script component, copied the code within and deleted the script. I closed down VS2019 and created a new script, pasted the code and re-added the component.

I did try to Remove the component and re-add first, but that had no affect.

Not sure why closing down VS2019 and re-creating the script worked, perhaps VS2019 was returning a cached script and did not have the full code..though it was showing the correct code in the inspector.

If anyone else has a similar issue, it maybe the integration of VS2017/2019 with Unity that could cause issues.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.