Helper class for loading IResourceHandle s in the background.
sealed class
|
ResourceLoader
|
extends
|
Disposable
|
Allow errors that occur during resource loading to be reported?
public
property
|
AllowError
{
get
set
}
|
||
type
|
bool
|
||
value
|
true
to
report
errors,
false
to
ignore
them
(see
remarks). |
Remarks:
When
set
to
true
,
errors
will
be
reported
to
via
the
ConsumeLoadedResource
method,
passing
a
null
resource
object.
When
set
to
false
,
error
messages
will
be
logged
and
the
call
to
the
ConsumeLoadedResource
method
will
be
skipped.
Defaults
to
false
.
Allow
null
resource
objects
as
a
result
of
a
successful
loading
operation?
public
property
|
AllowNull
{
get
set
}
|
||
type
|
bool
|
||
value
|
true
to
enable
passing
of
null
resource
objects
to
the
ConsumeLoadedResource
method,
false
to
disable
it.
|
Remarks:
Defaults
to
false
.
Is this resource loader busy?
public
property
|
IsLoading
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
one
or
more
resources
are
being
loaded,
false
if
the
resource
loader
is
idle.
|
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Creates a new instance of ResourceLoader.
public
constructor
|
ResourceLoader
(Graphics graphics)
|
||
params
|
graphics
|
[not-null]
|
The graphics object to use. |
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Cancels loading of all pending resources.
public
method
|
Cancel
(bool wait = true)
|
||
params
|
wait
|
Wait
until
all
loading
jobs
have
been
cancelled?
Defaults
to
true .
|
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Invokes the ConsumeLoadedResource callbacks for all resources that have finished loading.
public
method
|
Finish
()
|
Loads a resource from the given handle.
public
method
|
Load
(string name,
IResourceHandle handle,
IResourceConsumer callback,
IResourceHandle placeholder = null)
|
||
params
|
name
|
The resource name tag. Will be passed to callback. | |
handle
|
[not-null]
|
The resource handle. | |
callback
|
[not-null]
|
The callback to invoke when the resource has been loaded (see Finish). | |
placeholder
|
Optional
handle
to
use
for
generating
a
resource
that
will
be
reported
to
callback
instantly,
intended
to
be
used
as
a
placeholder
resource
until
the
actual
resource
has
finished
loading.
Defaults
to
null .
|
Remarks:
If an error occurs while loading a texture file, a log message is generated and the final call to callback is skipped.
Loads a 2D texture resource.
public
method
|
LoadTexture
(string name,
Path path,
IResourceConsumer callback,
int64 placeholder = Colors.White)
|
||
params
|
name
|
[not-null]
|
The resource name. Will be passed to callback. |
path
|
[not-null]
|
The texture file path. | |
callback
|
[not-null]
|
The callback to invoke when the resource has been loaded (see Finish). | |
placeholder
|
Optional color value to use for generating a texture (compressed sRGB) that will be reported to callback instantly, intended to be used as a placeholder until the actual texture finished loading. Defaults to White. |
The logger object of this class.
public
static
readonly
field
|
Logger
|
||
type
|
ILogger
|