Table of Contents

Class AccessoryFactory

Namespace
S1API.Rendering
Assembly
S1API.dll

Factory for creating custom accessory prefabs at runtime by cloning and modifying existing ones.

public static class AccessoryFactory
Inheritance
AccessoryFactory
Inherited Members

Methods

CloneAccessoryWithCustomTextures(string, string, Dictionary<string, Texture2D>, Color?, string)

Clones an accessory prefab and applies custom textures/materials.

public static GameObject CloneAccessoryWithCustomTextures(string sourceResourcePath, string newName, Dictionary<string, Texture2D> textureReplacements = null, Color? colorTint = null, string targetResourcePath = null)

Parameters

sourceResourcePath string

The Resources path to the source accessory prefab.

newName string

Name for the cloned accessory.

textureReplacements Dictionary<string, Texture2D>

Optional dictionary of shader texture names and replacement textures.

colorTint Color?

Optional color tint to apply.

targetResourcePath string

Optional target resource path for the cloned accessory. If provided, sets Accessory.AssetPath to this value instead of sourceResourcePath. This ensures PlayerClothing validation can match the accessory correctly.

Returns

GameObject

The cloned and customized accessory GameObject, or null if cloning failed.

CreateAndRegisterAccessory(string, string, string, Dictionary<string, Texture2D>, Color?)

Creates a custom accessory by cloning a source and applies custom textures, then registers it. This is a convenience method that combines cloning, customization, and registration.

public static bool CreateAndRegisterAccessory(string sourceResourcePath, string targetResourcePath, string newName, Dictionary<string, Texture2D> textureReplacements = null, Color? colorTint = null)

Parameters

sourceResourcePath string

The Resources path to the source accessory prefab.

targetResourcePath string

The Resources path where the custom accessory will be registered.

newName string

Name for the cloned accessory.

textureReplacements Dictionary<string, Texture2D>

Optional dictionary of shader texture names and replacement textures.

colorTint Color?

Optional color tint to apply.

Returns

bool

True if the accessory was successfully created and registered.

RegisterAccessory(string, GameObject)

Registers a cloned accessory with the RuntimeResourceRegistry so it can be loaded via Resources.Load.

public static bool RegisterAccessory(string resourcePath, GameObject accessory)

Parameters

resourcePath string

The Resources path to register the accessory at.

accessory GameObject

The accessory GameObject to register.

Returns

bool

True if registration was successful.