private bool Pack(int size) { int num = 0; int num2 = 0; int num3 = 0; int num4 = this.padding; Vector2 zero = Vector2.zero; DictionaryView <int, AtlasInfo.UVDetail> dictionaryView = new DictionaryView <int, AtlasInfo.UVDetail>(); DictionaryView <int, AtlasInfo.UVDetail> .Enumerator enumerator = this.textures.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <int, AtlasInfo.UVDetail> current = enumerator.Current; int width = current.get_Value().width; KeyValuePair <int, AtlasInfo.UVDetail> current2 = enumerator.Current; int height = current2.get_Value().height; AtlasInfo.UVDetail uVDetail = new AtlasInfo.UVDetail(); uVDetail.rotate = false; DictionaryView <int, AtlasInfo.UVDetail> dictionaryView2 = dictionaryView; KeyValuePair <int, AtlasInfo.UVDetail> current3 = enumerator.Current; dictionaryView2.Add(current3.get_Key(), uVDetail); if (num3 + height + num4 <= size && num2 + width + num4 <= size) { uVDetail.x = num2; uVDetail.y = num3; uVDetail.width = width; uVDetail.height = height; num3 += height + num4; if (num < num2 + width + num4) { num = num2 + width + num4; } } else { if (num + width > size || height > size) { return(false); } num2 = num; uVDetail.x = num2; uVDetail.y = 0; uVDetail.width = width; uVDetail.height = height; num3 = height + num4; num = num2 + width + num4; } } TextureFormat textureFormat = TextureFormat.ARGB32; if (this.needCompress) { textureFormat = TextureFormat.ARGB32; } Texture2D texture2D = new Texture2D(size, size, textureFormat, false); Color[] pixels = new Color[texture2D.width * texture2D.height]; texture2D.SetPixels(pixels); texture2D.name = string.Concat(new object[] { "Auto_UI3D_Atlas_", size, "_", this.counter, "_format", textureFormat.ToString() }); this.counter++; enumerator.Reset(); while (enumerator.MoveNext()) { Texture2D texture2D2 = null; Dictionary <int, Texture2D> dictionary = this.waitForCombineTextures; KeyValuePair <int, AtlasInfo.UVDetail> current4 = enumerator.Current; if (!dictionary.TryGetValue(current4.get_Key(), ref texture2D2)) { texture2D2 = this.atlas; } KeyValuePair <int, AtlasInfo.UVDetail> current5 = enumerator.Current; AtlasInfo.UVDetail value = current5.get_Value(); DictionaryView <int, AtlasInfo.UVDetail> dictionaryView3 = dictionaryView; KeyValuePair <int, AtlasInfo.UVDetail> current6 = enumerator.Current; AtlasInfo.UVDetail uVDetail2 = dictionaryView3[current6.get_Key()]; Color[] pixels2 = texture2D2.GetPixels(value.x, value.y, value.width, value.height); texture2D.SetPixels(uVDetail2.x, uVDetail2.y, value.width, value.height, pixels2); texture2D.Apply(false, false); uVDetail2.uvTL = new Vector2((float)uVDetail2.x / (float)texture2D.width, (float)(uVDetail2.y + uVDetail2.height) / (float)texture2D.height); uVDetail2.uvTR = new Vector2((float)(uVDetail2.x + uVDetail2.width) / (float)texture2D.width, (float)(uVDetail2.y + uVDetail2.height) / (float)texture2D.height); uVDetail2.uvBL = new Vector2((float)uVDetail2.x / (float)texture2D.width, (float)uVDetail2.y / (float)texture2D.height); uVDetail2.uvBR = new Vector2((float)(uVDetail2.x + uVDetail2.width) / (float)texture2D.width, (float)uVDetail2.y / (float)texture2D.height); } this.textures = dictionaryView; Object.Destroy(this.atlas); this.atlas = texture2D; Shader shader = Singleton <CResourceManager> .GetInstance().GetResource("Shaders/UI/UI3D.shader", typeof(Shader), enResourceType.BattleScene, true, true).m_content as Shader; this.mat = new Material(shader); this.mat.SetTexture("_MainTex", this.atlas); HashSet <Sprite3D> .Enumerator enumerator2 = this.sprites.GetEnumerator(); while (enumerator2.MoveNext()) { enumerator2.get_Current().SetMaterial(this.mat); enumerator2.get_Current().SetAutoAtlas(this.atlas, this.textures[enumerator2.get_Current().m_textureGUID]); } Dictionary <int, Texture2D> .Enumerator enumerator3 = this.waitForCombineTextures.GetEnumerator(); this.waitForCombineTextures.Clear(); Singleton <CResourceManager> .GetInstance().UnloadUnusedAssets(); return(true); }