m039 / CommonUnityLibrary

A library with common for all my projects code or assets.
MIT License
6 stars 0 forks source link

Wrap UnityEditor namespace in #if UNITY_EDITOR to prevent build errors #1

Closed beardordie closed 1 month ago

beardordie commented 1 month ago

https://github.com/m039/CommonUnityLibrary/blob/73a1ccc456b2f2d21ecfaa0d60c67f6737a67c42/Runtime/Scripts/Utilities/MinMaxFloat.cs#L1

The "using UnityEditor" line will cause build errors for runtime scripts. Wrapping it in #if UNITY_EDITOR should resolve.

m039 commented 1 month ago

I'm using 2023.3.12f1 version of Unity and don't see any build errors. What version are you using? Maybe errors will pop up in older version. Currently, "using UnityEditor" replaced with empty namespace and doesn't cause any issues, but other UnityEditor namespaces are not replaced, like UnityEditor.UI.

beardordie commented 1 month ago

Gotcha, it looks like the compiler removes the using statement if the class doesn't actually use it, which because of the other #if preprocessors you're using, it technically doesn't in a build. Disregard.