Search code examples
unity-game-engineuwp

Cant build with with Unity Presets in my code


I'm building a unity HoloLens 2 application which means that I need to build my project to UWP (Universal Windows Platform). I'm pretty deep into my project and have had no issues building before but for some reason when I tried including Presets IN CODE it just stops working.

Here are my build settings: build settings the code I have isn't really relevant since I'm just applying a serialized Preset reference to a rigidbody. I have the using statement otherwise my ide would have warned me, it even runs fine in the editor no errors nothing but when I build I get the following error: "Assets\Scripts\Chain\Piece\SnapGroup.cs(4,19): error CS0234: The type or namespace name 'Presets' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)"

I tried deleting my old build and rebuilding the project from scratch since I saw some people having issues with UWP builds not updating stuff when updating an existing build but this did not fix the issue.

Also to clarify, this build error occurs when building from unity to visual studio, not when building onto the HoloLens itself (because I can't make it past the first step atm).

I know that excluding Presets will fix the issue (tested). But it will be very messy to replicate the desired functionality without them. Anybody know what the issue is and if there's a fix?


Solution

  • Answered by @RetiredNinja in a comment but posting it as an answer here so that I can mark this question as solved.

    Preset is an editor only class so it cannot be used in run time code. More info can be found here (link also provided by RetiredNinja)