Hello,
I’m posting here because I’m still in the learning phase and would like to have your point of view. In my project, I started to use the new input manager system. I have a script “Player Movement” which is attached to my Player GameObject. In this script, I set all the Inputs of the players as well as the movements (It is a 2D game). I created a SerializedField to insert the GameObject I would like to toggle on and off (to show or hide the canvas of Inventory) the same way you do in the ShowHideUI script.
In the Input manager I create a key bind called PressStart. The Goal is to toggle the Inventory by pressing Start button of the pad (which I can define in the input manager)
My question is, is it a good practice, to add the toggle in the OnPressStart method in my player movement instead of ShowHideUI script ?
It does work but I wonder if there is something I might break later on by doing this way or if it is a good habit to add all inputs related method in one single file. I’m beginner and try to grasp the best coding practices.
public class PlayerMovements : MonoBehaviour
{
[SerializeField] private GameObject inventoryReference;
private void OnPressStart()
{
inventoryReference.SetActive(!inventoryReference.activeSelf);
}
}
(I didn’t put the full content of my scripts only the part that is matter.)
Thanks