加载到纹理上的图像显示为完全白色

时间:2017-11-23 13:13:21

标签: c# image unity3d textures arkit

我正在使用ARKit和Unity将纹理应用于原始平面,

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;
    }

但作为纹理应用的图像是完全白色的,没有颜色。有人可以指出我的错误。我检查了灯光,没有问题。

0 个答案:

没有答案