using System.Collections.Generic; using UnityEngine; namespace UnityTest.ZXL { public class CharacterInfo : MonoBehaviour { [SerializeField] private ClothingType clothingType; [SerializeField] private List list = new List(); public void SetCloth(string str) { ClothingData go = null; foreach (var data in list) { if (data.name == str) { go = data; } } if (go != null) { foreach (var clothingData in list) { clothingData.go.SetActive(false); } go.go.SetActive(true); } else { Debug.LogError($"the info dont have {str}"); } } } [System.Serializable] public class ClothingData { public string name; public GameObject go; } public enum ClothingType { 衣服, 呼吸器, 头盔, 手套, 鞋子, } }