well, it’s a simple game, although I know in Game Maker, here in Unity things are completely different…
I just wanted to know how I could hide this inventory screen when you press J/C, as it seems to be very different from hiding an element/object/sprite
I have a script called inv_visible, which was attached to the gameobject inventory, in Hierarchy, that can controll the visibility of inv
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inv_visible : MonoBehaviour
{
public GameObject pic;
public void Trigger()
{
if (pic.activeInHierarchy == false && Input.GetKeyDown(KeyCode.F))
{
pic.SetActive(true);
}
else
{
pic.SetActive(false);
}
}
}
note: Inventory is a Canvas, and it has warnings like this because my laptop is weak.
Sorry for the big text.
You have to use Update function and write your code inside it. The Update function gets called by unity every frame. Check out this page from Unity’s documentation for more info.
It worked,
and thanks to one thing I forgot it MUST be called
Thanks, and I adjusted the code too
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using player;
namespace inventorys
{
public class inv_visible : MonoBehaviour
{
[SerializeField]
public GameObject pic;
private bool is_enabled = false;
public void Trigger()
{
if (pic.activeInHierarchy == false && Input.GetKeyDown(KeyCode.F)) //if press F (inventory)
{
is_enabled = true; //enabled
}
else if (pic.activeInHierarchy == true && Input.GetKeyDown(KeyCode.F)) //if press F (inventory)
{
is_enabled = false; //disabled
}
if (is_enabled == false) //if disabled
{
pic.SetActive(false); //set to the active = true
}
else if (is_enabled == true) //if enabled
{
pic.SetActive(true); //set to the active = true
}
void Update()
{
Trigger(); //trigger the input
}
}
}
Hmmmmmmm i see
This could be very useful not only in this game, but also in my Rain World mod
Except for the fact that I tend to explain everything with a comment, due to forgetfulness
I can see
Really thank you :)
The warnings have nothing to do with your laptop. The first message is just alerting you that more channels are enabled than may be required, and the second that you’re in one color mode and the canvas is defaulting to the other color mode which may cause incorrect colors.