No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MidLevelLoadManager.cs 758B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. public class MidLevelLoadManager : MonoBehaviour
  3. {
  4. [Tooltip("How many Vegetation objects in percent(%) to enable at the start of the test(DISABLED)")]
  5. [Range(0, 100)]
  6. public float startingLoadAmount = 100;
  7. public Transform Vegetation;
  8. public void SetLoad(float loadAmount)
  9. {
  10. startingLoadAmount = loadAmount;
  11. foreach (Transform veg in Vegetation)
  12. {
  13. veg.gameObject.SetActive(false);
  14. }
  15. int vegetationCount = Vegetation.childCount;
  16. int percentageAmount = Mathf.FloorToInt((vegetationCount / 100.0f) * loadAmount);
  17. for (int i = 0; i < percentageAmount; i++)
  18. {
  19. Vegetation.GetChild(i).gameObject.SetActive(true);
  20. }
  21. }
  22. }