GetTexture2D.cs 721 B

1234567891011121314151617181920212223242526272829
  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 GetTexture2D : MonoBehaviour
  8. {
  9. public static string urlbase = "DeMa";
  10. public string m_url = "";
  11. void Start()
  12. {
  13. string filePath = System.IO.Path.Combine(Application.streamingAssetsPath+"/"+ urlbase, m_url);
  14. SetWebGLText.Instance.GetTexture(filePath+".png", (Texture2D t2d)=> {
  15. try
  16. {
  17. if (GetComponent<RawImage>())
  18. GetComponent<RawImage>().texture = t2d;
  19. }
  20. catch
  21. {
  22. }
  23. });
  24. }
  25. }