private void DrawOrientation(UIOrientation uIOrientation) { EditorGUI.BeginChangeCheck(); bool enabled = _target.deviceOrientation.allowed.Contains(uIOrientation); var value = EditorGUILayout.Toggle(uIOrientation.ToString(), enabled); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_target, "Edited Build Preferences"); if (enabled) { if (_target.deviceOrientation.allowed.Count > 1) { _target.deviceOrientation.allowed.Remove(uIOrientation); } else { Debug.LogError("You cannot remove all orientations"); } } else { _target.deviceOrientation.allowed.Add(uIOrientation); } } }
private void UpdateAllowedOrientations(UIOrientation orientation) { bool isAutoRotation = (orientation == UIOrientation.AutoRotation); m_AllowedOrienations.style.visibility = isAutoRotation ? Visibility.Visible : Visibility.Hidden; m_AllowedOrienations.style.position = isAutoRotation ? Position.Relative : Position.Absolute; }
public void ResolutionScalingInitializedCorrectly(UIOrientation orientation, int screenWidth, int screenHeight, float screenDpi, int scaledDpi) { PlayerSettings.defaultInterfaceOrientation = orientation; var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); serializedSettings.FindProperty("resolutionScalingMode").intValue = 1; serializedSettings.FindProperty("targetPixelDensity").intValue = scaledDpi; serializedSettings.ApplyModifiedPropertiesWithoutUndo(); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations, screenWidth, screenHeight, screenDpi); var testWindow = new TestWindow(); m_Simulation = new ScreenSimulation(testDevice, m_InputTest, new SimulationPlayerSettings(), testWindow); if (screenDpi >= scaledDpi) { var scale = scaledDpi / screenDpi; var expectedResolution = orientation.IsLandscape() ? new Vector2((int)(screenHeight * scale), (int)(screenWidth * scale)) : new Vector2((int)(screenWidth * scale), (int)(screenHeight * scale)); Assert.AreEqual(expectedResolution, testWindow.TargetSize); } else { var expectedResolution = orientation.IsLandscape() ? new Vector2(screenHeight, screenWidth) : new Vector2(screenWidth, screenHeight); Assert.AreEqual(expectedResolution, testWindow.TargetSize); } }
public SimulationPlayerSettings() { var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); resolutionScalingMode = (ResolutionScalingMode)serializedSettings.FindProperty("resolutionScalingMode").intValue; targetDpi = serializedSettings.FindProperty("targetPixelDensity").intValue; androidStartInFullscreen = serializedSettings.FindProperty("androidStartInFullscreen").boolValue; androidRenderOutsideSafeArea = serializedSettings.FindProperty("androidRenderOutsideSafeArea").boolValue; defaultOrientation = PlayerSettings.defaultInterfaceOrientation; allowedPortrait = PlayerSettings.allowedAutorotateToPortrait; allowedPortraitUpsideDown = PlayerSettings.allowedAutorotateToPortraitUpsideDown; allowedLandscapeLeft = PlayerSettings.allowedAutorotateToLandscapeLeft; allowedLandscapeRight = PlayerSettings.allowedAutorotateToLandscapeRight; if (!PlayerSettings.GetUseDefaultGraphicsAPIs(BuildTarget.Android)) { androidGraphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.Android); } if (!PlayerSettings.GetUseDefaultGraphicsAPIs(BuildTarget.iOS)) { iOSGraphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.iOS); } }
internal static void SetScreenOrientation(UIOrientation defaultOrientation, bool allowedPortrait, bool allowedPortraitUpsideDown, bool allowedLandscapeRight, bool allowedLandscapeLeft) { UnityEditor.PlayerSettings.defaultInterfaceOrientation = defaultOrientation; UnityEditor.PlayerSettings.allowedAutorotateToPortrait = allowedPortrait; UnityEditor.PlayerSettings.allowedAutorotateToPortraitUpsideDown = allowedPortraitUpsideDown; UnityEditor.PlayerSettings.allowedAutorotateToLandscapeRight = allowedLandscapeRight; UnityEditor.PlayerSettings.allowedAutorotateToLandscapeLeft = allowedLandscapeLeft; }
static void CheckAndApplyOrientationSettings() { if (!mInitialized || PlayerSettings.defaultInterfaceOrientation != mUIOrientation) { mInitialized = true; mUIOrientation = PlayerSettings.defaultInterfaceOrientation; SetOrientationInAndroidManifest(OrientationMapping[mUIOrientation]); } }
static void CheckAndApplyOrientationSettings() { if (!mInitialized || PlayerSettings.defaultInterfaceOrientation != mUIOrientation) { mInitialized = true; mUIOrientation = PlayerSettings.defaultInterfaceOrientation; SetOrientationInAndroidManifest(OrientationMapping[mUIOrientation]); } }
static void BuildProjectTarget(UIOrientation landscapeOrientation, string landscapeSuffix) { try { # if UNITY_2018 PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto; PlayerSettings.Android.targetArchitectures = AndroidArchitecture.All; // ARM64 PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP); # elif UNITY_2017
private static void Load() { var scriptable = GetAllInstances <SaveScriptable>(); company = scriptable.Company; product = scriptable.Product; version = scriptable.Version; icon = scriptable.icon; orientation = scriptable.orientation; }
public void ResolutionScalingInitializedCorrectly(UIOrientation orientation, int screenWidth, int screenHeight, float screenDpi, int scaledDpi) { PlayerSettings.defaultInterfaceOrientation = orientation; var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); serializedSettings.FindProperty("resolutionScalingMode").intValue = 1; serializedSettings.FindProperty("targetPixelDensity").intValue = scaledDpi; serializedSettings.ApplyModifiedPropertiesWithoutUndo(); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations, screenWidth, screenHeight, default, screenDpi);
/// <summary> /// 初始化. /// </summary> public override void Init() { PlatformType = TPlatformType.None; MinSdkVersion = -1; MaxSdkVersion = -1; TargetSdkVersion = -1; Orientation = PlayerSettings.defaultInterfaceOrientation; Local = false; AutoSDKInit = true; AutoLogin = true; }
private string GetOrientationAttr() { UIOrientation defaultInterfaceOrientation = PlayerSettings.defaultInterfaceOrientation; string str = null; bool flag = PlayerSettings.allowedAutorotateToPortrait || PlayerSettings.allowedAutorotateToPortraitUpsideDown; bool flag2 = PlayerSettings.allowedAutorotateToLandscapeLeft || PlayerSettings.allowedAutorotateToLandscapeRight; switch (defaultInterfaceOrientation) { case UIOrientation.Portrait: str = "portrait"; break; case UIOrientation.PortraitUpsideDown: str = "reversePortrait"; break; case UIOrientation.LandscapeRight: str = "reverseLandscape"; break; case UIOrientation.LandscapeLeft: str = "landscape"; break; default: if (flag && flag2) { str = "fullSensor"; } else if (flag) { str = "sensorPortrait"; } else if (flag2) { str = "sensorLandscape"; } else { str = "unspecified"; } break; } if (PlayerSettings.virtualRealitySupported) { str = "landscape"; } return(str); }
private bool IsOrientationAndroidTVCompatible() { UIOrientation defaultInterfaceOrientation = PlayerSettings.defaultInterfaceOrientation; switch (defaultInterfaceOrientation) { case UIOrientation.LandscapeLeft: case UIOrientation.LandscapeRight: return(true); } bool flag2 = PlayerSettings.allowedAutorotateToLandscapeLeft || PlayerSettings.allowedAutorotateToLandscapeRight; return((defaultInterfaceOrientation == UIOrientation.AutoRotation) && flag2); }
public static bool IsLandscape(this UIOrientation orientation) { switch (orientation) { case UIOrientation.Portrait: case UIOrientation.PortraitUpsideDown: return false; case UIOrientation.LandscapeLeft: case UIOrientation.LandscapeRight: return true; default: throw new ArgumentException( $"Supported values are Portrait, PortraitUpsideDown, LandscapeLeft or LandscapeRight, but {orientation} provided."); } }
public void OneTimeSetUp() { m_CachedOrientation = PlayerSettings.defaultInterfaceOrientation; m_CachedAutoPortrait = PlayerSettings.allowedAutorotateToPortrait; m_CachedAutoPortraitReversed = PlayerSettings.allowedAutorotateToPortraitUpsideDown; m_CachedAutoLandscapeLeft = PlayerSettings.allowedAutorotateToLandscapeLeft; m_CachedAutoLandscapeRight = PlayerSettings.allowedAutorotateToLandscapeRight; var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); m_CachedScalingMode = serializedSettings.FindProperty("resolutionScalingMode").intValue; m_CachedScaledDPI = serializedSettings.FindProperty("targetPixelDensity").intValue; m_TestDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations); }
protected XElement CreateInitialRotationPreferenceElement(XNamespace elementNamespace, List <UIOrientation> supportedOrientations) { List <string> orientations = new List <string>(); UIOrientation defaultInterfaceOrientation = PlayerSettings.defaultInterfaceOrientation; switch (defaultInterfaceOrientation) { case UIOrientation.Portrait: case UIOrientation.PortraitUpsideDown: case UIOrientation.LandscapeRight: case UIOrientation.LandscapeLeft: this.AddRotationIfSupported(orientations, supportedOrientations, defaultInterfaceOrientation); break; case UIOrientation.AutoRotation: if (PlayerSettings.allowedAutorotateToLandscapeLeft) { this.AddRotationIfSupported(orientations, supportedOrientations, UIOrientation.LandscapeLeft); } if (PlayerSettings.allowedAutorotateToLandscapeRight) { this.AddRotationIfSupported(orientations, supportedOrientations, UIOrientation.LandscapeRight); } if (PlayerSettings.allowedAutorotateToPortrait) { this.AddRotationIfSupported(orientations, supportedOrientations, UIOrientation.Portrait); } if (PlayerSettings.allowedAutorotateToPortraitUpsideDown) { this.AddRotationIfSupported(orientations, supportedOrientations, UIOrientation.PortraitUpsideDown); } break; } if (orientations.Count > 0) { XElement element = new XElement((XName)(elementNamespace + "InitialRotationPreference")); foreach (string str in orientations) { element.Add(new XElement((XName)(elementNamespace + "Rotation"), new XAttribute("Preference", str))); } return(element); } return(null); }
public static ScreenOrientation ToScreenOrientation(UIOrientation original) { switch (original) { case UIOrientation.Portrait: return(ScreenOrientation.Portrait); case UIOrientation.PortraitUpsideDown: return(ScreenOrientation.PortraitUpsideDown); case UIOrientation.LandscapeLeft: return(ScreenOrientation.LandscapeLeft); case UIOrientation.LandscapeRight: return(ScreenOrientation.LandscapeRight); case UIOrientation.AutoRotation: return(ScreenOrientation.AutoRotation); } throw new ArgumentException($"Unexpected value of UIOrientation {original}"); }
private void OnGUI() { GUILayout.Label("Base Settings", EditorStyles.boldLabel); version = EditorGUILayout.TextField("Version", version); company = EditorGUILayout.TextField("Company", company); product = EditorGUILayout.TextField("Product", product); icon = (Texture2D)EditorGUILayout.ObjectField("Sprite", icon, typeof(Texture2D), allowSceneObjects: true); orientation = (UIOrientation)EditorGUILayout.EnumPopup(orientation); if (GUILayout.Button("Save")) { Options(); Save(); } if (GUILayout.Button("Build")) { Options(); Save(); //build } }
/// <summary> /// 应用用户自定义数据. /// </summary> /// <param name="iGameName">游戏名.</param> protected override void ApplyUserData(string iGameName) { // 本地设定 { string name = "Local"; string value = TiangeSDKSettings.GetInstance().Local.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (TiangeSDKSettings.GetInstance().Local == false) { return; } } // 游戏名 { string name = "GameName"; string value = iGameName; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // SDK自动初始化 { string name = "AutoSDKInit"; string value = TiangeSDKSettings.GetInstance().AutoSDKInit.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (TiangeSDKSettings.GetInstance().Local == false) { return; } } // 自动登录 { string name = "AutoLogin"; string value = TiangeSDKSettings.GetInstance().AutoLogin.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (TiangeSDKSettings.GetInstance().Local == false) { return; } } // 屏幕方向 { string name = "Orientation"; string value = "1"; UIOrientation _Orientation = TiangeSDKSettings.GetInstance().Orientation; if ((UIOrientation.LandscapeLeft == _Orientation) || (UIOrientation.LandscapeRight == _Orientation)) { value = "2"; } if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } } // 易接SDK 设定 if (true == TiangeSDKSettings.GetInstance().Data.Options.isOptionValid(TSDKOptions.OneSDK)) { // 易接SDK Key { string name = "zy_class_name"; string value = TiangeSDKSettings.GetInstance().Data.Options.OneSDK.ZyClassName; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 易接SDK MetaDatas { List <MetaDataInfo> _metaDatas = TiangeSDKSettings.GetInstance().Data.Options.OneSDK.MetaDatas; foreach (MetaDataInfo _metaData in _metaDatas) { if ((null != _metaData) && (false == string.IsNullOrEmpty(_metaData.Name)) && (false == string.IsNullOrEmpty(_metaData.Value))) { this.AddUserDefineNode(_metaData.Name, _metaData.Value, false); } } } } // 保存strings.xml if (null != this._stringsXml) { this._stringsXml.Save(); } }
/// <summary> /// 应用用户自定义数据. /// </summary> /// <param name="iGameName">游戏名.</param> protected override void ApplyUserData(string iGameName) { // 本地设定 { string name = "Tiange_Local"; string value = HuaweiSDKSettings.GetInstance().Local.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (HuaweiSDKSettings.GetInstance().Local == false) { return; } } // 游戏名 { string name = "Tiange_GameName"; string value = iGameName; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 自动登录 { string name = "Tiange_AutoLogin"; string value = HuaweiSDKSettings.GetInstance().AutoLogin.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (HuaweiSDKSettings.GetInstance().Local == false) { return; } } // AppID { string name = "Tiange_AppID"; string value = HuaweiSDKSettings.GetInstance().AppID; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 屏幕方向 { string name = "Tiange_Orientation"; string value = "1"; UIOrientation _Orientation = HuaweiSDKSettings.GetInstance().Orientation; if ((UIOrientation.LandscapeLeft == _Orientation) || (UIOrientation.LandscapeRight == _Orientation)) { value = "2"; } if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } } // 保存strings.xml if (null != this._stringsXml) { this._stringsXml.Save(); } }
/// <summary> /// 设置发布选项 /// </summary> /// <param name="target"></param> /// <param name="platform_info"></param> /// <param name="cache_channel_info"></param> /// <param name="cache_plat_info"></param> public static void BulidTarget(ePublishPlatformType target, PublishPlatformInfo platform_info, PublishCacheChannelInfo cache_channel_info, PublishCachePlatformInfo cache_plat_info) { BuildTarget buildTarget = GetBuildTargetByType(target); BuildTargetGroup targetGroup = GetTargetGroupByType(target); ///1.全局 PlayerSettings.companyName = "广州硕星"; PlayerSettings.productName = "机甲军团"; ///2.Resolution and Presentatio UIOrientation orientation = UIOrientation.LandscapeLeft; switch (cache_plat_info.Orientation) { case ScreenOrientation.AutoRotation: orientation = UIOrientation.AutoRotation; break; case ScreenOrientation.LandscapeLeft: orientation = UIOrientation.LandscapeLeft; break; case ScreenOrientation.LandscapeRight: orientation = UIOrientation.LandscapeRight; break; case ScreenOrientation.Portrait: orientation = UIOrientation.Portrait; break; case ScreenOrientation.PortraitUpsideDown: orientation = UIOrientation.PortraitUpsideDown; break; } PlayerSettings.defaultInterfaceOrientation = orientation; PlayerSettings.use32BitDisplayBuffer = false; ///3.Icon ///4.Splash Image PlayerSettings.SplashScreen.show = cache_plat_info.EnableUnitySplash; PlayerSettings.SplashScreen.showUnityLogo = cache_plat_info.EnableUnitySplash; ///5.RenderPath UnityEditor.Rendering.TierSettings ts = new UnityEditor.Rendering.TierSettings(); ts.renderingPath = cache_plat_info.RenderPath; UnityEditor.Rendering.EditorGraphicsSettings.SetTierSettings(targetGroup, UnityEngine.Rendering.GraphicsTier.Tier2, ts); ///6.BundleIdentifier PlayerSettings.applicationIdentifier = platform_info.BundleIdentifier; PlayerSettings.bundleVersion = platform_info.BundleVersion; ///7.预定义宏 if (!string.IsNullOrEmpty(platform_info.CompileDefine)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, platform_info.CompileDefine); } ///8.IL2CPP if (target == ePublishPlatformType.Android || target == ePublishPlatformType.iOS) { switch (cache_plat_info.ScriptBackend) { case eScriptingImplementation.IL2CPP: PlayerSettings.SetScriptingBackend(targetGroup, ScriptingImplementation.IL2CPP); break; case eScriptingImplementation.Mono2x: PlayerSettings.SetScriptingBackend(targetGroup, ScriptingImplementation.Mono2x); break; } } ///9.net版本 ApiCompatibilityLevel api_level = ApiCompatibilityLevel.NET_2_0_Subset; switch (cache_plat_info.ApiLevel) { case eApiCompatibilityLevel.NET_2_0: api_level = ApiCompatibilityLevel.NET_2_0; break; case eApiCompatibilityLevel.NET_2_0_Subset: api_level = ApiCompatibilityLevel.NET_2_0_Subset; break; } PlayerSettings.SetApiCompatibilityLevel(targetGroup, api_level); ///9.gpu蒙皮 PlayerSettings.gpuSkinning = cache_plat_info.GUPSkin; switch (target) { case ePublishPlatformType.Android: HandleAndroidPlayerSetting(buildTarget, targetGroup, platform_info, cache_channel_info, cache_plat_info); break; case ePublishPlatformType.iOS: HandleIOSPlayerSetting(buildTarget, targetGroup, platform_info, cache_channel_info, cache_plat_info); break; case ePublishPlatformType.Win64: case ePublishPlatformType.Win32: HandleWinPlayerSetting(buildTarget, targetGroup, platform_info, cache_channel_info, cache_plat_info); break; case ePublishPlatformType.WebGL: HandleWebGLPlayerSetting(buildTarget, targetGroup, platform_info, cache_channel_info, cache_plat_info); break; } }
private void AddRotationIfSupported(List <string> orientations, List <UIOrientation> supportedOrientations, UIOrientation orientation) { if (supportedOrientations.Contains(orientation)) { switch (orientation) { case UIOrientation.Portrait: orientations.Add("portrait"); break; case UIOrientation.PortraitUpsideDown: orientations.Add("portraitFlipped"); break; case UIOrientation.LandscapeRight: orientations.Add("landscapeFlipped"); break; case UIOrientation.LandscapeLeft: orientations.Add("landscape"); break; } } }
/// <summary> /// 应用用户自定义数据. /// </summary> /// <param name="iGameName">游戏名.</param> protected override void ApplyUserData(string iGameName) { // 本地设定 { string name = "Huawei_Local"; string value = HuaweiSDKSettings.GetInstance().Local.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (HuaweiSDKSettings.GetInstance().Local == false) { return; } } // 游戏名 { string name = "Huawei_GameName"; string value = iGameName; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 自动登录 { string name = "Huawei_AutoLogin"; string value = HuaweiSDKSettings.GetInstance().AutoLogin.ToString(); if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } if (HuaweiSDKSettings.GetInstance().Local == false) { return; } } // AppID { string name = "Huawei_AppID"; string value = HuaweiSDKSettings.GetInstance().AppID; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 浮标密钥 { string name = "Huawei_BuoySecret"; string value = HuaweiSDKSettings.GetInstance().BuoySecret; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 支付ID { string name = "Huawei_PayID"; string value = HuaweiSDKSettings.GetInstance().PayID; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 支付私钥 { string name = "Huawei_PayPrivateRsa"; string value = HuaweiSDKSettings.GetInstance().PayPrivateRsa; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 支付公钥 { string name = "Huawei_PayPublicRsa"; string value = HuaweiSDKSettings.GetInstance().PayPublicRsa; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // CPID { string name = "Huawei_CPID"; string value = HuaweiSDKSettings.GetInstance().CPID; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 登录签名公钥 { string name = "Huawei_LoginPublicRsa"; string value = HuaweiSDKSettings.GetInstance().LoginPublicRsa; if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value); } } // 屏幕方向 { string name = "Huawei_Orientation"; string value = "1"; UIOrientation _Orientation = HuaweiSDKSettings.GetInstance().Orientation; if ((UIOrientation.LandscapeLeft == _Orientation) || (UIOrientation.LandscapeRight == _Orientation)) { value = "2"; } if (false == string.IsNullOrEmpty(value)) { this.AddUserDefineNode(name, value, false); } } // 保存strings.xml if (null != this._stringsXml) { this._stringsXml.Save(); } }