Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: wangzy_88 on March 03, 2015, 02:21:48 AM

Title: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: wangzy_88 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.  
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: ArenMook on March 03, 2015, 05:41:49 PM
Why are you doing this?

You need to call EditorUtility.ClearProgressBar();
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: wangzy_88 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..."
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: wangzy_88 on March 18, 2015, 03:49:01 AM
I think it's a useful function,help please...
@ArenMook
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: ArenMook 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.
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: wangzy_88 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...
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: ArenMook 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.
Title: Re: Use UIAtlasMaker.AddOrUpdate() and get stuck
Post by: wangzy_88 on March 22, 2015, 08:21:16 PM
Thank you very much,I will post on unity forum.