ReadTextureFromList.cs 896 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ReadTextureFromList : MonoBehaviour
  5. {
  6. public bool isVirus;
  7. public List<Texture2D> TextureList;
  8. public int IndexTexture;
  9. const float SPERM_SCALE_FACTOR = .5f;
  10. static float scaleFactor = SPERM_SCALE_FACTOR;
  11. void Start()
  12. {
  13. if(!isVirus)
  14. {
  15. TextureList = TextureManager.Instance.ListTexturesSpermsCelebrity;
  16. }
  17. Init();
  18. }
  19. public void Init()
  20. {
  21. Material m = GetComponent<Renderer>().material;
  22. m.mainTexture = TextureList[IndexTexture];
  23. //m.mainTextureScale = new Vector2(TextureList[IndexTexture].width, TextureList[IndexTexture].height);
  24. transform.localScale = new Vector3(TextureList[IndexTexture].width * scaleFactor, TextureList[IndexTexture].height * scaleFactor);
  25. }
  26. }