private static void ApplySettings(Uni2DTextureAtlas a_rAtlas)
 {
     if (a_rAtlas.ApplySettings( ) == false)
     {
         EditorUtility.DisplayDialog("Uni2D Texture Atlasing",
                                     "Uni2D could not pack all the specified textures into '" + a_rAtlas.name + "'.\n"
                                     + "Please check the maximum allowed atlas size and the input textures.",
                                     "OK");
     }
 }
Пример #2
0
    // Generate atlas
    private void GenerateAtlas(AnimationClipRegeneration a_eRegeneration)
    {
        int iFrameCount = this.FrameCount;

        if (globalAtlas != null)          // global atlas
        {
            string[] oTextureGUIDs = this.GetAllFramesTextureGUIDs( );

            if (a_eRegeneration == AnimationClipRegeneration.RegenerateAll ||
                (a_eRegeneration == AnimationClipRegeneration.RegenerateAlsoAtlasIfNeeded &&
                 (globalAtlas.UnappliedSettings || globalAtlas.Contains(oTextureGUIDs) == false)))
            {
                globalAtlas.ApplySettings( );
            }

            globalAtlas.AddTextures(oTextureGUIDs);
        }
        else         // Atlas per frame
        {
            HashSet <Uni2DTextureAtlas> oFrameAtlases = new HashSet <Uni2DTextureAtlas>( );

            for (int iFrameIndex = 0; iFrameIndex < iFrameCount; ++iFrameIndex)
            {
                Uni2DAnimationFrame rFrame      = frames[iFrameIndex];
                Uni2DTextureAtlas   rFrameAtlas = rFrame.atlas;
                if (rFrameAtlas != null)
                {
                    string oFrameTextureGUID = rFrame.textureContainer != null ? rFrame.textureContainer.GUID : null;

                    if (a_eRegeneration == AnimationClipRegeneration.RegenerateAll ||
                        (a_eRegeneration == AnimationClipRegeneration.RegenerateAlsoAtlasIfNeeded &&
                         (rFrameAtlas.UnappliedSettings || rFrameAtlas.Contains(oFrameTextureGUID) == false)))
                    {
                        oFrameAtlases.Add(rFrameAtlas);
                    }

                    rFrameAtlas.AddTextures(new string[1] {
                        oFrameTextureGUID
                    });
                }
            }

            // Regenerate atlases
            foreach (Uni2DTextureAtlas rFrameAtlas in oFrameAtlases)
            {
                rFrameAtlas.ApplySettings( );
            }
        }
    }
	private static void ApplySettings( Uni2DTextureAtlas a_rAtlas )
	{
		if( a_rAtlas.ApplySettings( ) == false )
		{
			EditorUtility.DisplayDialog( "Uni2D Texture Atlasing",
				"Uni2D could not pack all the specified textures into '" + a_rAtlas.name + "'.\n"
				+ "Please check the maximum allowed atlas size and the input textures.",
				"OK" );
		}
	}