---
url: https://cri-middleware.github.io/SSPlayerForWeb/api/@spritestudio/ssplayer-pixi-ui/classes/PixiResourceManager.md
---
# Class: PixiResourceManager

Defined in: packages/ssplayer-pixi/dist/index.d.ts:680

## Implements

* [`IResourceManager`](../interfaces/IResourceManager.md)

## Constructors

### Constructor

> **new PixiResourceManager**(): `PixiResourceManager`

#### Returns

`PixiResourceManager`

## Properties

### beforeFree

> **beforeFree**: (() => `void`) | `null`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:685

Called before [reset](#reset) destroys textures, for whoever still draws from them.

## Methods

### bindTextureSource()

> **bindTextureSource**(`source`, `hash`): `void`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:701

#### Parameters

##### source

`HTMLCanvasElement` | `ImageBitmap` | `HTMLImageElement`

##### hash

`number`

#### Returns

`void`

***

### clearOverrideTexture()

> **clearOverrideTexture**(`hash`): `void`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:712

Drop the override for `hash`, restoring the originally loaded texture.

#### Parameters

##### hash

`number`

#### Returns

`void`

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`clearOverrideTexture`](../interfaces/IResourceManager.md#clearoverridetexture)

***

### destroy()

> **destroy**(): `void`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:716

Frees all managed resources.

#### Returns

`void`

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`destroy`](../interfaces/IResourceManager.md#destroy)

***

### getOverrideTexture()

> **getOverrideTexture**(`hash`): [`Texture`](https://pixijs.download/release/docs/index.html)<[`TextureSource`](https://pixijs.download/release/docs/index.html)<`any`>> | `undefined`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:714

The current override for `hash` (never the original), or undefined.

#### Parameters

##### hash

`number`

#### Returns

[`Texture`](https://pixijs.download/release/docs/index.html)<[`TextureSource`](https://pixijs.download/release/docs/index.html)<`any`>> | `undefined`

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`getOverrideTexture`](../interfaces/IResourceManager.md#getoverridetexture)

***

### getTexture()

> **getTexture**(`hash`): [`Texture`](https://pixijs.download/release/docs/index.html)<[`TextureSource`](https://pixijs.download/release/docs/index.html)<`any`>> | `undefined`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:702

Gets a loaded texture by its hash.

#### Parameters

##### hash

`number`

The hash of the texture.

#### Returns

[`Texture`](https://pixijs.download/release/docs/index.html)<[`TextureSource`](https://pixijs.download/release/docs/index.html)<`any`>> | `undefined`

The engine-specific texture object (e.g. PIXI.Texture).

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`getTexture`](../interfaces/IResourceManager.md#gettexture)

***

### loadTexture()

> **loadTexture**(`url`, `hash`): `Promise`<`void`>

Defined in: packages/ssplayer-pixi/dist/index.d.ts:692

Load `url` and bind it under `hash`. Cached in Pixi's global `Assets`
under the URL, deliberately not under the hash: the hash is a cell-map
name hash, unique only within one `.ssab`, so aliasing on it hands one
project another project's atlas.

#### Parameters

##### url

`string`

##### hash

`number`

#### Returns

`Promise`<`void`>

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`loadTexture`](../interfaces/IResourceManager.md#loadtexture)

***

### loadTextureFromBytes()

> **loadTextureFromBytes**(`bytes`, `hash`): `Promise`<`void`>

Defined in: packages/ssplayer-pixi/dist/index.d.ts:700

Decode raw (encoded) image bytes — e.g. a PNG embedded in the SSAB via the
converter's `--embedded` mode — into a texture under `hash`. Uses the same
`createImageBitmap` + `premultiply-alpha-on-upload` (ImageSource default)
as Pixi's own URL texture loader, so embedded and external textures render
identically.

#### Parameters

##### bytes

`Uint8Array`

##### hash

`number`

#### Returns

`Promise`<`void`>

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`loadTextureFromBytes`](../interfaces/IResourceManager.md#loadtexturefrombytes)

***

### reset()

> **reset**(): `void`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:715

Optional: forget every texture bound for the previously bound pack, so the
next one loads its own from scratch. Called by the core from
`bindResource`; a manager that caches by hash must implement it. Must also
drop any runtime texture overrides — they belong to the previous pack's
hashes.

#### Returns

`void`

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`reset`](../interfaces/IResourceManager.md#reset)

***

### setOverrideTexture()

> **setOverrideTexture**(`hash`, `texture`): `void`

Defined in: packages/ssplayer-pixi/dist/index.d.ts:710

Runtime texture replacement: bind `texture` for `hash`, shadowing the
originally loaded texture. Caller-owned — not destroyed here. The pixi
shader/mesh caches are keyed by the `Texture` object, so the new texture
gets its own shader on the next draw and the swap is picked up
automatically; the stale entry is dropped at the next pack load.

#### Parameters

##### hash

`number`

##### texture

[`Texture`](https://pixijs.download/release/docs/index.html)

#### Returns

`void`

#### Implementation of

[`IResourceManager`](../interfaces/IResourceManager.md).[`setOverrideTexture`](../interfaces/IResourceManager.md#setoverridetexture)
