---
url: https://cri-middleware.github.io/SSPlayerForWeb/api/@spritestudio/ssplayer-core/interfaces/IResourceManager.md
---
# Interface: IResourceManager

Defined in: [src/IResourceManager.ts:1](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L1)

## Methods

### clearOverrideTexture()?

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

Defined in: [src/IResourceManager.ts:47](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L47)

Optional: drop any override for `hash`, restoring the originally loaded
texture. A no-op when nothing is overridden. Pairs with
[setOverrideTexture](#setoverridetexture).

#### Parameters

##### hash

`number`

#### Returns

`void`

***

### destroy()

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

Defined in: [src/IResourceManager.ts:67](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L67)

Frees all managed resources.

#### Returns

`void`

***

### getOverrideTexture()?

> `optional` **getOverrideTexture**(`hash`): `unknown`

Defined in: [src/IResourceManager.ts:53](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L53)

Optional: the current override for `hash` (the caller-supplied value, not
the original texture), or `undefined` when nothing is overridden.

#### Parameters

##### hash

`number`

#### Returns

`unknown`

***

### getTexture()

> **getTexture**(`hash`): `any`

Defined in: [src/IResourceManager.ts:25](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L25)

Gets a loaded texture by its hash.

#### Parameters

##### hash

`number`

The hash of the texture.

#### Returns

`any`

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

***

### loadTexture()

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

Defined in: [src/IResourceManager.ts:7](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L7)

Loads a texture from the given URL and associates it with the given hash.

#### Parameters

##### url

`string`

The URL of the texture to load.

##### hash

`number`

The cell-map name hash — a slot in one `.ssab`, not an image.

#### Returns

`Promise`<`void`>

***

### loadTextureFromBytes()?

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

Defined in: [src/IResourceManager.ts:18](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L18)

Optional: bind a texture from raw (encoded) image bytes — e.g. a PNG/JPEG
embedded in the SSAB (`--embedded` converter mode) — and associate it with
the given hash. ResourceManagers that only support URL loading may omit
this; the core then falls back to [loadTexture](#loadtexture) with a resolved file
URL, so embedded textures require this method to render.

#### Parameters

##### bytes

`Uint8Array`

The encoded image bytes (e.g. a PNG/JPEG file's contents).

##### hash

`number`

The hash of the texture (cell-map name hash).

#### Returns

`Promise`<`void`>

***

### reset()?

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

Defined in: [src/IResourceManager.ts:62](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L62)

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`

***

### setOverrideTexture()?

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

Defined in: [src/IResourceManager.ts:40](https://github.com/cri-middleware/SSPlayerForWeb/blob/eb9d544908210befb40d3729ed6fde7adc44f61a/packages/ssplayer-core/src/IResourceManager.ts#L40)

Optional: replace the texture bound to `hash` with a caller-supplied engine
texture (runtime texture replacement — costume/expression swaps). The
override *shadows* the originally loaded texture rather than freeing it, so
[clearOverrideTexture](#clearoverridetexture) can restore the original with no reload. The
override object is caller-owned; managers that build their own from a raw
source track that separately and free only what they built.

A manager without this method cannot be a texture-replacement target, and
the core throws a clear error rather than silently no-op.

#### Parameters

##### hash

`number`

The render-time texture key (cell-map or external-texture name hash).

##### texture

`unknown`

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

#### Returns

`void`
