Guest User

Untitled

a guest
Nov 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. IEnumerator loadSpriteImageFromUrl( string URL, ARPlaneAnchor anchor ){
  2. WWW www = new WWW(URL);
  3. while (!www.isDone)
  4. {
  5. Debug.Log("Download image on progress" + www.progress);
  6. yield return null;
  7. }
  8.  
  9. if (!string.IsNullOrEmpty(www.error))
  10. {
  11. Debug.Log("Download failed");
  12. }
  13. else
  14. {
  15. GameObject clone = GameObject.CreatePrimitive(PrimitiveType.Plane);
  16. clone.transform.position = UnityARMatrixOps.GetPosition (anchor.transform);
  17. clone.transform.rotation = UnityARMatrixOps.GetRotation (anchor.transform);
  18. clone.transform.localScale = new Vector3(anchor.extent.x * 0.1f ,anchor.extent.y * 0.1f ,anchor.extent.z * 0.1f );
  19. clone.transform.localPosition = new Vector3(anchor.center.x,anchor.center.y,-anchor.center.z);
  20. Texture2D texture =new Texture2D(128,128,TextureFormat.RGBA32,false);
  21. www.LoadImageIntoTexture(texture);
  22. MeshRenderer m = clone.GetComponent<MeshRenderer>();
  23. m.material.mainTexture = texture;
  24. }
Add Comment
Please, Sign In to add comment