public void OnPostGenerateGradleAndroidProject(string path) { // Check if it's trying to build to an unsuportted platform if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) { // Plugin might be on a project that's not making use of it. So we'll just show a warning. Debug.LogWarning($"<size=20>Kiln only supports Android for the moment.</size>"); return; } else { Settings settings = Resources.Load <Settings>("KilnSettings"); // If we do have a kiln configuration we'll copy that configuration to the Android Build if (settings != null) { string assetsPath = $"{path}/src/main/assets"; string file; // Copy the mocked leaderboard status foreach (Settings.Leaderboard l in settings.Leaderboards) { if (Leaderboard.IsSaved(l.Id)) { file = $"{assetsPath}/{Leaderboard.GetFileName(l.Id)}"; if (settings.ExportLeaderboardState) { System.IO.File.Copy(Leaderboard.GetPath(l.Id), file, true); } else { // If we don't want to export our current Leaderboard states // we'll just create new ones Leaderboard aux = new Leaderboard(l.Id, 100, l.Type, false); System.IO.File.WriteAllText(file, aux.ToJson()); } } } // Copy the mocked In App Purchases status file = $"{assetsPath}/{InAppPurchases.StorageFileName}"; if (InAppPurchases.IsSaved() && settings.ExportIAPState) { System.IO.File.Copy(InAppPurchases.StoragePath, file, true); } else { System.IO.File.WriteAllText(file, InAppPurchases.GetEmptyState()); } // Create kiln definitions var definitions = new KilnDefinition(settings); file = $"{assetsPath}/{KilnDefinition.FileName}"; System.IO.File.WriteAllText(file, definitions.Serialize().ToString()); } } }
/// <summary> /// Initializes the SDK /// </summary> /// <returns>Task that'll return upon initializing all modules in the SDK</returns> public static Task Init() { #if ANDROID_DEVICE return(Bridge.Init()); #else var aTcs = new TaskCompletionSource <object>(); _initialized = true; if (SupportsInterstitialAds()) { foreach (string id in Settings.GetInterstitialsIds()) { _interstitialAds.Add(id, null); } } if (SupportsRewardedAds()) { foreach (string id in Settings.GetRewardedIds()) { _rewardedAds.Add(id, null); } } if (SupportsBannerAds()) { foreach (string id in Settings.GetBannerIds()) { _bannerAds.Add(id, null); } } if (SupportsLeaderboards()) { foreach (Settings.Leaderboard l in _settings.Leaderboards) { Leaderboard leaderboard = Leaderboard.IsSaved(l.Id) ? Leaderboard.Load(l.Id) : new Leaderboard(l.Id, type: l.Type); _leaderboards.Add(l.Id, leaderboard); } } if (SupportsIAP()) { _iap = new InAppPurchases(); } aTcs.SetResult(0); return(aTcs.Task); #endif }
private void CheckInitialize() { if (!_initialized) { _initialized = true; // Ads list _ads = new ReorderableList(_settings.ADs, typeof(Settings.Ad), false, true, true, true); _ads.drawElementCallback = DrawAdsListItems; _ads.drawHeaderCallback = (Rect rect) => { string name = "Ad Placements Setup"; EditorGUI.LabelField(rect, name); }; _ads.onRemoveCallback = (ReorderableList list) => { _settings.ADs.RemoveAt(list.index); EditorUtility.SetDirty(_settings); }; _ads.onAddCallback = (ReorderableList list) => { _settings.ADs.Add(new Settings.Ad()); EditorUtility.SetDirty(_settings); }; _ads.elementHeight = _listItemHeight; // IAPs list _iaps = new ReorderableList(_settings.IAPs, typeof(Settings.InAppPurchase), false, true, true, true); _iaps.drawElementCallback = DrawIAPsListItems; _iaps.drawHeaderCallback = (Rect rect) => { string name = "In App Purchases Setup"; EditorGUI.LabelField(rect, name); Rect resetButtonRect = new Rect(rect.x + rect.width - 60, rect.y, 100 - 35, EditorGUIUtility.singleLineHeight); if (GUI.Button(resetButtonRect, "RESET")) { // Erase data file if it exists InAppPurchases.Reset(); UnityEditor.AssetDatabase.Refresh(); } // We'll setup a project wide selector for mocking the currency IAPs are going to use Rect currencyCodeRect = new Rect(rect.x + 200, rect.y, 100 - 35, EditorGUIUtility.singleLineHeight); string label = "Currency"; EditorGUI.LabelField(currencyCodeRect, label); currencyCodeRect.x += 50; CurrencyCode currencyCode = _settings.CurrencyCode; CurrencyCode newCurrencyCode = (CurrencyCode)EditorGUI.EnumPopup(currencyCodeRect, currencyCode); if (newCurrencyCode != currencyCode) { _settings.CurrencyCode = newCurrencyCode; EditorUtility.SetDirty(_settings); } }; _iaps.onRemoveCallback = (ReorderableList list) => { _settings.IAPs.RemoveAt(list.index); EditorUtility.SetDirty(_settings); }; _iaps.onAddCallback = (ReorderableList list) => { _settings.IAPs.Add(new Settings.InAppPurchase()); EditorUtility.SetDirty(_settings); }; _iaps.elementHeight = _listItemHeight; // Leaderboard list _leaderboards = new ReorderableList(_settings.Leaderboards, typeof(Settings.Leaderboard), false, true, true, true); _leaderboards.drawElementCallback = DrawLeaderboardsListItems; _leaderboards.drawHeaderCallback = (Rect rect) => { string name = "Leaderboards Setup"; EditorGUI.LabelField(rect, name); }; _leaderboards.onRemoveCallback = (ReorderableList list) => { // Erase data file if it exists Leaderboard.Reset(_settings.Leaderboards[list.index].Id); UnityEditor.AssetDatabase.Refresh(); _settings.Leaderboards.RemoveAt(list.index); EditorUtility.SetDirty(_settings); }; _leaderboards.onAddCallback = (ReorderableList list) => { _settings.Leaderboards.Add(new Settings.Leaderboard()); EditorUtility.SetDirty(_settings); }; _leaderboards.elementHeight = _listItemHeight; // Analytic Events list _analyticsEvents = new ReorderableList(_settings.AnalyticsEvents, typeof(string), false, true, true, true); _analyticsEvents.drawElementCallback = DrawAnalyticEventsListItems; _analyticsEvents.drawHeaderCallback = (Rect rect) => { string name = "Analytic Events"; EditorGUI.LabelField(rect, name); }; _analyticsEvents.onRemoveCallback = (ReorderableList list) => { _settings.AnalyticsEvents.RemoveAt(list.index); EditorUtility.SetDirty(_settings); }; _analyticsEvents.onAddCallback = (ReorderableList list) => { _settings.AnalyticsEvents.Add(""); EditorUtility.SetDirty(_settings); }; _analyticsEvents.elementHeight = _listItemHeight; } }