ImageAsset Class Reference

Image asset class. More...

List of all members.

Public Member Functions

 ImageAsset (string filename, bool asyncLoad)
 Creates a new instance from a specified image file.
 ImageAsset (string filename)
 Creates a new instance from a specified image file.
 ImageAsset (SystemImageAsset name)
 Creates a new instance for a specified system image asset.
 ImageAsset (Texture2D texture)
 Creates a new instance from a specified existing texture.
 ImageAsset (Image image, PixelFormat format)
 Creates a new instance from a specified existing image.
 ImageAsset (Image image)
 Creates a new instance from a specified existing image.
 ImageAsset (string filename, bool asyncLoad, bool scaledPixelDensity)
 Creates a new instance from a specified image file.
 ImageAsset (Texture2D texture, bool scaledPixelDensity)
 Creates a new instance from a specified existing texture.
 ImageAsset (Image image, PixelFormat format, bool scaledPixelDensity)
 Creates a new instance from a specified existing image.
 ImageAsset (Image image, bool scaledPixelDensity)
 Creates a new instance from a specified existing image.
Texture2D CloneTexture ()
 Obtains texture duplicates.
void WaitForLoad ()
 Waits until the file is loaded.
void Dispose ()
 Frees used resources.
bool UnloadFromCache ()
 Deletes the ImageAsset cache loaded from an image file.

Static Public Member Functions

static void WaitForLoadAll ()
 Waits until the asynchronous loading of all images completes.
static bool UnloadFromCache (string filename)
 Deletes the ImageAsset cache loaded from a file.

Properties

bool Ready [get]
 Obtains whether image asset loading is completed.
int Width [get]
 Obtains the width of an image asset.
int Height [get]
 Obtains the height of an image asset.
string FilePath [get]
 Obtains the image file path.

Detailed Description

Image asset class.

Class concealing texture loading. Asynchronous loading of image files and caching is supported. When ImageAsset has been created from an image file, the texture is cached. If an ImageAsset with the same filename is created from this cache, the unmanaged resources of the texture will be shared. Note that the cache will not be freed with just Dispose or garbage collection. For ImageAssets that are no longer used, after calling UnloadFromCache, call all Disposes for the ImageAssets of the same image files.


Constructor & Destructor Documentation

ImageAsset ( string  filename,
bool  asyncLoad 
)

Creates a new instance from a specified image file.

Once loaded, it will be cached. For those that are no longer used, call UnloadFromCache.

Parameters:
filenameImage filename
asyncLoadWhether or not asynchronous loading is performed
ImageAsset ( string  filename)

Creates a new instance from a specified image file.

Performs synchronous loading. Once loaded, it will be cached. For those that are no longer used, call UnloadFromCache.

Parameters:
filenameImage filename

Creates a new instance for a specified system image asset.

Image assets used for standard widgets, etc. Performs asynchronous loading.

Parameters:
nameSystem image asset
ImageAsset ( Texture2D  texture)

Creates a new instance from a specified existing texture.

Will not be cached. To hold the ShallowClone of a texture in ImageAsset, use Dispose on the instance for the texture specified in the argument as required.

Parameters:
textureTextures
ImageAsset ( Image  image,
PixelFormat  format 
)

Creates a new instance from a specified existing image.

Will not be cached. Use Dispose on the instance for the image specified in the argument as required.

Parameters:
imageExisting image
formatPixel format of specified existing image
ImageAsset ( Image  image)

Creates a new instance from a specified existing image.

Will not be cached. Use Dispose on the instance for the image specified in the argument as required.

Parameters:
imageExisting image
ImageAsset ( string  filename,
bool  asyncLoad,
bool  scaledPixelDensity 
)

Creates a new instance from a specified image file.

Once loaded, it will be cached. For those that are no longer used, call UnloadFromCache.

Parameters:
filenameImage filename
asyncLoadWhether or not asynchronous loading is performed
scaledPixelDensityWhether or not to scale according to the pixel density
ImageAsset ( Texture2D  texture,
bool  scaledPixelDensity 
)

Creates a new instance from a specified existing texture.

Will not be cached. To hold the ShallowClone of a texture in ImageAsset, use Dispose on the instance for the texture specified in the argument as required.

Parameters:
textureTextures
scaledPixelDensityWhether or not to scale according to the pixel density
ImageAsset ( Image  image,
PixelFormat  format,
bool  scaledPixelDensity 
)

Creates a new instance from a specified existing image.

Will not be cached. Use Dispose on the instance for the image specified in the argument as required.

Parameters:
imageExisting image
formatPixel format of specified existing image
scaledPixelDensityWhether or not to scale according to the pixel density
ImageAsset ( Image  image,
bool  scaledPixelDensity 
)

Creates a new instance from a specified existing image.

Will not be cached. Use Dispose on the instance for the image specified in the argument as required.

Parameters:
imageExisting image
scaledPixelDensityWhether or not to scale according to the pixel density

Member Function Documentation

Texture2D CloneTexture ( )

Obtains texture duplicates.

Returns the ShallowClone of the texture. If texture loading is not yet completed during asynchronous loading, null is returned.

void Dispose ( )

Frees used resources.

Calls Dispose for a texture held by this instance. When ImageAsset is loaded from an image file, the cached texture is not freed. For complete release, UnloadFromCache must be called.

bool UnloadFromCache ( )

Deletes the ImageAsset cache loaded from an image file.

Frees a cached texture. Only textures in a cache are freed, so it is possible to continue using this instance. To free unmanaged resources of the target texture without waiting for garbage collection, Dispose must be called.

Returns:
false: Did not exist in the cache
static bool UnloadFromCache ( string  filename) [static]

Deletes the ImageAsset cache loaded from a file.

Parameters:
filenameFilename
Returns:
false: Did not exist in the cache
void WaitForLoad ( )

Waits until the file is loaded.

Returns quickly if loaded synchronously or if already loaded.


Property Documentation

string FilePath [get]

Obtains the image file path.

Returns null when a file is not created.

int Height [get]

Obtains the height of an image asset.

If loading is not yet completed during asynchronous loading, 0 is returned.

bool Ready [get]

Obtains whether image asset loading is completed.

"true" returns if a non-image file is loaded or if loaded synchronously.

int Width [get]

Obtains the width of an image asset.

If loading is not yet completed during asynchronous loading, 0 is returned