暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. }