# Device Presets

Device Presets are the core of **XRBuildKit’s multi-platform workflow**.\
A Device Preset is a **snapshot** of Unity project settings, XR configurations, and platform-specific files required to build your app for a specific XR device or platform.

***

### What is a Device Preset?

A Device Preset bundles together:

* **Project Settings**
  * Player settings, build options, scripting backend, and platform targets.
  * Includes critical assets like `ProjectSettings.asset`, `XRPackageSettings.asset`, and legacy `XRSettings.asset`.
* **XR Plug-in and Loader Settings**
  * Active XR loaders and OpenXR configurations.
  * Preserves feature toggles and loader activation states.
* **Scene List**
  * All Unity scenes included in the build pipeline.
* **Platform-Specific Assets**
  * For Android:
    * `AndroidManifest.xml`,
    * `gradleTemplate.properties`,
    * `mainTemplate.gradle`,
    * native `.aar` or `.so` plugin assets.
  * Loader-specific `.meta` configuration files are also tracked.
* **Custom XR Resources**
  * Full contents of the `Assets/XR/` folder.
  * Ensures OpenXR settings are reloaded live (`EnsureOpenXRSettingsLoaded`).

***

### Why Use Device Presets?

* **Instant platform switching** – safely move between Quest, XREAL, VisionOS, and PC with one Unity project.
* **Eliminate plugin conflicts** – XRBuildKit manages enabling/disabling `.meta` files for Android/XREAL automatically.
* **Reproduce builds rapidly** – switch to known-good presets for testing, release, or debugging.
* **Version control friendly** – preset data is stored under `XRBuildKit/` and can be committed to Git.

***

### Typical Workflow

1.  **Save a Preset**\
    Save the current Unity project configuration as a preset for your target platform.

    ```csharp
    XRSettingsUtility.SavePreset("Quest3", "Android");
    ```
2.  **Load a Preset**\
    Instantly restore all settings and platform files for another device.

    ```csharp
    XRSettingsUtility.LoadPreset("Quest3", "Android");
    ```
3.  **Delete a Preset**\
    Clean up unused or outdated presets.

    ```csharp
    XRSettingsUtility.DeletePreset("Quest3", "Android");
    ```
4. **Switch Back Anytime**\
   Move freely between devices without breaking project settings.

***

### Example Use Cases

* Build for **Meta Quest 3**, **XREAL**, and **Windows PC** with a single Unity project—just load the preset before building.
* Safely **roll back** to a stable configuration after a Unity upgrade or plugin change.
* **Share presets with teammates** for consistent builds across development machines.

***

### API Reference

All functions are static and available from **Editor scripts**:

* `SavePreset(string name, string platform)`\
  Saves `ProjectSettings`, `XR`, and `Android` settings (if applicable).
* `LoadPreset(string name, string platform)`\
  Switches Unity’s active build target, restores preset directories, and ensures OpenXR settings are live.
* `DeletePreset(string name, string platform)`\
  Removes stored preset folders from `XRBuildKit/CustomProjectSettings`, `XRBuildKit/CustomXRSettings`, and `XRBuildKit/Plugins`.
* `BuildUtility.LoadAllPresets(string root, List<string> platforms, List<string> names)`\
  Recursively enumerates available presets for UI display.
* `BuildUtility.GetDisplayNames(List<string> platforms, List<string> names)`\
  Returns presets in `"Platform/PresetName"` format for dropdowns.

***

### Tips & Best Practices

* **Clear naming** – use device name + platform, e.g. `Quest3_Android`, `PC_Windows`.
* **Commit preset folders** – stored under:
  * `XRBuildKit/CustomProjectSettings/`
  * `XRBuildKit/CustomXRSettings/`
  * `XRBuildKit/Plugins/` (Android)
* **Update presets** after major plugin or settings changes.
* **Use version control** to share stable presets across your team.

***

### Related Guides

* [Saving, Loading, and Deleting Presets](https://chatgpt.com/c/68a27455-45b0-832b-bc9d-c71a47dcd04a#typical-workflow)
* [Platform & Build Options](https://chatgpt.com/c/BuildUtility.md)
* [Plugin Configuration (Android & XREAL)](https://chatgpt.com/c/PluginConfigurator.md)

***

🚀 **Start managing your Device Presets with XRBuildKit today for a faster, safer, multi-platform XR workflow!**
