Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerator loadSpriteImageFromUrl( string URL, ARPlaneAnchor anchor ){
- WWW www = new WWW(URL);
- while (!www.isDone)
- {
- Debug.Log("Download image on progress" + www.progress);
- yield return null;
- }
- if (!string.IsNullOrEmpty(www.error))
- {
- Debug.Log("Download failed");
- }
- else
- {
- GameObject clone = GameObject.CreatePrimitive(PrimitiveType.Plane);
- clone.transform.position = UnityARMatrixOps.GetPosition (anchor.transform);
- clone.transform.rotation = UnityARMatrixOps.GetRotation (anchor.transform);
- clone.transform.localScale = new Vector3(anchor.extent.x * 0.1f ,anchor.extent.y * 0.1f ,anchor.extent.z * 0.1f );
- clone.transform.localPosition = new Vector3(anchor.center.x,anchor.center.y,-anchor.center.z);
- Texture2D texture =new Texture2D(128,128,TextureFormat.RGBA32,false);
- www.LoadImageIntoTexture(texture);
- MeshRenderer m = clone.GetComponent<MeshRenderer>();
- m.material.mainTexture = texture;
- }
Add Comment
Please, Sign In to add comment