LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/Test/CharacterInfo.cs

70 lines
1.5 KiB
C#
Raw Normal View History

2023-09-24 11:28:47 +08:00
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
2023-09-24 11:28:47 +08:00
namespace UnityTest.ZXL
{
public class CharacterInfo : MonoBehaviour
{
[SerializeField] private ClothingType clothingType;
[SerializeField] private List<ClothingData> list = new List<ClothingData>();
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.HideAll();
2023-09-24 11:28:47 +08:00
}
go.ShowAll();
2023-09-24 11:28:47 +08:00
}
else
{
Debug.LogError($"the info dont have {str}");
}
}
}
[System.Serializable]
public class ClothingData
{
public string name;
[FormerlySerializedAs("go")] public List<GameObject> gos;
public void HideAll()
{
foreach (var gameObject in gos)
{
gameObject.SetActive(false);
}
}
public void ShowAll()
{
foreach (var gameObject in gos)
{
gameObject.SetActive(true);
}
}
2023-09-24 11:28:47 +08:00
}
public enum ClothingType
{
,
,
,
,
,
}
}