Author Topic: Use UIAtlasMaker.AddOrUpdate() and get stuck  (Read 3710 times)

wangzy_88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Use UIAtlasMaker.AddOrUpdate() and get stuck
« on: March 03, 2015, 02:21:48 AM »
I use UIAtlasMaker.AddOrUpdate() in AssetPostprocessor,but after i import texture unity get stuck,progressbar can't close.
  1. void OnPostprocessTexture(Texture2D texture)
  2.     {
  3.         string dir = Path.GetDirectoryName(assetPath);
  4.         string dirName = new DirectoryInfo(dir).Name;
  5.         KNGUIUtils.atlasType atlas = (KNGUIUtils.atlasType)System.Enum.Parse(typeof(KNGUIUtils.atlasType), dirName);
  6.         if (dir.Contains(KNGUIUtils.SpritePath) && !KNGUIUtils.IsSpriteInAtlas(texture.name, atlas))
  7.         {
  8.             TextureImporter importer = assetImporter as TextureImporter;
  9.             importer.textureType = TextureImporterType.Advanced;
  10.             importer.isReadable = true;
  11.             importer.npotScale = TextureImporterNPOTScale.None;
  12.             importer.mipmapEnabled = false;
  13.             importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
  14.             importer.anisoLevel = 0;
  15.             UIAtlasMaker.AddOrUpdate(KNGUIUtils.GetAtlas(atlas), texture);
  16.         }
  17.     }
  18.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #1 on: March 03, 2015, 05:41:49 PM »
Why are you doing this?

You need to call EditorUtility.ClearProgressBar();

wangzy_88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #2 on: March 09, 2015, 04:12:26 AM »
thx,I want to auto import texture to atlas by AssetPostprocessor :)
I try it, it close one progressbar about importing and now stuck on "Updating the atlas, please wait..."
« Last Edit: March 09, 2015, 04:18:45 AM by wangzy_88 »

wangzy_88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #3 on: March 18, 2015, 03:49:01 AM »
I think it's a useful function,help please...
@ArenMook

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #4 on: March 19, 2015, 06:28:40 AM »
ClearProgressBar() clears it, it's a Unity command. Updating the atlas line happens in UIAtlasMaker line 641. As you can see it calls EditorUtility.DisplayProgressBar. EditorUtility.ClearProgressBar() closes it as I mentioned.

If yours doesn't close, call it again or something. Figure out why your progress bar is showing up again by adding a Debug.Log at line 641.

wangzy_88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #5 on: March 20, 2015, 10:12:23 PM »
I add log and retry,first time throw an error;second time don't throw error and add the image to atlas' texture,but atlas don't have the image's info.I don't add EditorUtility.ClearProgressBar() both and the progressBar auto close...
Attachments are screenshots,unity 5.0f4,ngui 3.8.0.The atlas's texture is readable but throw not readable error,I don't know why...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #6 on: March 22, 2015, 08:02:14 AM »
I don't know enough about asset post processing to be of further help here unfortunately. You will need to ask Unity as this is not an NGUI question to begin with.

wangzy_88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
« Reply #7 on: March 22, 2015, 08:21:16 PM »
Thank you very much,I will post on unity forum.