Wearable Set Object

A pre-configured set of Wearables, Materials and Morphs.

A Wearable Set Object is an asset you can create to hold a Wearable Set.

Manually Creating a Wearable Set Object

To create a set manually, right-click in a folder and navigate to Create > Modular Character System > Wearable Set.

Fill in the fields as you wish, ensuring you are only adding Wearables compatible with the Character Style you are creating it for.

Creating a Wearable Set Object with Code

The demo scenes capture the current Wearable Set configuration from a character and save it as a Wearable Set Object. You can do so using the SaveCurrentSet function in the Modular Character Manager.

Create a new script called "SaveWearableSetObject" and include the following block of code.

Calling the function will create a new Wearable Set Object generated directly from the current character configuration. You will need to specify a save location and pass both the Modular Character Manager, and a new set name to the function.

This code will check your specified save location to see if a folder with the Character Style name exists. If no such folder exists, it will create one. It will then copy the current set and save it as a Wearable Set Object in that location. Finally, it will ping the newly created object.

Scriptable Objects assets can not be created at Runtime. You will need to run the code in Editor Play Mode, or create a custom editor button to run it.

using UnityEngine;
using UnityEditor;
using Stellar;

public class SaveWearableSetObject : Monobehaviour
{   
    public string saveLocation;

    // Saves a copy of the current Wearable Set as a Wearable Set Object to the specified folder
    public void SaveNewCharacterPreset(ModularCharacterManager _manager, string _newSetName)
    {
        WearableSet newSet = _manager.SaveCurrentSet(_newSetName);
        WearableSetObject setObjectAsset = ScriptableObject.CreateInstance<WearableSetObject>();
        setObjectAsset.wearableSet = newSet;   
    
        string folderName = _manager.modularCharacter.charStyle.styleName;    
    
        if (AssetDatabase.IsValidFolder(newFolderLocation + "/" + folderName))
        {
            saveLocation = saveLocation + "/" + folderName;
        }
        else
        {
            string guid = AssetDatabase.CreateFolder(saveLocation, folderName);
            saveLocation = AssetDatabase.GUIDToAssetPath(guid);
        }
    
        string localPath = saveLocation + "/" + _newSetName + ".asset";
        localPath = AssetDatabase.GenerateUniqueAssetPath(localPath);
    
        AssetDatabase.CreateAsset(setObjectAsset, localPath);
        AssetDatabase.SaveAssets();
        EditorGUIUtility.PingObject(setObjectAsset);
    
    }
}

Last updated