So basically here’s my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QuestUIManager : MonoBehaviour
{
public static QuestUIManager uiManager;
//BOOLS
public bool questAvailable = false;
public bool questRunning = false;
private bool questPanelActive = false;
private bool questLogPanelActive = false;
//PANELS
public GameManager questPanel;
public GameObject questLogPanel;
//QUESTOBJECT
private QuestObject currentQuestObject;
//QUESTLIST
public List<Quest> availableQuests = new List<Quest>();
public List<Quest> activeQuests = new List<Quest>();
//BUTTONS
public GameObject qButton;
public GameObject qLogButton;
private List<GameObject> qButtons = new List<GameObject>();
private GameObject acceptButton;
private GameObject giveUpButton;
private GameObject completeButton;
//SPACER
public Transform qButtonSpacer1;
public Transform qButtonSpacer2;
public Transform qLogButtonSpacer;
//QUEST INFOS
public Text questTitle;
public Text questDescription;
public Text questSummary;
//QUEST LOG INFOS
public Text questLogTitle;
public Text questLogDescription;
public Text questLogSummary;
void Awake()
{
if (uiManager == null)
{
uiManager = this;
}
else if (uiManager != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
HideQuestPanel();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
questLogPanelActive = !questPanelActive;
//Show Quest Logpanel
}
}
// CALLED FORM QUEST OBJECT
public void CheckQuests(QuestObject questObject)
{
currentQuestObject = questObject;
QuestManager.questManager.QuestRequest(questObject);
if ((questRunning || questAvailable) && !questPanelActive)
{
ShowQuestPanel();
}
else
{
Debug.Log("NO QUESTS AVAILABLE");
}
}
//SHOWPANEL
public void ShowQuestPanel()
{
questPanelActive = true;
questPanel.SetActive(questPanelActive);
//FILL IN DATA
FillQuestButtons();
}
//quest Log
//HIDE QUEST PANEL
public void HideQuestPanel()
{
questPanelActive = false;
questAvailable = false;
questRunning = false;
//CLEAR TEXT
questTitle.text = "";
questDescription.text = "";
questSummary.text = "";
//CLEAR LIST
availableQuests.Clear();
activeQuests.Clear();
//CLEAR BUTTON LIST
for (int i = 0; i < qButtons.Count; i++)
{
Destroy(qButtons);
}
qButtons.Clear();
//HIDE PANEL
questPanel.SetActive(questPanelActive);
}
//FILL BUTTONS
void FillQuestButtons()
{
foreach (Quest availableQuest in availableQuests)
{
GameObject questButton = Instantiate(qButton);
QButtonScript qBScript = questButton.GetComponent<QButtonScript>();
qBScript.questID = availableQuest.id;
qBScript.questTitle.text = availableQuest.title;
questButton.transform.SetParent(qButtonSpacer1, false);
qButtons.Add(questButton);
}
foreach (Quest activeQuest in availableQuests)
{
GameObject questButton = Instantiate(qButton);
QButtonScript qBScript = questButton.GetComponent<QButtonScript>();
qBScript.questID = activeQuest.id;
qBScript.questTitle.text = activeQuest.title;
questButton.transform.SetParent(qButtonSpacer2, false);
qButtons.Add(questButton);
}
}
}
I’m trying to do this
Drag the quest panel object onto the quest panel field
Whichever object you want to drag to the slot… make sure it has a GameManager script on it.
I have tried drag it on and it’s not working
Yes, I understood that from your first post. I was asking if the game object that you’re trying to drag into the slot has a script called ‘GameManager’ on it, as that is the slot’s variable type.
Oh sorry no I don’t have any scripts on the object
Well, then it’s impossible to move it.
If it’s just some game object, without a script, change the variable’s type to ‘GameObject’ or ‘Transform’ (whichever is more useful for you).
So I’d just change the QuestPanels codes variable type to gameobject?
I was following this
I skimmed through that video very quickly, but did not see the Game Manager in the video. May have missed it at my speed. lol
Anyways, I’d say try to follow from the part you are or redo it. If you see the author creating a Game Manager script, then maybe you need to add that to the game object. If they do not, then maybe Game Manager was just the name of the game object, but not the type of the variable…
Hopefully if you look over the video again you can find which is which.
methos5k:
I skimmed through that video very quickly, but did not see the Game Manager in the video. May have missed it at my speed. lol
Anyways, I’d say try to follow from the part you are or redo it. If you see the author creating a Game Manager script, then maybe you need to add that to the game object. If they do not, then maybe Game Manager was just the name of the game object, but not the type of the variable…
Hopefully if you look over the video again you can find which is which.
Alright, thank you for the time
Hey so I figured it out like you said it’s to do with the game manager so how would I do this?
Alright I got to here but my canvas now isn’t hiding any ideas?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QuestUIManager : MonoBehaviour
{
public static QuestUIManager uiManager;
//BOOLS
public bool questAvailable = false;
public bool questRunning = false;
private bool questPanelActive = false;
private bool questLogPanelActive = false;
//PANELS
public GameManager questPanel;
public GameObject questLogPanel;
//QUESTOBJECT
private QuestObject currentQuestObject;
//QUESTLIST
public List<Quest> availableQuests = new List<Quest>();
public List<Quest> activeQuests = new List<Quest>();
//BUTTONS
public GameObject qButton;
public GameObject qLogButton;
private List<GameObject> qButtons = new List<GameObject>();
private GameObject acceptButton;
private GameObject giveUpButton;
private GameObject completeButton;
//SPACER
public Transform qButtonSpacer1;
public Transform qButtonSpacer2;
public Transform qLogButtonSpacer;
//QUEST INFOS
public Text questTitle;
public Text questDescription;
public Text questSummary;
//QUEST LOG INFOS
public Text questLogTitle;
public Text questLogDescription;
public Text questLogSummary;
void Awake()
{
if (uiManager == null)
{
uiManager = this;
}
else if (uiManager != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
HideQuestPanel();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
questLogPanelActive = !questPanelActive;
//Show Quest Logpanel
}
}
// CALLED FORM QUEST OBJECT
public void CheckQuests(QuestObject questObject)
{
currentQuestObject = questObject;
QuestManager.questManager.QuestRequest(questObject);
if ((questRunning || questAvailable) && !questPanelActive)
{
ShowQuestPanel();
}
else
{
Debug.Log("NO QUESTS AVAILABLE");
}
}
//SHOWPANEL
public void ShowQuestPanel()
{
questPanelActive = true;
questPanel.SetActive(questPanelActive);
//FILL IN DATA
FillQuestButtons();
}
//quest Log
//HIDE QUEST PANEL
public void HideQuestPanel()
{
questPanelActive = false;
questAvailable = false;
questRunning = false;
//CLEAR TEXT
questTitle.text = "";
questDescription.text = "";
questSummary.text = "";
//CLEAR LIST
availableQuests.Clear();
activeQuests.Clear();
//CLEAR BUTTON LIST
for (int i = 0; i < qButtons.Count; i++)
{
Destroy(qButtons[i]);
}
qButtons.Clear();
//HIDE PANEL
questPanel.SetActive(questPanelActive);
}
//FILL BUTTONS
void FillQuestButtons()
{
foreach (Quest availableQuest in availableQuests)
{
GameObject questButton = Instantiate(qButton);
QButtonScript qBScript = questButton.GetComponent<QButtonScript>();
qBScript.questID = availableQuest.id;
qBScript.questTitle.text = availableQuest.title;
questButton.transform.SetParent(qButtonSpacer1, false);
qButtons.Add(questButton);
}
foreach (Quest activeQuest in availableQuests)
{
GameObject questButton = Instantiate(qButton);
QButtonScript qBScript = questButton.GetComponent<QButtonScript>();
qBScript.questID = activeQuest.id;
qBScript.questTitle.text = activeQuest.title;
questButton.transform.SetParent(qButtonSpacer2, false);
qButtons.Add(questButton);
}
}
}
Well, you may have missed something from the tutorial, or maybe it made a mistake that’s later corrected.
This is just a guess, but after you set your bool, you don’t actually use it. Maybe you want this:
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
questLogPanelActive = !questPanelActive;
//Show Quest Logpanel
questLogPanel.SetActive(questLogPanelActive);
}
}
methos5k:
Well, you may have missed something from the tutorial, or maybe it made a mistake that’s later corrected.
This is just a guess, but after you set your bool, you don’t actually use it. Maybe you want this:
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
questLogPanelActive = !questPanelActive;
//Show Quest Logpanel
questLogPanel.SetActive(questLogPanelActive);
}
}
I’ve added that just now I’m not sure what it’s supposed to do?
Make sure it replaced your old Update method.
Well, I’m not sure if it’s right, either. Remember, just because you’re watching that tutorial… I have no idea what’s in it. You said something was appearing/hiding, so I thought maybe that was it.
If you meant to point out another section or game object, please let me know…
methos5k:
Make sure it replaced your old Update method.
Well, I’m not sure if it’s right, either. Remember, just because you’re watching that tutorial… I have no idea what’s in it. You said something was appearing/hiding, so I thought maybe that was it.
If you meant to point out another section or game object, please let me know…
Basically I want the canvas to be hidden and only appear on once space has been pressed in the box collider but of course at the moment my canvas is constantly on the screen
I also have encounted this error
Okay, you have lost me a little bit.
You have the Update method checking for the key ‘Q’… at first I thought you were talking about that.
Never mind, though, as I see there are 2 methods there.
So, maybe those are supposed to be connected to the OnClick events from buttons you have in your scene.
Just remove the code I posted before, and keep following along the tutorial. I opened the youtube page, and it shows a number of videos. Hopefully they are all working. Try to find the answer there, and if you’re really stuck create a question here.
Alrighty thank you, I’m on the last one I’ll then let you know if I encounter any problems
So I still have the problem, I want to make it so when the game is started you can’t see the canvas so it’s hidden
When you say canvas, do you mean: questPanel? or something else?