1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.IO;
- using UnityEngine;
- public class ImgDisplay : MonoBehaviour
- {
- private void Start()
- {
- string fullPath = Path.GetFullPath(".\\");
- string text = fullPath + "Img";
- bool flag = false;
- if (Directory.Exists(text))
- {
- string text2 = text + "\\" + this.m_strFileName;
- if (File.Exists(text2))
- {
- byte[] array = UTY.LoadImage(text2);
- if (array != null)
- {
- Texture2D texture2D = new Texture2D(1, 1);
- if (texture2D.LoadImage(array) && this.m_mrTargetMaterial != null)
- {
- Material material = this.m_mrTargetMaterial.material;
- if (material != null)
- {
- material.SetTexture("_MainTex", texture2D);
- }
- flag = true;
- }
- }
- }
- }
- if (!flag && this.m_bMeshHideWhenInvalid && this.m_mrTargetMaterial != null)
- {
- this.m_mrTargetMaterial.enabled = false;
- }
- }
- public string m_strFileName = "display.png";
- public MeshRenderer m_mrTargetMaterial;
- public bool m_bMeshHideWhenInvalid;
- }
|