ImgDisplay.cs 988 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.IO;
  3. using UnityEngine;
  4. public class ImgDisplay : MonoBehaviour
  5. {
  6. private void Start()
  7. {
  8. string str = UTY.gameProjectPath + "\\";
  9. string text = str + "Img";
  10. bool flag = false;
  11. if (Directory.Exists(text))
  12. {
  13. string text2 = text + "\\" + this.m_strFileName;
  14. if (File.Exists(text2))
  15. {
  16. byte[] array = UTY.LoadImage(text2);
  17. if (array != null)
  18. {
  19. Texture2D texture2D = new Texture2D(1, 1);
  20. if (texture2D.LoadImage(array) && this.m_mrTargetMaterial != null)
  21. {
  22. Material material = this.m_mrTargetMaterial.material;
  23. if (material != null)
  24. {
  25. material.SetTexture("_MainTex", texture2D);
  26. }
  27. flag = true;
  28. }
  29. }
  30. }
  31. }
  32. if (!flag && this.m_bMeshHideWhenInvalid && this.m_mrTargetMaterial != null)
  33. {
  34. this.m_mrTargetMaterial.enabled = false;
  35. }
  36. }
  37. public string m_strFileName = "display.png";
  38. public MeshRenderer m_mrTargetMaterial;
  39. public bool m_bMeshHideWhenInvalid;
  40. }