mirror of
				https://github.com/DerTyp7/industrialize-unity.git
				synced 2025-10-31 13:27:09 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using UnityEngine;
 | |
| public class MenuManager : MonoBehaviour
 | |
| {
 | |
|     public static void OpenMenu(string id)
 | |
|     {
 | |
|         MenuDictionary.instance.GetEntryById(id).Open();
 | |
|     }
 | |
| 
 | |
|     public static void CloseMenu(string id)
 | |
|     {
 | |
|         MenuDictionary.instance.GetEntryById(id).Close();
 | |
|     }
 | |
| 
 | |
|     public static void ToggleMenu(string id)
 | |
|     {
 | |
|         MenuDictionary.instance.GetEntryById(id).Toggle();
 | |
|     }
 | |
| 
 | |
|     public static void CloseAllMenus()
 | |
|     {
 | |
|         foreach (Menu menu in MenuDictionary.instance.entries)
 | |
|         {
 | |
|             menu.Close();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public static bool AllMenusClosed()
 | |
|     {
 | |
|         foreach (Menu menu in MenuDictionary.instance.entries)
 | |
|         {
 | |
|             if (menu.isOpen)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|         }
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     private void Start()
 | |
|     {
 | |
|         CloseAllMenus();
 | |
|     }
 | |
| 
 | |
|     private void Update()
 | |
|     {
 | |
|         if (Input.GetKeyDown(KeyCode.Escape))
 | |
|         {
 | |
|             CloseAllMenus();
 | |
|         }
 | |
| 
 | |
|         if (Input.GetButtonDown("BuildingMenu"))
 | |
|         {
 | |
|             ToggleMenu("menu_building");
 | |
|         }
 | |
|     }
 | |
| }
 | 
