NpcTextureChanger.cs 686 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using WebTools.Customizes.Behaviours;
  5. public class NpcTextureChanger : MonoBehaviour
  6. {
  7. [SerializeField]
  8. public SkinnedMeshRenderer mesh;
  9. [SerializeField]
  10. public Texture texture;
  11. [SerializeField]
  12. public string materialPropertyId= "_MainTex";
  13. [SerializeField]
  14. public List<string> materialColorIds;
  15. [SerializeField]
  16. public Color color;
  17. private void OnEnable()
  18. {
  19. mesh.material.SetTexture(materialPropertyId, texture);
  20. foreach(string colorId in materialColorIds)
  21. {
  22. mesh.material.SetColor(colorId, color);
  23. }
  24. }
  25. }