diff --git a/Editor/JSONChecker.cs b/Editor/JSONChecker.cs index 7a48151..9463010 100644 --- a/Editor/JSONChecker.cs +++ b/Editor/JSONChecker.cs @@ -23,6 +23,12 @@ THE SOFTWARE. //#define JSONOBJECT_PERFORMANCE_TEST //For testing performance of parse/stringify. Turn on editor profiling to see how we're doing // ReSharper disable UseStringInterpolation +#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER +#define USING_UNITY +#endif + +#if USING_UNITY + using Defective.JSON.Tests; using UnityEngine; using UnityEditor; @@ -118,3 +124,5 @@ void OnGUI() { } } } + +#endif diff --git a/JSONObject.cs b/JSONObject.cs index 2a486fd..a00bbbc 100644 --- a/JSONObject.cs +++ b/JSONObject.cs @@ -843,7 +843,12 @@ static bool ParseObjectEnd(string inputString, int offset, bool openQuote, JSONO return true; if (container == null) { - Debug.LogError("Parsing error: encountered `}` with no container object"); +#if USING_UNITY + Debug.LogError +#else + Debug.WriteLine +#endif + ("Parsing error: encountered `}` with no container object"); return false; } @@ -870,7 +875,12 @@ static bool ParseArrayEnd(string inputString, int offset, bool openQuote, JSONOb return true; if (container == null) { - Debug.LogError("Parsing error: encountered `]` with no container object"); +#if USING_UNITY + Debug.LogError +#else + Debug.WriteLine +#endif + ("Parsing error: encountered `]` with no container object"); return false; } @@ -907,7 +917,12 @@ static bool ParseColon(string inputString, bool openQuote, JSONObject container, return true; if (container == null) { - Debug.LogError("Parsing error: encountered `:` with no container object"); +#if USING_UNITY + Debug.LogError +#else + Debug.WriteLine +#endif + ("Parsing error: encountered `:` with no container object"); return false; } @@ -929,7 +944,12 @@ static bool ParseComma(string inputString, bool openQuote, JSONObject container, return true; if (container == null) { - Debug.LogError("Parsing error: encountered `,` with no container object"); +#if USING_UNITY + Debug.LogError +#else + Debug.WriteLine +#endif + ("Parsing error: encountered `,` with no container object"); return false; } diff --git a/VectorTemplates.cs b/VectorTemplates.cs index e3c1bd6..86570ac 100644 --- a/VectorTemplates.cs +++ b/VectorTemplates.cs @@ -20,6 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER +#define USING_UNITY +#endif + +#if USING_UNITY + using UnityEngine; namespace Defective.JSON { @@ -299,3 +305,5 @@ public static JSONObject ToJson(this RectOffset rectOffset) { } } } + +#endif