public static void FirstProjectLaunch() { if (!FindObjectOfType <FMCGameManager>()) { new GameObject("FMC").AddComponent <FMCGameManager>(); EditorSceneManager.SaveScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene(), fmc.game.GameSceneDefaultPath); FMCGameSettings Target = FMCGameSettings.LoadOrCreateGameSettings(); //Searching scenes in project if (string.IsNullOrEmpty(Target.Public.gameSceneGUID)) { SceneAsset s = GetSceneFromGUID(null, fmc.game.GameSceneDefaultName); if (s) { Target.Public.gameSceneGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetOrScenePath(s)); } } if (string.IsNullOrEmpty(Target.Public.splashScreenSceneGUID)) { SceneAsset s = GetSceneFromGUID(null, fmc.game.SplashScreenSceneName); if (s) { Target.Public.splashScreenSceneGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetOrScenePath(s)); } } UpdateUnitySettings(Target); } }
static void CreateFMCInfoFile() { var gameSettings = FMCGameSettings.LoadOrCreateGameSettings(); FileStream fs = new FileStream(BuildFolder + "fmcinfo.xml", FileMode.Create); XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8); w.Formatting = Formatting.Indented; w.WriteStartDocument(); w.WriteStartElement("data"); { w.WriteStartElement("gametitle"); w.WriteString(gameSettings.Public.gameTitle); w.WriteEndElement(); w.WriteStartElement("bundleid"); w.WriteString(gameSettings.Public.BundleId); w.WriteEndElement(); } w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); fs.Close(); }
public FMCFramework() { _instance = this; GameSettings = FMCGameSettingsPublic.GetGameSettings(); if (GameSettings == null) { #if UNITY_EDITOR Debug.LogWarning("FMC: unable to find game settings. Creating a new settings asset..."); FMCGameSettings.LoadOrCreateGameSettings(); #else Debug.LogError("FMC error: unable to find game settings. Check FMC settings."); #endif } GameInstance = new FMCGameInstance(); SaveSystem = new FMCSaveSystem(); Ads = new FMCAds(); #if ACTIVATE_FIREBASE if (GameSettings.enableAnalytics) { Analytics = new FMCFirebaseAnalytics(); } else #endif { Analytics = new FMCTestAnalytics(); } //Binding game events to analytics fmc.events.ResetGame += () => { fmc.analytics.Event(fmc.analytics.EventName_ResetGame); }; fmc.events.GameStarted += () => { fmc.analytics.Event(fmc.analytics.EventName_GameStarted); }; fmc.events.NewBestScore += (long score) => { fmc.analytics.Event(fmc.analytics.EventName_NewBestScore, fmc.analytics.EventParamName_Score, score); }; fmc.events.GameOver += (long score) => { fmc.analytics.Event(fmc.analytics.EventName_GameOver, fmc.analytics.EventParamName_Score, score); }; fmc.events.ResumedFromGameOver += () => { fmc.analytics.Event(fmc.analytics.EventName_ResumeFromGameOver); }; fmc.events.LevelUp += (int newLevel) => { fmc.analytics.Event(fmc.analytics.EventName_LevelUp); }; if (fmc.game.Settings.enableLevelSystem) { if (fmc.game.Settings.testLevel > 0) { fmc.game.Level = fmc.game.Settings.testLevel; fmc.game.Experience = 30; } } else { fmc.game.Level = 1; fmc.game.Experience = 0; } }
static void FillAndroidPublishingSettings() { var gameSettings = FMCGameSettings.LoadOrCreateGameSettings(); if (File.Exists(gameSettings.Private.keystoreName)) { PlayerSettings.Android.keystoreName = gameSettings.Private.keystoreName; PlayerSettings.Android.keystorePass = gameSettings.Private.keystorePass; PlayerSettings.Android.keyaliasName = gameSettings.Private.keyaliasName; PlayerSettings.Android.keyaliasPass = gameSettings.Private.keyaliasPass; } else { Debug.Log("Keystore file not found, unable to sign!"); } }
public static void UpdateUnitySettings(FMCGameSettings Target) { List <string> scenePaths = new List <string>(); string splashScreenScenePath = AssetDatabase.GUIDToAssetPath(Target.Public.splashScreenSceneGUID); string gameScenePath = AssetDatabase.GUIDToAssetPath(Target.Public.gameSceneGUID); if (!fmc.utils.IsNullOrWhiteSpace(splashScreenScenePath)) { scenePaths.Add(splashScreenScenePath); } if (!fmc.utils.IsNullOrWhiteSpace(gameScenePath)) { scenePaths.Add(gameScenePath); } SetEditorBuildSettingsScenes(scenePaths); SetAllIcons(Target.Public.defaultIcon, Target.Public.iOSIcon, Target.Public.androidIcon, Target.Public.adaptiveIconBackground, Target.Public.adaptiveIconForeground); PlayerSettings.companyName = Target.Public.companyName; PlayerSettings.productName = Target.Public.gameTitle; PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait; //Currently FMC is for portrait games EditorSettings.defaultBehaviorMode = Target.Public.is2DGame ? EditorBehaviorMode.Mode2D : EditorBehaviorMode.Mode3D; PlayerSettings.iOS.appleDeveloperTeamID = Target.Private.appleDeveloperTeamID; PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, Target.Public.BundleId); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, Target.Public.BundleId); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Standalone, Target.Public.BundleId); //Updating define symbols string symbols = ""; if (Target.Public.enableAds) { symbols += FMCAds.PrecompileDirectiveName + ";"; } if (Target.Public.enableAnalytics) { symbols += FMCAnalytics.PrecompileDirectiveName + ";"; } SetScriptingDefineSymbols(symbols); }
static void Build(BuildTarget target) { var gameSettings = FMCGameSettings.LoadOrCreateGameSettings(); string iOSBuildPath = BuildFolder + gameSettings.Public.InternalGameName + "_xcode"; BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); buildPlayerOptions.scenes = GetBuildScenes(); if (target == BuildTarget.Android) { FillAndroidPublishingSettings(); buildPlayerOptions.locationPathName = BuildFolder + gameSettings.Public.InternalGameName + ".apk"; } else //iOS { buildPlayerOptions.locationPathName = iOSBuildPath; } buildPlayerOptions.target = target; buildPlayerOptions.options = BuildOptions.None; BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary; if (summary.result == BuildResult.Succeeded) { Debug.Log("Build succeeded: " + summary.totalSize + " bytes"); if (target == BuildTarget.iOS) { ChangeXcodePlist(iOSBuildPath); Debug.Log("Updated Xcode plist file to declare it does not uses ecryption."); } } if (summary.result == BuildResult.Failed) { Debug.Log("Build failed"); } }
public static bool IsValid(FMCGameSettings settings) { return(settings != null && settings.Public && settings.Private); }
void OnGUI() { // /* ColorUtility.TryParseHtmlString("#E23400", out difficultyColor); ColorUtility.TryParseHtmlString("#1F87F1", out levelDurationColor); ColorUtility.TryParseHtmlString("#238E3C", out singleScoreColor); ColorUtility.TryParseHtmlString("#B237A8", out levelUpRateColor); /*/ * difficultyColor = EditorGUILayout.ColorField(difficultyColor); * levelDurationColor = EditorGUILayout.ColorField(levelDurationColor); * singleScoreColor = EditorGUILayout.ColorField(singleScoreColor); * levelUpRateColor = EditorGUILayout.ColorField(levelUpRateColor); * //*/ FMCGameSettings.LoadOrCreateGameSettings(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); //************************* GAME GUISpace(); Target.Public.enableLevelSystem = EditorGUILayout.Toggle("Enable level system", Target.Public.enableLevelSystem); if (Target.Public.enableLevelSystem) { EditorGUILayout.LabelField("Testing", EditorStyles.miniBoldLabel); Target.Public.testLevel = Mathf.Clamp(Target.Public.testLevel, 0, Target.Public.maxLevels); string debugText = "Test level"; if (Target.Public.testLevel < 1) { debugText += " (OFF)"; } Target.Public.testLevel = EditorGUILayout.IntSlider(debugText, Target.Public.testLevel, 0, Target.Public.maxLevels); Target.Public.quickLevelUp = EditorGUILayout.Toggle("Quick level-up", Target.Public.quickLevelUp); EditorGUILayout.LabelField("Level system", EditorStyles.miniBoldLabel); Target.Public.maxLevels = EditorGUILayout.IntSlider("Max levels", Target.Public.maxLevels, 3, 100); GUISpace(); Target.Public.difficulty = GrowthField(Target.Public.difficulty, 1, 1); Func <int, float> difficultyFunc = (x) => { return(Target.Public.difficulty.GetFloatValue(x)); }; DrawHistogramCurve(1, Target.Public.maxLevels, difficultyFunc, difficultyColor); GUISpace(); Target.Public.singleScoreAtLevel = GrowthField(Target.Public.singleScoreAtLevel, 10, 100); Func <int, float> singleScoreFunc = (x) => { return(Target.Public.singleScoreAtLevel.GetValue(x)); }; DrawHistogramCurve(1, Target.Public.maxLevels, singleScoreFunc, singleScoreColor); GUISpace(); Target.Public.levelDuration = GrowthField(Target.Public.levelDuration, 100, 100000); Func <int, float> levelDurationFunc = (x) => { return(Target.Public.levelDuration.GetValue(x)); }; DrawHistogramCurve(1, Target.Public.maxLevels, levelDurationFunc, levelDurationColor); GUISpace(); recapTableOpen = EditorGUILayout.Foldout(recapTableOpen, "Recap table", EditorStyles.foldout); if (recapTableOpen) { DrawTable(Target.Public.maxLevels, (int)position.width); } } else { Target.Public.singleScoreAtLevel.firstLevelValue = EditorGUILayout.Slider("Single score", (int)Target.Public.singleScoreAtLevel.firstLevelValue, 10, 100); } EditorGUILayout.EndScrollView(); Target.SetDirty(); }
static Startup() { FMCGameSettings.LoadOrCreateGameSettings(); //automatically creates new Scriptable Objects if needed. //Debug.Log("FMC Settings initialized!");//Use it when debugging }
void OnGUI() { FMCGameSettings.LoadOrCreateGameSettings(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); //************************* GAME GUISpace(); EditorGUILayout.LabelField("Game", EditorStyles.boldLabel); Target.Public.gameTitle = EditorGUILayout.TextField("Game title", Target.Public.gameTitle); Target.Public.tutorialMessage = EditorGUILayout.TextField("Tutorial message", Target.Public.tutorialMessage); Target.Public.gameSceneGUID = SceneField("Game scene", Target.Public.gameSceneGUID, fmc.game.GameSceneDefaultName); Target.Public.is2DGame = EditorGUILayout.Toggle("Is 2D game", Target.Public.is2DGame); Target.Public.gameLogo = SquareField("Game logo", Target.Public.gameLogo, null, 70); //************************* ICONS GUISpace(); EditorGUILayout.LabelField("Icons", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); Target.Public.defaultIcon = SquareField("Default", Target.Public.defaultIcon, null, 100); Target.Public.iOSIcon = SquareField("iOS", Target.Public.iOSIcon, Target.Public.defaultIcon); Target.Public.androidIcon = SquareField("Android", Target.Public.androidIcon, Target.Public.defaultIcon); GUILayout.BeginVertical(); Target.Public.adaptiveIconBackground = SquareField("Adaptive Back", Target.Public.adaptiveIconBackground, Target.Public.defaultIcon); Target.Public.adaptiveIconForeground = SquareField("Adaptive Fore", Target.Public.adaptiveIconForeground, Target.Public.defaultIcon); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //************************* ADVERTISEMENT GUISpace(3); EditorGUILayout.LabelField("Advertisement", EditorStyles.boldLabel); Target.Public.enableAds = EditorGUILayout.Toggle("Enable Ads", Target.Public.enableAds); if (Target.Public.enableAds) { //Admob Android EditorGUILayout.LabelField("Admob - Android", EditorStyles.miniBoldLabel); Target.Public.AndroidAdMobUseTestIds = EditorGUILayout.Toggle("Use test ids", Target.Public.AndroidAdMobUseTestIds); EditorGUI.BeginDisabledGroup(Target.Public.AndroidAdMobUseTestIds); Target.Public.AndroidAppId = EditorGUILayout.TextField("App id", Target.Public.AndroidAppId); Target.Public.AndroidAdBannerUnitId = EditorGUILayout.TextField("Banner unit id", Target.Public.AndroidAdBannerUnitId); Target.Public.AndroidAdInterstitialUnitId = EditorGUILayout.TextField("Interstitials unit id", Target.Public.AndroidAdInterstitialUnitId); EditorGUI.EndDisabledGroup(); //Admob iOS EditorGUILayout.LabelField("Admob - iOS", EditorStyles.miniBoldLabel); Target.Public.iOSAdMobUseTestIds = EditorGUILayout.Toggle("Use test ids", Target.Public.iOSAdMobUseTestIds); EditorGUI.BeginDisabledGroup(Target.Public.iOSAdMobUseTestIds); Target.Public.iOSAppId = EditorGUILayout.TextField("App id", Target.Public.iOSAppId); Target.Public.iOSAdBannerUnitId = EditorGUILayout.TextField("Banner unit id", Target.Public.iOSAdBannerUnitId); Target.Public.iOSAdInterstitialUnitId = EditorGUILayout.TextField("Interstitials unit id", Target.Public.iOSAdInterstitialUnitId); EditorGUI.EndDisabledGroup(); if (!AssetDatabase.IsValidFolder("Assets/GoogleMobileAds")) { EditorGUILayout.HelpBox("It looks like you don't have Admob. The project won't compile. Install the Admob Unity SDK.", MessageType.Warning); } EditorGUILayout.HelpBox("Remember to enable also Unity Ads: FMC uses it for videos.", MessageType.Info); } GUISpace(); EditorGUILayout.LabelField("Analytics", EditorStyles.boldLabel); Target.Public.enableAnalytics = EditorGUILayout.Toggle("Enable Analytics", Target.Public.enableAnalytics); if (Target.Public.enableAnalytics) { if (!AssetDatabase.IsValidFolder("Assets/Firebase")) { EditorGUILayout.HelpBox("It looks like you don't have Firebase. The project won't compile. Install the Firebase Unity SDK.", MessageType.Warning); } } //************************* ADVANCED GUISpace(); advancedOptionOpened = EditorGUILayout.Foldout(advancedOptionOpened, "Stuff you usually don't need to change", EditorStyles.foldout); if (advancedOptionOpened) { //************************* SPLASH SCREEN SETTINGS EditorGUILayout.LabelField("Splash screen", EditorStyles.boldLabel); Target.Public.splashScreenSceneGUID = SceneField("Splash screen scene", Target.Public.splashScreenSceneGUID, fmc.game.SplashScreenSceneName); Target.Public.splashScreenDuration = EditorGUILayout.FloatField("Duration of splash screen in seconds", Target.Public.splashScreenDuration); GUISpace(); GUILayout.BeginHorizontal(); Target.Public.splashScreenBackground = SquareField("Splash screen background", Target.Public.splashScreenBackground, null, 100); Target.Public.companyLogo = SquareField("Company logo", Target.Public.companyLogo, null, 100); if (!Target.Public.companyLogo) { Target.Public.companyLogo = Resources.Load <Sprite>("companyLogo34"); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //************************* BUILDING AND SHIPPING EditorGUILayout.LabelField("Building and shipping", EditorStyles.boldLabel); EditorGUILayout.LabelField("Local path", Target.Public.GamePath); EditorGUILayout.LabelField("Internal name", Target.Public.InternalGameName); Target.Public.bundleIdPrefix = EditorGUILayout.TextField("Prefix of bundle id", Target.Public.bundleIdPrefix); EditorGUILayout.LabelField("Bundle id (iOS+Android)", Target.Public.BundleId); Target.Public.companyName = EditorGUILayout.TextField("Company name", Target.Public.companyName); Target.Private.appleDeveloperTeamID = EditorGUILayout.TextField("Apple signing team ID", Target.Private.appleDeveloperTeamID); Target.Private.keystoreName = EditorGUILayout.TextField("Keystore name", Target.Private.keystoreName); Target.Private.keystorePass = EditorGUILayout.TextField("Keystore pass", Target.Private.keystorePass); Target.Private.keyaliasName = EditorGUILayout.TextField("Keystore alias name", Target.Private.keyaliasName); Target.Private.keyaliasPass = EditorGUILayout.TextField("Keystore pass", Target.Private.keyaliasPass); //************************* BUILDING AND SHIPPING GUISpace(); EditorGUILayout.LabelField("Privacy policies", EditorStyles.boldLabel); Target.Public.companyPrivacyPolicyURL = EditorGUILayout.TextField("Company URL", Target.Public.companyPrivacyPolicyURL); Target.Public.unityPrivacyPolicyURL = EditorGUILayout.TextField("Unity URL", Target.Public.unityPrivacyPolicyURL); Target.Public.googlePrivacyPolicyURL = EditorGUILayout.TextField("Google URL", Target.Public.googlePrivacyPolicyURL); } /* * SpriteField("Background", "backgroundAtlas", "backgroundSpriteName"); * SpriteField("Company logo", "companyAtlas", "companySpriteName"); * SpriteField("Game logo", "gameLogoAtlas", "gameLogoSpriteName"); */ GUISpace(5); EditorGUILayout.EndScrollView(); UpdateUnitySettings(Target); Target.SetDirty(); }
/// <summary> /// This method is called from the fmc toolkit. /// It is used to create the game settings object and to set the unity settings accordingly. /// </summary> public static void UpdateUnitySettingsFromToolkit() { FMCGameSettings Target = FMCGameSettings.LoadOrCreateGameSettings(); UpdateUnitySettings(Target); }