Author Topic: UIAtlas.Coordinates doesn't exist in NGUI 3?  (Read 3130 times)

aikitect

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 27
    • View Profile
UIAtlas.Coordinates doesn't exist in NGUI 3?
« on: December 27, 2013, 10:37:36 AM »
Hello, I am trying to generate an atlas at runtime, and in NGUI <2.7.0, I used the following code:

  1.                 UIAtlas atlas = gameObject.AddComponent("UIAtlas") as UIAtlas;
  2.  
  3.                 yield return StartCoroutine(Assets.DownloadAssetBundle(url, version));
  4.                 AssetBundle bundle = Assets.GetAssetBundle(url, version);
  5.                 AssetBundleRequest pngRequest = bundle.LoadAsync(key, typeof(Texture2D));
  6.                 AssetBundleRequest txtRequest = bundle.LoadAsync(key, typeof(TextAsset));
  7.                 yield return pngRequest.isDone && txtRequest.isDone;
  8.                 Material mat = new Material(Shader.Find("Unlit/Transparent Colored"));
  9.                 mat.mainTexture = pngRequest.asset as Texture2D;
  10.                 atlas.spriteMaterial = mat;
  11.                 atlas.coordinates = UIAtlas.Coordinates.Pixels;
  12.                 atlas.pixelSize = 0.5f;
  13.                 NGUIJson.LoadSpriteData(atlas, txtRequest.asset as TextAsset);
  14.  

However, in NGUI 3, I get a Unity error that states that UIAtlas.Coordinates is protected, and atlas.coordinates does not exist.  Can I just delete that line, or do I need to substitute it with another line?  Also, are there any other changes that need to be made to update the above function?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAtlas.Coordinates doesn't exist in NGUI 3?
« Reply #1 on: December 27, 2013, 04:19:56 PM »
NGUI 3+ works with pixels, not texture coordinates. What is it you're trying to do there? If you're tring to display a downloaded texture, use UITexture not a sprite.