using System; using System.Collections.Generic; using jeanf.validationTools; using UnityEngine; public class SwapHands : MonoBehaviour { [SerializeField] public HandType handType; [Space(20)] [Validation("The hand renderers list is required — SetHands has no SkinnedMeshRenderer to re-skin without it.")] [SerializeField] private List hands; [SerializeField] private List handTypes; [Serializable] public struct Hand { public HandType handType; public Mesh mesh; public Material skinMaterial; public Material nailMaterial; } public enum HandType { WhiteSkin_Male = 0, WhiteSkin_Female = 1, LightBrownSkin_Male = 2, LightBrownSkin_Female = 3, DarkBrownSkin_Male = 4, DarkBrownSkin_Female = 5, DarkSkin_Male = 6, DarkSkin_Female = 7, HandWithGlove_Male = 8, HandWithGlove_Female = 9 } private HandType _handType { get => handType; set { handType = value; SetHands(value); } } public void OnValidate () { _handType = handType; } public void SetHands(HandType handType) { foreach (var h in handTypes) { if (h.handType != handType) continue; foreach (var hand in hands) { hand.sharedMesh = h.mesh; hand.sharedMaterial = h.skinMaterial; } } } }