Class AccessoryFactory
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
sourceResourcePathstringThe Resources path to the source accessory prefab.
newNamestringName for the cloned accessory.
textureReplacementsDictionary<string, Texture2D>Optional dictionary of shader texture names and replacement textures.
colorTintColor?Optional color tint to apply.
targetResourcePathstringOptional 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
sourceResourcePathstringThe Resources path to the source accessory prefab.
targetResourcePathstringThe Resources path where the custom accessory will be registered.
newNamestringName for the cloned accessory.
textureReplacementsDictionary<string, Texture2D>Optional dictionary of shader texture names and replacement textures.
colorTintColor?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
resourcePathstringThe Resources path to register the accessory at.
accessoryGameObjectThe accessory GameObject to register.
Returns
- bool
True if registration was successful.