Hello every body/
i created a script for my game and i use of
(input.getkeymousebuttondown)(0){
image.setactive(true);
}
now!i press pause Button! (and image will set active true!)
i want my pause menu(UI) dont Under the influence of my script!
What should I do?
thanks for helpping…
I’m not sure I understand what you’re asking, but I’ll try. It sounds like you want to pause the game, and show a pause menu? But you don’t want to put the code for the pause menu in the same script?
What you can do is put your pause menu UI/Canvas on a game object, and turn it into a prefab. (In this case, put it in a folder called “Resources”.) This game object can have its own script for managing your pause menu. When you pause the game, instead of “image.setactive(true);”, you can do something like:
var pauseMenu = Resources.Load("MyPauseMenuObject");
Instantiate(pauseMenu);
Sorry if I misunderstood what you’re trying to do.
When I first read this, I thought the OP was saying he has a script that displays an image when the mouse is pressed down. However, when he pushes a button to open the menu, the mouse down is also registered and showing the image, and that is not desired.
If that’s the case, you should check like this:
if(Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) image.SetActive(true);
If you meant something else, sorry If it’s not what @dgoyette said, perhaps you can try to explain it a little better.
Please take a moment to look at this page for how to post code on the forums, nicely formatted and easy to read: Using code tags properly
Please try to re-read your post after you submit and edit any glaring mistakes. (ie: random ‘/’ or ‘!’ in your message lol)
thank you /i will test youre Help!;)
You’re welcome.