So hey, how do i do this, so whenever i press a button the inventory would show up and when i press again it would close. Do i use booleans? ive tried this:
Bool = !Bool;
But in this case it doesnt work. Is there any other way of doing this?
So hey, how do i do this, so whenever i press a button the inventory would show up and when i press again it would close. Do i use booleans? ive tried this:
Bool = !Bool;
But in this case it doesnt work. Is there any other way of doing this?
Can you post the actual script? The code snippet you posted there makes no sense. It’s not clear if that’s the exact thing you’ve written or the concept you have used.
It doesnt? Well maybe i should’ve showed you the script earlier. Lol
foreach (Touch touch in Input.touches)
{
Vector3 inputGuiPosition = touch.position;
inputGuiPosition.y = Screen.height - inputGuiPosition.y;
if(Input.touchCount > 0)
{
if(backPabckRect.Contains(inputGuiPosition))
{
ShowInventory = !ShowInventory;
}
}
}
There is no need to iterate through all the touches if the only thing you need is touchCount. Just do:
if(Input.touchCount > 0)
{
if(backPabckRect.Contains(inputGuiPosition))
{
ShowInventory = !ShowInventory;
}
}
In your case you would have to look at phases of the touch here