private void SetLogos(bool show) { if (!show) { PlayerSettings.SplashScreen.logos = null; PlayerSettings.SplashScreen.backgroundColor = Color.black; return; } //设置闪屏背景颜色 PlayerSettings.SplashScreen.backgroundColor = Color.white; var logo1 = new PlayerSettings.SplashScreenLogo { duration = 2f, //设置闪屏logo logo = AssetDatabase.LoadAssetAtPath <Sprite>(logo1_Path) }; var logo2 = new PlayerSettings.SplashScreenLogo { duration = 2f, //设置闪屏logo logo = AssetDatabase.LoadAssetAtPath <Sprite>(logo2_Path) }; PlayerSettings.SplashScreen.logos = new PlayerSettings.SplashScreenLogo[2] { logo1, logo2 }; }
private void SetMetadata() { PlayerSettings.productName = _brandingConfig.Metadata.AppName; PlayerSettings.bundleVersion = _brandingConfig.Metadata.Version; PlayerSettings.applicationIdentifier = _brandingConfig.Metadata.BundleId; var logos = new PlayerSettings.SplashScreenLogo[_brandingConfig.Metadata.SplashScreenLogos.Length]; for (var i = 0; i < _brandingConfig.Metadata.SplashScreenLogos.Length; i++) { logos[i].logo = _brandingConfig.Metadata.SplashScreenLogos[i]; } PlayerSettings.SplashScreen.logos = logos; PlayerSettings.SplashScreen.background = _brandingConfig.Metadata.SplashScreenBackground; GameObject.Find("ContentManager").GetComponent <ContentRequest>().SetUrl(_brandingConfig.Metadata.AuthoringToolUrl); GameObject.Find("ContentManager").GetComponent <ContentRequest>().SetFileName(_brandingConfig.Metadata.FileName); GameObject.Find("ContentManager").GetComponent <ContentRequest>().SetResourcesFileName(_brandingConfig.Metadata.ResourcesFileName); }
/// <summary> /// Sets the splash settings for the application in <see cref="PlayerSettings.SplashScreen"/>. /// </summary> private static void SetSplashSettings() { var boseLogoAssetPath = AssetDatabase.GUIDToAssetPath(BOSE_LOGO_ICON_GUID); var boseLogo = AssetDatabase.LoadAssetAtPath <Sprite>(boseLogoAssetPath); var splashScreenLogo = new PlayerSettings.SplashScreenLogo() { logo = boseLogo, duration = 2 }; var splashColor = Color.black; splashColor.a = 1f; PlayerSettings.SplashScreen.show = true; PlayerSettings.SplashScreen.unityLogoStyle = PlayerSettings.SplashScreen.UnityLogoStyle.LightOnDark; PlayerSettings.SplashScreen.backgroundColor = splashColor; PlayerSettings.SplashScreen.animationMode = PlayerSettings.SplashScreen.AnimationMode.Static; PlayerSettings.SplashScreen.drawMode = PlayerSettings.SplashScreen.DrawMode.UnityLogoBelow; PlayerSettings.SplashScreen.logos = new[] { splashScreenLogo }; }
private void DrawSplashLogos() { var logos = PlayerSettings.SplashScreen.logos.ToList(); for (int i = 0; i < logos.Count; i++) { var logo = logos[i]; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); var newLogo = EditorGUIExtensions.SpriteField($"Logo {i}", logo.logo); if (_settings.SelectedPreferences.splash.Required && !_settings.SelectedPreferences.splash.logos.Contains(logo.logo)) { EditorGUILayout.HelpBox("This logo wasn't expected by preferences.", MessageType.Warning); } if (EditorGUI.EndChangeCheck()) { logo.logo = newLogo; logos[i] = logo; PlayerSettings.SplashScreen.logos = logos.ToArray(); } if (GUILayout.Button("Remove")) { logos.RemoveAt(i--); PlayerSettings.SplashScreen.logos = logos.ToArray(); } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add logo")) { logos.Add(new PlayerSettings.SplashScreenLogo()); PlayerSettings.SplashScreen.logos = logos.ToArray(); } foreach (var prefLogo in _settings.SelectedPreferences.splash.logos) { if (prefLogo == null) { continue; } bool found = false; foreach (var existingLogo in logos) { if (existingLogo.logo == prefLogo) { found = true; } } if (!found) { if (_settings.SelectedPreferences.splash.Required && EditorGUIExtensions.DrawFixHelpBox($"Logo {prefLogo.name} wasn't added.")) { var newLogo = new PlayerSettings.SplashScreenLogo(); newLogo.logo = prefLogo; logos.Add(newLogo); PlayerSettings.SplashScreen.logos = logos.ToArray(); } } } if (_settings.SelectedPreferences.splash.Required && (logos == null || logos.Count <= 0)) { EditorGUILayout.HelpBox("App has logos.", MessageType.Warning); } }
public void ConfigureForBuild() { var config = ApplicationConfig.FindMainConfig(); if (config == null) { return; } config.LoadedEdition = this; PlayerSettings.productName = ProductName; PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, Android_BundleIdentifier); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, iOS_BundleIdentifier); PlayerSettings.bundleVersion = BundleVersion; PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, new[] { Android_AppIcon }); PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.iOS, new[] { iOS_AppIcon }); var logos = new PlayerSettings.SplashScreenLogo[SplashLogos.Length]; for (int i = 0; i < SplashLogos.Length; i++) { logos[i] = new PlayerSettings.SplashScreenLogo { duration = 2f, logo = SplashLogos[i] }; } PlayerSettings.SplashScreen.logos = logos; List <EditionConfig> editionsToUse = new List <EditionConfig>(); if (IsMultiEdition) { foreach (var edition in ChildEditions) { editionsToUse.Add(edition); } } else { editionsToUse.Add(this); } // Move folders based on language... var languagesToUse = new HashSet <LanguageCode>(); foreach (var edition in editionsToUse) { languagesToUse.Add(edition.NativeLanguage); languagesToUse.UnionWith(edition.SupportedNativeLanguages); languagesToUse.Add(edition.LearningLanguage); } for (int iLang = 0; iLang < (int)LanguageCode.COUNT; iLang++) { var langCode = (LanguageCode)iLang; if (langCode == LanguageCode.NONE) { continue; } string pascalcaseName = langCode.ToString(); var words = pascalcaseName.Split('_'); pascalcaseName = ""; for (var i = 0; i < words.Length; i++) { var word = words[i]; pascalcaseName += $"{Char.ToUpperInvariant(word[0])}{word.Substring(1)}"; if (i < words.Length - 1) { pascalcaseName += "_"; } } var assetGroupSchemaPath = $"Assets/AddressableAssetsData/AssetGroups/Schemas/{pascalcaseName}_BundledAssetGroupSchema.asset"; var schema = AssetDatabase.LoadAssetAtPath <BundledAssetGroupSchema>(assetGroupSchemaPath); if (schema == null) { Debug.LogWarning($"Language {langCode} is not setup with Addressables. No schema found at '{assetGroupSchemaPath}'"); continue; } if (languagesToUse.Contains(langCode)) { schema.IncludeInBuild = true; Debug.Log($"Enabling language: {langCode}"); } else { schema.IncludeInBuild = false; Debug.Log($"Disabling language: {langCode}"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.LogWarning($"Set '{EditionTitle}' as active Edition"); // Write ProjectSettings.asset var path = $"{Application.dataPath}/../ProjectSettings/ProjectSettings.asset"; var readSr = File.OpenText(path); var newFile = new StringBuilder(); while (!readSr.EndOfStream) { var line = readSr.ReadLine(); if (line.Contains("cloudProjectId:")) { var newLine = $" cloudProjectId: {UnityProjectId}"; Debug.LogError("Overriding line: " + line + " with " + newLine); line = newLine; } newFile.AppendLine(line); } readSr.Close(); var writeSr = new StreamWriter(path, false); writeSr.Write(newFile); writeSr.Close(); AssetDatabase.Refresh(); }
/// <summary> /// 设置安卓的spalshicon 可通用 /// </summary> private static void SetAndroidSpalshIcon(string platformName, AppGameConfig gameCfg) { //先清理资源文件 FileUtils.CleanDirectory(UnityEngine.Application.dataPath + "/PlatformData/"); AssetDatabase.Refresh(); #region unity splash #if UNITY_5_6_OR_NEWER { List <PlayerSettings.SplashScreenLogo> logoList = new List <PlayerSettings.SplashScreenLogo>(); string screenSourcePath = string.Format(Directory.GetParent(UnityEngine.Application.dataPath) + "/PlatformData/{0}/android/splash_screen/", platformName);//源目录文件夹 string screenTargetPath = string.Format(UnityEngine.Application.dataPath + "/PlatformData/{0}/android/splash_screen/", platformName); //存在splash文件时,拷贝到unity if (Directory.Exists(screenSourcePath)) { if (Directory.Exists(screenTargetPath)) { AssetBuilderCtrl.CleanDirectory(screenTargetPath); } Directory.CreateDirectory(screenTargetPath); AssetBuilderCtrl.CopyDirectory(screenSourcePath, screenTargetPath);//拷贝文件夹资源 AssetDatabase.Refresh(); screenTargetPath = string.Format("Assets/PlatformData/{0}/android/splash_screen/", platformName); } if (Directory.Exists(screenTargetPath)) { for (int i = 1; i <= 3; i++) { string logoPath = screenTargetPath + i + ".png"; if (!File.Exists(logoPath)) { logoPath = screenTargetPath + i + ".jpg"; } if (File.Exists(logoPath)) { Sprite logoSp = (Sprite)AssetDatabase.LoadAssetAtPath(logoPath, typeof(Sprite)); if (logoSp == null) { TextureImporter import = AssetImporter.GetAtPath(logoPath) as TextureImporter; import.textureType = TextureImporterType.Sprite; import.spriteImportMode = SpriteImportMode.Single; import.mipmapEnabled = false; import.sRGBTexture = true; import.alphaSource = TextureImporterAlphaSource.FromInput; import.anisoLevel = 16; AssetDatabase.ImportAsset(logoPath); logoSp = (Sprite)AssetDatabase.LoadAssetAtPath(logoPath, typeof(Sprite)); } if (logoSp != null) { PlayerSettings.SplashScreenLogo logo = PlayerSettings.SplashScreenLogo.Create(2.5f, logoSp); logoList.Add(logo); } } } PlayerSettings.SplashScreen.logos = logoList.ToArray(); PlayerSettings.SplashScreen.drawMode = PlayerSettings.SplashScreen.DrawMode.AllSequential; PlayerSettings.SplashScreen.backgroundColor = Color.white; PlayerSettings.SplashScreen.unityLogoStyle = PlayerSettings.SplashScreen.UnityLogoStyle.DarkOnLight; PlayerSettings.SplashScreen.show = true; PlayerSettings.SplashScreen.showUnityLogo = false; } else { PlayerSettings.SplashScreen.show = false; PlayerSettings.SplashScreen.showUnityLogo = false; } // Directory.Delete(screenTargetPath);//设置完后删除? } #endif #endregion #region splash { string screenSourcePath = string.Format(Directory.GetParent(UnityEngine.Application.dataPath) + "/PlatformData/{0}/android/assets/splash/", platformName);//源目录文件夹 string screenTargetPath = string.Format(UnityEngine.Application.dataPath + "/PlatformData/{0}/android/assets/splash/", platformName); //存在splash文件时,拷贝到unity if (Directory.Exists(screenSourcePath)) { if (Directory.Exists(screenTargetPath)) { AssetBuilderCtrl.CleanDirectory(screenTargetPath); } Directory.CreateDirectory(screenTargetPath); AssetBuilderCtrl.CopyDirectory(screenSourcePath, screenTargetPath);//拷贝文件夹资源 AssetDatabase.Refresh(); screenTargetPath = string.Format("Assets/PlatformData/{0}/android/assets/splash/", platformName); } int splashCount = 0; for (int i = 1; i <= 3; i++) { string iconPath = string.Format("{0}{1}.png", screenTargetPath, i); Texture2D tex2d = AssetDatabase.LoadAssetAtPath <Texture2D>(iconPath); if (tex2d != null) { splashCount++; PlayerSettings.showUnitySplashScreen = false; #if UNITY_2017_1_OR_NEWER PlayerSettings.virtualRealitySplashScreen = tex2d; #endif } else { break; } } AssetDatabase.Refresh(); gameCfg.Splash = splashCount; } PlayerSettings.showUnitySplashScreen = false; #endregion #region Set icon { string screenSourcePath = string.Format(Directory.GetParent(UnityEngine.Application.dataPath) + "/PlatformData/{0}/android/icon/", platformName);//源目录文件夹 string screenTargetPath = string.Format(UnityEngine.Application.dataPath + "/PlatformData/{0}/android/icon/", platformName); if (Directory.Exists(screenSourcePath)) { if (Directory.Exists(screenTargetPath)) { AssetBuilderCtrl.CleanDirectory(screenTargetPath); } Directory.CreateDirectory(screenTargetPath); AssetBuilderCtrl.CopyDirectory(screenSourcePath, screenTargetPath);//拷贝文件夹资源 AssetDatabase.Refresh(); } screenTargetPath = string.Format("Assets/PlatformData/{0}/android/icon/", platformName); int[] sizeList = PlayerSettings.GetIconSizesForTargetGroup(BuildTargetGroup.Android); Texture2D[] icons = new Texture2D[sizeList.Length]; for (int i = 0; i < sizeList.Length; i++) { string iconPath = string.Format("{0}icon_{1}.png", screenTargetPath, sizeList[i]); Texture2D textIcon = (Texture2D)AssetDatabase.LoadAssetAtPath(iconPath, typeof(Texture2D)); icons[i] = textIcon; } PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, icons); } #endregion }