What is a "Clothing Plugin"?
It turns out that you can trick VAM into loading plugins when an item of clothing is loaded. These plugins don't go into the default Atom plugin UIs and are generally their own separate thing.
What can I do with a Clothing Plugin?
A clothing plugin can do anything a regular plugin can do. What's nice about clothing plugins is that a user doesn't need to load them manually. They're added automatically when an item of clothing is put on for the first time.
It's really just a way for content creators to package up their clothes with some additional logic. Some example uses are:
Is it safe?
Probably. Since we're using VAM's plugin manager, the loaded plugins will have the same sandboxing to prevent access to the outside system. Similarly, there will be a confirmation dialog for any new plugin loaded this way.
I've run it by the devs and they gave the green light. Still, hard to make any guarantees with this sort of thing.
Hair Plugins
A similar thing can be done with Hair through a slightly different process.
Setting Up Clothing Plugins
Video walkthrough for adding a clothing plugin to an existing piece, and publishing.
1. Add an MVRPluginManager to the list of components
Locate the .vaj file for your clothing. It will contain a json file with "components" and "storables". Under components, add an item of type MVRPluginManager
2. Add the ClothingPluginManager
Next, add an entry to 'storables' with your plugin list. The id for this entry must be the base id of the clothing. In the example, I'm modifying mopedlampe:test-glasses, and all of the other components are named like mopedlampe:test-glassesXXX. In this case I will use "id" : "mopedlampe:test-glasses".
The only required item under the plugins list is the latest version of the ClothingPluginManager. This will quiet VAM's various complaints about being forced to load plugins this way.
3. Add Plugins / Save Defaults
You should now see a Plugins tab under the customization UI. Use this to add and configure additional plugins.
The ClothingPluginManager UI also has buttons to save and load presets. By default it will save a default.clothingplugins file, which will be loaded with the clothing.
4. Releasing Clothing
When packaging up the clothing, VAM will want to replace the ID of the storable with something like "SELF:/Custom/Clothing/Female/mopedlampe/test-glasses/test-glasses.vam", which will not work.
To get around this
Making Clothing Plugins
A clothing plugin isn't fundamentally different from a regular plugin. In fact, many regular plugins will work fine when loaded as clothing plugins.
Still, a few things to keep in mind...
Multiple Copies
A clothing plugin is more likely to be added multiple times to the same atom (under different pieces of clothing). Make sure that this doesn't cause issues.
Storables and Store Ids
The PluginManager will register clothing plugins with the atom as a storable. This means that storable plugin parameters will generally work fine when saving/loading from scenes. Neat!
I recommend setting the storeId of the plugin (via the overrideId) to make it easier to find and less likely to collide with other instances of the plugin.
Defaults For Clothing Items
A clothing creator will likely need to modify plugin settings to match the particular item. The best way I've thought to do this by allowing them to package up a default preset along with the clothing files.
Here is a simple pattern that I've used. Note, you'll need to find the clothing item's DAZDynamic component. It should be one hop up in the gameObject hierarchy above where the plugin exists.
Demo
A fully packaged var available here:
It turns out that you can trick VAM into loading plugins when an item of clothing is loaded. These plugins don't go into the default Atom plugin UIs and are generally their own separate thing.
What can I do with a Clothing Plugin?
A clothing plugin can do anything a regular plugin can do. What's nice about clothing plugins is that a user doesn't need to load them manually. They're added automatically when an item of clothing is put on for the first time.
It's really just a way for content creators to package up their clothes with some additional logic. Some example uses are:
- Automatically applying HeelAdjust(2) to shoes.
- Putting on other clothes
- Hiding or adding decals to parts of the main body
- Adding and positioning Lights or CUAs
- Animating clothing materials
Is it safe?
Probably. Since we're using VAM's plugin manager, the loaded plugins will have the same sandboxing to prevent access to the outside system. Similarly, there will be a confirmation dialog for any new plugin loaded this way.
I've run it by the devs and they gave the green light. Still, hard to make any guarantees with this sort of thing.
Hair Plugins
A similar thing can be done with Hair through a slightly different process.
Guides - Hair Plugins
What is a "Hair Plugin"? It turns out that you can trick VAM into loading plugins when a hair is put on. These plugins don't go into the default Atom plugin UIs and are generally their own separate thing. Hair Plugins are very similar to...
hub.virtamate.com
Setting Up Clothing Plugins
Video walkthrough for adding a clothing plugin to an existing piece, and publishing.
1. Add an MVRPluginManager to the list of components
Locate the .vaj file for your clothing. It will contain a json file with "components" and "storables". Under components, add an item of type MVRPluginManager
2. Add the ClothingPluginManager
Next, add an entry to 'storables' with your plugin list. The id for this entry must be the base id of the clothing. In the example, I'm modifying mopedlampe:test-glasses, and all of the other components are named like mopedlampe:test-glassesXXX. In this case I will use "id" : "mopedlampe:test-glasses".
The only required item under the plugins list is the latest version of the ClothingPluginManager. This will quiet VAM's various complaints about being forced to load plugins this way.
3. Add Plugins / Save Defaults
You should now see a Plugins tab under the customization UI. Use this to add and configure additional plugins.
The ClothingPluginManager UI also has buttons to save and load presets. By default it will save a default.clothingplugins file, which will be loaded with the clothing.
4. Releasing Clothing
When packaging up the clothing, VAM will want to replace the ID of the storable with something like "SELF:/Custom/Clothing/Female/mopedlampe/test-glasses/test-glasses.vam", which will not work.
To get around this
- Click "Prep Package"
- Click "Open Prepped Folder In Windows Explorer"
- Find the .vaj file and modify it with the correct value
- Finalize Package
Making Clothing Plugins
A clothing plugin isn't fundamentally different from a regular plugin. In fact, many regular plugins will work fine when loaded as clothing plugins.
Still, a few things to keep in mind...
Multiple Copies
A clothing plugin is more likely to be added multiple times to the same atom (under different pieces of clothing). Make sure that this doesn't cause issues.
Storables and Store Ids
The PluginManager will register clothing plugins with the atom as a storable. This means that storable plugin parameters will generally work fine when saving/loading from scenes. Neat!
I recommend setting the storeId of the plugin (via the overrideId) to make it easier to find and less likely to collide with other instances of the plugin.
C#:
this.overrideId = $"{dazSkinWrap.name}:{this.storeId}";
Defaults For Clothing Items
A clothing creator will likely need to modify plugin settings to match the particular item. The best way I've thought to do this by allowing them to package up a default preset along with the clothing files.
Here is a simple pattern that I've used. Note, you'll need to find the clothing item's DAZDynamic component. It should be one hop up in the gameObject hierarchy above where the plugin exists.
C#:
string defaultFile = $"{dazDynamic.GetStoreFolderPath(true)}default.{fileExt}";
if(FileManagerSecure.FileExists(defaultFile)){
LoadPreset(defaultFile);
}
Demo
A fully packaged var available here:
Clothing - Plugin Clothing Test Sunglasses
A test pair of sunglasses that have been repackaged to use the StaticClothing plugin. Meant only do serve as a demo for the guide: https://hub.virtamate.com/resources/clothing-plugins.37636/ Original import by @mopedlampe available here...
hub.virtamate.com