Example #1
0
        public void Options_ReadFromJson_Success()
        {
            var optionsFilePath = GetTestOptionsFilePath();

            Assert.IsTrue(File.Exists(optionsFilePath));

            var jsonTextAsset = new TextAsset(File.ReadAllText(GetTestOptionsFilePath()));

            JsonSentryUnityOptions.LoadFromJson(jsonTextAsset);
        }
Example #2
0
        public void ToScriptableOptions_ConvertJsonOptions_AreEqual(bool isBuilding)
        {
            var jsonTextAsset   = new TextAsset(File.ReadAllText(GetTestOptionsFilePath()));
            var expectedOptions = JsonSentryUnityOptions.LoadFromJson(jsonTextAsset);

            var scriptableOptions = ScriptableObject.CreateInstance <ScriptableSentryUnityOptions>();

            SentryOptionsUtility.SetDefaults(scriptableOptions);
            JsonSentryUnityOptions.ToScriptableOptions(jsonTextAsset, scriptableOptions);

            var actualOptions = ScriptableSentryUnityOptions.ToSentryUnityOptions(scriptableOptions, isBuilding);

            AssertOptions(expectedOptions, actualOptions);
        }
        public static SentryUnityOptions?LoadSentryUnityOptions(bool isBuilding = false)
        {
            // TODO: Deprecated and to be removed once we update far enough.
            var sentryOptionsTextAsset = Resources.Load <TextAsset>($"{ConfigRootFolder}/{ConfigName}");

            if (sentryOptionsTextAsset != null)
            {
                var options = JsonSentryUnityOptions.LoadFromJson(sentryOptionsTextAsset);
                return(options);
            }

            var scriptableOptions = Resources.Load <ScriptableSentryUnityOptions>($"{ConfigRootFolder}/{ConfigName}");

            if (scriptableOptions is not null)
            {
                return(ToSentryUnityOptions(scriptableOptions, isBuilding));
            }

            return(null);
        }