- Home /
Question by
sinoobkt · Apr 14, 2020 at 07:38 PM ·
c#methodif statementbooleansprograming
I am referring a bool function from other script and i am checking with in if condition , but it is not working? can anyone can help me?
//First script
public bool ActivatePlayers()
{
GameObject Test = GameObject.FindWithTag("Magentos");
if (Test.activeSelf == true)
{
isActive = true;
return isActive;
}
return isActive;
}
//Second script
if (PlayersItems.Instance.ActivatePlayers())
{
foreach (PlayersItems i in Planes)
{
GameObject o = Instantiate(Buy, BuyChoosePanel.transform.position, Quaternion.identity);
o.transform.GetChild(0).GetComponent<Text>().text = i.Cost.ToString();
o.transform.SetParent(BuyChoosePanel.transform);
o.transform.GetComponent<Button>().onClick.AddListener(delegate {
MakePurchase(i.Name, i.Cost); });
// o.transform.GetComponent<Button>().onClick.AddListener(delegate { BGitemDisplay(); });
}
}
Comment
You have to explain in more detail what result you expect and what happens. Everything looks more or less correct, tho there are some red-ish flags as far as possible mistakes go.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Setting variable when method called 1 Answer
C# Health Bar 1 Answer