示例#1
0
        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());
                }
            }
        }
示例#2
0
        /// <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
        }