Search Unity

[Windows Universal 8.1] Invalid Geometry when loading remote image

Discussion in 'Windows' started by kujo, Sep 28, 2015.

  1. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    I've just upgraded my game to Unity 5.2 from 4.6.7 and I have a problem when loading images remotely from Facebook on both Windows Phone 8.1 and also on Desktop/Tablet

    The only error that I see in the output log is:

    Code (csharp):
    1. PxShape::setGeometry(): Invalid geometry!
    The code I use to set this up is as follow:

    Code (csharp):
    1.  
    2. public void SetImage(Texture2D tex)
    3.  {
    4.   CreateImage();
    5.  
    6.  _image.GetComponent<Renderer>().material.mainTexture = tex;
    7.  _image.transform.localScale = GetScale(tex);
    8.  if (this.GetComponent<Renderer>() != null)
    9.  this.GetComponent<Renderer>().enabled = false;
    10.  
    11.  }
    12.  private void CreateImage()
    13.  {
    14.  if (this._image == null)
    15.  {
    16.  _image = (GameObject)GameObject.CreatePrimitive(PrimitiveType.Plane);
    17.  _image.layer = this.gameObject.layer;
    18.  _image.transform.parent = this.gameObject.transform;
    19.  _image.transform.localPosition = new Vector3(0, 0, -0.1f);
    20.  _image.transform.localRotation = Quaternion.Euler(new Vector3(90, 180, 0));
    21.  _image.transform.localScale = Vector3.zero;
    22.  }
    23.  else
    24.  {
    25.  _image.SetActive(true);
    26.  }
    27.  }
    28.  
    29. private Vector3 GetScale(Texture2D image)
    30.  {
    31.  float wRatio;
    32.  float hRatio;
    33.  
    34.  if (image.width >= image.height)
    35.  {
    36.  wRatio = scale / image.width;
    37.  hRatio = scale / image.height;
    38.  }
    39.  else
    40.  {
    41.  wRatio = scale / image.width;
    42.  hRatio = scale / image.height;
    43.  }
    44.  
    45.  float resizeRatio = Mathf.Min(wRatio, hRatio);
    46.  
    47.  return new Vector3(image.width * resizeRatio, image.height * resizeRatio, image.height * resizeRatio);
    48.  }
    49.  
    It seems like its happening as soon as the primitive plane is created, so doesn't seem to have anything to do with the resizing stuff that I do. When the code finishes executing, I'm left with a pink box. This code works fine in the Windows UnityEditor and on iOS and Android.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    1,959
    What material are you using on the mesh? If it's the default one, try setting a custom one
     
  3. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    Yeah, its just what ever comes on the CreatePrimitive mesh. Looking at it in the editor, its an instance of the standard shader, with the texture set on the Albedo property.

    I'll try setting a custom one and see what it does.
     
  4. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    Yep - that fixed it. I used a legacy diffuse shader on it (what it was previously I guess) and its working fine. I still see that invalid geometry error, but it displays correctly.