- Home /
Open up a dialogue window via right click
What I want to do is when you right click on a selection, instantiated from a prefab and list, it will bring up a window and ask if you want to do a certain action, then click yes or no buttons. No matter what I do, I can't seem to get a reference. I thought if I moved the open window script to its own script, that would fix it, only it still says unassigned reference or null reference.
Scripts:
public Canvas DialogueCanvas;
public bool windowOpen=false;
public bool DialogueOpen=false;
public void OpenDialogWindow()
{
if(windowOpen==false)
{
windowOpen=true;
DialogueCanvas.enabled = true;
}
else if(windowOpen==true)
{
windowOpen=false;
DialogueCanvas.enabled=false;
}
}
This is attached to the dialogue canvas
public Canvas DialogueCanvas;
public DialogueWindow DW;
public void ClickRight()
{
//DBIndexList.Clear ();
Debug.Log ("You clicked Right!");
DW = DialogueCanvas.GetComponent<DialogueWindow> ();
DW.OpenDialogWindow ();
}
This is attached to the prefab.
When I try to drag the canvas over, it won't let me attach it. Where am I going wrong? Since this is a delete operation, I'd like to have a dialogue, just in case. Thanks guys!
Answer by Menyus777 · Jul 18, 2017 at 10:57 AM
I Advise you to not make a Canvas but to Make Panels, but if u stick to canvas do the folliwing.
public GameObject DialogueCanvas;
int latter in your code :
DailogueCanvas.setactive(true);
So you attach gameobjects not Canvas panel etc when u want to active and disable a text, a panel, an image a Canvas etc...
and use this setactive function
I guess u already have a canvas why would you make another one then?
Also u can still use a Canvas if u stick to it, and in some cases it is even necessary
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Prefab Variables Problem 0 Answers