Пример #1
0
    private void SetResourceUI(GameObject obj, ResourceType type)
    {
        ResourceUI resourceUI = obj.GetComponent <ResourceUI>();

        if (resourceUI == null)
        {
            Debug.LogError("Prefab for type " + type + " did not have ResourceUI component");
            return;
        }

        resourceUI.SetResource(type);
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (unit != null && resourceUI != null)
     {
         transform.position = Camera.main.WorldToScreenPoint(unit.transform.position);
         if (unit.CarriedResourceType != ResourceTypes.NONE && unit.CarriedResourceAmount > 0)
         {
             resourceUI.gameObject.SetActive(true);
             resourceUI.SetResource(unit.CarriedResourceType, unit.CarriedResourceAmount.ToString());
         }
         else
         {
             resourceUI.gameObject.SetActive(false);
         }
     }
 }