This code snippet is used to add an event listener to your script to wait for a preset to be loaded and execute a method to perform tasks.
In this example, the code will get listen for an Appearance Preset to be loaded and output the message "Preset Loaded" with the preset name in the message window.
C#:
public PresetManager pm;
public override void Init() {
try {
JSONStorable presetJS = containingAtom.GetStorableByID("AppearancePresets");
pm = presetJS.GetComponentInChildren<PresetManager>();
pm.postLoadEvent.AddListener(OnPresetLoaded);
}
catch (Exception e) {
SuperController.LogError("Exception caught: " + e);
}
}
C#:
protected void OnPresetLoaded() {
SuperController.LogMessage("Preset Loaded - " + pm.presetName);
}
Some additional properties include:
presetName | Returns the name of the preset. Includes var name when applicable. |
GetStoreRootPath() | Returns root path to the preset. Ex: "Custom\Atom\Person" |
storeFolderName | Returns the folder within "Custom\Atom\Person\" the preset resides in. Example: "Hair" for a Hair preset. |
GetStoreFolderPath | Returns full path to the preset. Ex: "Custom\Atom\Person\Appearance" |
IsPresetInPackage | Returns true if contained in a var package. Otherwise false. |
customPath | Returns preset base path "Person\" |
includePhysical | Returns true/false according to the 'Include Physical' checkbox on General presets. |
includeAppearance | Returns true/false according to the 'Include Appearance' checkbox on General presets. |