mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 05:07:08 +01:00 
			
		
		
		
	ResourceText
This commit is contained in:
		
							
								
								
									
										35
									
								
								Assets/Scripts/ResourceUiTextScript.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Assets/Scripts/ResourceUiTextScript.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
| using UnityEngine.UI; | ||||
|  | ||||
| public class ResourceUiTextScript : MonoBehaviour | ||||
| { | ||||
|     private ResourceManager resourceManager; | ||||
|  | ||||
|  | ||||
|     private string str = ""; | ||||
|     private TMPro.TextMeshProUGUI textResource; | ||||
|  | ||||
|     private void Start() | ||||
|     { | ||||
|         resourceManager = GameObject.Find("GameManager").GetComponent<ResourceManager>(); | ||||
|         textResource = GetComponent<TMPro.TextMeshProUGUI>(); | ||||
|     } | ||||
|     void Update() | ||||
|     { | ||||
|         List<Item> inventory = new List<Item>(); | ||||
|         inventory = resourceManager.GetAllResources(); | ||||
|         str = ""; | ||||
|         foreach(Item i in inventory) | ||||
|         { | ||||
|             if(i != null) | ||||
|             { | ||||
|                 str += i.count.ToString() + " " + i.name + "\n"; | ||||
|             } | ||||
|              | ||||
|         } | ||||
|  | ||||
|         textResource.text = str; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 DerTyp187
					DerTyp187