JunglePreset¶
Asset-based preset that stores a pre-configured SerializeReference value for polymorphic fields.
Namespace: Jungle.Presets
Inherits: JungleScriptableObject → ScriptableObject
Overview¶
JunglePreset works like Unity's built-in Preset system but for [SerializeReference] polymorphic fields. Every field that holds one of these values shows a preset button in its header, even when the field is empty. On an empty field it stays visible when at least one preset fits; on a filled field it shows when you hover the header. Clicking it opens a list grouped by category, with each preset's icon beside its name and its description under it.
A preset carries the feel, not the wiring. Any single-object field the preset leaves empty, such as a destination or a pivot, keeps the value the field already had when the preset is applied. If the field had nothing there either, it gets the type's own default. Leave the wiring empty in presets you make, so they work anywhere.
A preset appears in fields of the type it was saved for, and in narrower ones. A preset saved on an ITransformOperation field shows on every transform operation field, but not on a general process field.
Properties¶
| Property | Type | Description |
|---|---|---|
| category | string |
Group the preset is listed under in the picker, such as Drag or Attach. |
| description | string |
What the preset does and how it feels, shown under its name. |
| icon | Texture2D |
Picture shown in the picker and on the asset in the Project window. Drop in any texture to use your own; leave it empty to use the icon of what the preset holds. |
| baseTypeAssemblyQualifiedName | string |
Assembly-qualified name of the field type this preset was saved for. |
| presetValue | object |
The stored [SerializeReference] value. |
Runtime API¶
| Member | Type | Description |
|---|---|---|
Category |
string |
Picker category. |
Description |
string |
Picker description. |
Icon |
Texture2D |
The preset's own icon, or null. |
BaseType |
Type |
The field type this preset was saved for. |
Value |
object |
The stored preset value. Shared: do not modify, use CreateValueFor. |
ValueType |
Type |
The concrete type of the stored value. |
Methods¶
| Method | Description |
|---|---|
CreateValueFor(object current) |
Returns a fresh copy of the value that keeps current's wiring wherever the preset leaves a field empty. Works at runtime too. |
SetData(object, Type) |
Initialize the preset with a value and the field type it is for. |
SetInfo(string, string) |
Set the picker category and description. |
IsCompatibleWith(Type) |
True if the value fits a field of this type and the preset was saved for that type or a broader one. |