Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HB-6543] Add API to Allow Game Publishers to Specify the ChartboostMediationSettings Object #197

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions com.chartboost.mediation/Editor/ChartboostMediationSettingsEditor.cs

This file was deleted.

This file was deleted.

19 changes: 16 additions & 3 deletions com.chartboost.mediation/Editor/Settings/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using Chartboost.Editor.Adapters;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

Expand All @@ -20,9 +21,6 @@ internal static SettingsWindow Instance {
var settingsWindow = GetWindow<SettingsWindow>("Settings", typeof(AdaptersWindow));
settingsWindow.minSize = Constants.MinWindowSize;
_instance = settingsWindow;
var scriptableInstance = ChartboostMediationSettings.Instance == null;
if (!scriptableInstance)
Debug.LogWarning($"[Settings Window] Could not fetch ChartboostMediationSettings instance.");
return _instance;
}
}
Expand All @@ -38,6 +36,21 @@ private void Initialize()
var scrollView = new ScrollView();
scrollView.contentContainer.style.flexDirection = FlexDirection.Column;
scrollView.contentContainer.style.flexWrap = Wrap.NoWrap;

var objectField = new ObjectField {
objectType = typeof(ChartboostMediationSettings),
value = ChartboostMediationSettings.Instance
};

objectField.RegisterValueChangedCallback(value =>
{
ChartboostMediationSettings.Instance = value.newValue as ChartboostMediationSettings;
root.Clear();
Initialize();
});

scrollView.Add(objectField);


var settingsLabel = new Label("SDK Integration Settings") {
name = "title",
Expand Down
10 changes: 7 additions & 3 deletions com.chartboost.mediation/Runtime/ChartboostMediationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using UnityEngine;
using System.IO;
using UnityEngine.Scripting;
using UnityEngine.Serialization;
#if UNITY_EDITOR
using UnityEditor;
Expand Down Expand Up @@ -41,6 +42,7 @@ public enum ChartboostMediationPartners
/// <summary>
/// Chartboost Mediation Unity SDK Settings as an scriptable object with accessors
/// </summary>
[CreateAssetMenu(fileName = "ChartboostMediationSettings", menuName = "Chartboost Mediation/Create ChartboostMediationSettings")]
public class ChartboostMediationSettings : ScriptableObject
{
private const string Package = "com.chartboost.mediation";
Expand Down Expand Up @@ -99,6 +101,8 @@ public static ChartboostMediationSettings Instance
#endif
return _instance;
}
[Preserve]
set => _instance = value;
}

#if UNITY_EDITOR
Expand All @@ -120,7 +124,7 @@ public static void OpenDocumentation()
[SerializeField] private bool isAutomaticInitEnabled;
[SerializeField] private bool isSkAdNetworkResolutionEnabled;
#pragma warning disable CS0618
[SerializeField] private ChartboostMediationPartners partnerKillSwitch = ChartboostMediationPartners.None;
private ChartboostMediationPartners _partnerKillSwitch = ChartboostMediationPartners.None;
#pragma warning restore CS0618
[SerializeField] private bool disableBitcode = false;
[SerializeField] private string applovinSDKKey = DefaultSDKKeyValue;
Expand All @@ -133,8 +137,8 @@ public static void OpenDocumentation()
[Obsolete("PartnerKillSwitch has been deprecated and will be removed in future versions, please use StartWithOptions instead.")]
public static ChartboostMediationPartners PartnerKillSwitch
{
get => Instance.partnerKillSwitch;
set => Instance.partnerKillSwitch = value;
get => Instance._partnerKillSwitch;
set => Instance._partnerKillSwitch = value;
}

/// <summary>
Expand Down
Loading