- Home /
This question was
closed May 24, 2019 at 03:35 AM by
DoctorChar for the following reason:
The question is answered, right answer was accepted
Question by
DoctorChar · Apr 25, 2017 at 12:13 AM ·
uionclickvoidbroadcastmessagebroadcast
OnClickUpAsButton used externaly
How do I tell my player that my UI image has been clicked?
This is a question that can be solved two ways:
a) Broadcasting
Here is my attempt:
My "buttons" script I sadly deleted in rage so basically it needs to broadcast to ShieldReciever to function!
My players inventory script:
void FixedUpdate()
{
if (Input.GetKeyDown("i"))
{
IsCrafting = true;
}
if (IsCrafting == true)
{
a.SetActive(false);
b.SetActive(false);
c.SetActive(false);
d.SetActive(false);
}
if (IsCrafting == false)
{
a.SetActive(true);
b.SetActive(true);
c.SetActive(true);
d.SetActive(true);
Shield.SetActive(false);
ShieldInput.SetActive(false);
}
if (Input.GetKeyDown("i"))
{
IsCrafting = true;
}
if (IsCrafting == true)
{
Crafter();
}
}
void Crafter()
{
if (WoodAmount > 2)
{
if (GoblinScalesAmount > 0)
{
if (ShieldBought == false)
{
Shield.SetActive(true);
ShieldInput.SetActive(true);
if (ShieldIsPushed == true)
{
WoodAmount = WoodAmount - 2;
GoblinScalesAmount = GoblinScalesAmount - 1;
ShieldBought = true;
}
}
}
}
}
void ShieldReciever()
{
ShieldIsPushed = true;
}
b) A function I do know about
If there are any please tell me!
Thanks!
Comment