Skip to content

Creating Variants

cheese3660 edited this page Feb 18, 2024 · 2 revisions

First steps

To add variants to your part, you first should import V-SwiFT's mixins by doing

@use "VSwift:*";

At the top of any patch file where you want to add variants

Adding your variants

First you want to set up the part switch module on your part by doing

:parts ... {
    @include part-switch() {
       // This will be where all the following goes
    }
}

Adding a variant set

Inside the block you created, you can add variant sets by doing +[variant set id]

+SomeVariantSet {
    // You can optionally add a localization key, by default it defaults to the variant set id
    VariantSetLocalizationKey: OptionalLocalizationKey;
    // This is where we will add variants
}

Adding a variant

Inside the variant set you created, you can add a variant by doing +[variant id]

+SomeVariant {
    // You can optionally add a localization key, by default it defaults to the variant id
    VariantLocalizationKey: OptionalLocalizationKey;
    // This is where we will add transformers
}

Adding transformers

Inside variants are the transformers that set up this variant, they can be added quite easily by doing +TransformerType

+SomeTransformer {
    // All the transformer parameters go here
}

The 2 implemented transformers currently are TransformActivator and MaterialSwapper

TransformActivator

This transformer takes one "parameter" which is Transforms, which is a list of transform names to activate

+TransformActivator {
    Transforms: [...];
}

Note with the transform activator: All transforms you will be wanting to "activate" should be deactivated by default in unity

MaterialSwapper

This transformer takes one "parameter" which is Swaps, which is a dictionary of material swaps of from,to

+MaterialSwapper {
    Swaps: {
        from: to
    };
}

In the from it ignores any (Instance), and on the to it has to be of a special form with a protocol:// in front of it, the only protocol supported at the moment is addressables which has an addressables key after the addressables://

Clone this wiki locally