GetMainTexture2D.cs 667 B

12345678910111213141516171819202122232425262728
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5. using UnityEngine.UI;
  6. [ExecuteInEditMode]
  7. public class GetMainTexture2D : MonoBehaviour
  8. {
  9. public string m_url = "";
  10. void Start()
  11. {
  12. string filePath = System.IO.Path.Combine(Application.streamingAssetsPath+"/Main", m_url);
  13. SetWebGLText.Instance.GetTexture(filePath+".png", (Texture2D t2d)=> {
  14. try
  15. {
  16. if (GetComponent<RawImage>())
  17. GetComponent<RawImage>().texture = t2d;
  18. }
  19. catch
  20. {
  21. }
  22. });
  23. }
  24. }