private void SetupGraphicAPIs() { BuildTarget curBuildTarget = EditorUserBuildSettings.activeBuildTarget; // Set Build Target to Windows 64, if this is not already the case: if (curBuildTarget != BuildTarget.StandaloneWindows64) { #if UNITY_5 || UNITY_2017_1 GUIStyle yellowTextStyle = new GUIStyle(); yellowTextStyle.normal.textColor = Color.yellow; EditorGUILayout.LabelField("Use Build Settings to switch the Build Target to Standalone Windows x64.", yellowTextStyle); #else // #elif UNITY_2017_2_OR_NEWER if (GUILayout.Button("Switch")) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); } #endif } // Disable to use default graphics APIs: if (PlayerSettings.GetUseDefaultGraphicsAPIs(curBuildTarget) == true) { PlayerSettings.SetUseDefaultGraphicsAPIs(curBuildTarget, false); } // Set GraphicAPIs GlCore and DirectX 11: UnityEngine.Rendering.GraphicsDeviceType[] graphicsDeviceTypes = new UnityEngine.Rendering.GraphicsDeviceType[] { _graphicsDeviceGLCore, _graphicsDeviceDx11 }; PlayerSettings.SetGraphicsAPIs(curBuildTarget, graphicsDeviceTypes); }
private void doAPICheck() { //check the graphics API, popup warning if using unsupported gfx (dx9/11/12/legacy-openGL) UnityEngine.Rendering.GraphicsDeviceType graphicsAPI = SystemInfo.graphicsDeviceType; if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore) { //noop, everything is fine } else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D11) { //works, but needs alternate render alternateRender = true; } else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D9) { //has issues -- display warning, and needs alternate render alternateRender = true; if (apiCheckGUI == null) { apiCheckGUI = this.gameObject.AddComponent <GraphicsAPIGUI>(); apiCheckGUI.openGUI(); } } else { //unknown API -- display warning if (apiCheckGUI == null) { apiCheckGUI = this.gameObject.AddComponent <GraphicsAPIGUI>(); apiCheckGUI.openGUI(); } } }
private static void AddGraphicApi(BuildTarget target, UnityEngine.Rendering.GraphicsDeviceType type) { List <UnityEngine.Rendering.GraphicsDeviceType> deviceTypes = PlayerSettings.GetGraphicsAPIs(BuildTarget.StandaloneWindows).ToList <UnityEngine.Rendering.GraphicsDeviceType>(); if (!deviceTypes.Contains(type)) { deviceTypes.Add(type); PlayerSettings.SetGraphicsAPIs(target, deviceTypes.ToArray()); } }
private static void HandleWinPlayerSetting(BuildTarget buildTarget, BuildTargetGroup targetGroup, PublishPlatformInfo platform_info, PublishCacheChannelInfo cache_channel_info, PublishCachePlatformInfo cache_plat_info) { //图像引擎 PlayerSettings.SetUseDefaultGraphicsAPIs(buildTarget, cache_plat_info.AutoGraphicsAPI); if (!cache_plat_info.AutoGraphicsAPI) { UnityEngine.Rendering.GraphicsDeviceType[] gdt = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.Direct3D11, UnityEngine.Rendering.GraphicsDeviceType.Direct3D9 }; PlayerSettings.SetGraphicsAPIs(buildTarget, gdt); } }
public static void BuildMonitorAndroid() { //BuildLuaResource.BuildLua(false,BuildTarget.Android); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "USE_ASSETBUNDLE"); PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.StandaloneWindows, false); UnityEngine.Rendering.GraphicsDeviceType[] api = new UnityEngine.Rendering.GraphicsDeviceType[3]; api[1] = UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2; api[1] = UnityEngine.Rendering.GraphicsDeviceType.Direct3D11; api[1] = UnityEngine.Rendering.GraphicsDeviceType.Direct3D9; PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows, api); }
public static void LoadBundle() { if (BundleLoaded) { return; } string bundlePath = ""; UnityEngine.Rendering.GraphicsDeviceType type = SystemInfo.graphicsDeviceType; if (type.ToString().Contains("Direct3D")) { bundlePath = "DirectX.bundle"; } else if (type.ToString().Contains("OpenGL")) { bundlePath = "OpenGL.bundle"; } else { Util.log("Unsupported renderer."); BundleLoaded = true; return; } if (!System.IO.File.Exists(KSPUtil.ApplicationRootPath + "GameData/TextureReplacer/Shaders/" + bundlePath)) { Util.log("Bundle '" + bundlePath + "' not found."); BundleLoaded = true; return; } using (WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath + "GameData/TextureReplacer/Shaders/" + bundlePath)) { Util.log("Bundle '" + bundlePath + "' loaded."); BundleLoaded = true; AssetBundle bundle = www.assetBundle; Shader[] shaders = bundle.LoadAllAssets <Shader>(); foreach (Shader shader in shaders) { Util.log("Shader " + shader.name + " is loaded"); LoadedShaders.Add(shader.name, shader); } bundle.Unload(false); www.Dispose(); } }
static void InitProject() { //====================iOS用====================. //カメラを使用するための表記が設定されていない場合は適当に設定. if (0 == PlayerSettings.iOS.cameraUsageDescription.Length) { PlayerSettings.iOS.cameraUsageDescription = AR_KIT_CAMERA_USAGE_DESCRIPTION; } //iOSの最小ターゲットバージョンをARKit用に設定する. float iosVersion = float.Parse(PlayerSettings.iOS.targetOSVersionString); if (11.0f > iosVersion) { PlayerSettings.iOS.targetOSVersionString = "11.0"; } //iOSを64bitに設定. //0 - None, 1 - ARM64, 2 - Universal.. if (1 != PlayerSettings.GetArchitecture(BuildTargetGroup.iOS)) { PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 1); } //====================Android用====================. //AndroidのMinSDKVersionが低い場合はARCore向けに対応しているバージョンにする. if (AndroidSdkVersions.AndroidApiLevel24 > PlayerSettings.Android.minSdkVersion) { PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel24; } //ARCore向けにVulkenを使用しないようにする. if (true == PlayerSettings.GetGraphicsAPIs(BuildTarget.Android).Contains(UnityEngine.Rendering.GraphicsDeviceType.Vulkan)) { UnityEngine.Rendering.GraphicsDeviceType[] graphicsDeviceTypeArray = new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 }; PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, graphicsDeviceTypeArray); } //ARM64向けにビルドさせるためにScriptBackendをIL2CPPにする. if (ScriptingImplementation.IL2CPP != PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android)) { PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP); } //ARM64向けにビルドさせる設定にする. if (0 == (PlayerSettings.Android.targetArchitectures & AndroidArchitecture.ARM64)) { PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64; } return; }
// Set the hardwareInfo using the current system config public void SetFromCurrentConfig() { deviceType = SystemInfo.deviceType; gpuDeviceType = SystemInfo.graphicsDeviceType; gpuMemory = SystemInfo.graphicsMemorySize; gpuMultiThread = SystemInfo.graphicsMultiThreaded; gpuShaderLevel = SystemInfo.graphicsShaderLevel; maxTextureSize = SystemInfo.maxTextureSize; processorCount = SystemInfo.processorCount; processorFrequency = SystemInfo.processorFrequency; supportsComputeShaders = SystemInfo.supportsComputeShaders; supportsImageEffects = SystemInfo.supportsImageEffects; supportsShadows = SystemInfo.supportsShadows; systemMemory = SystemInfo.systemMemorySize; }
// Try to set Graphics API for the target public static bool SetGraphicsAPI(BuildTarget target) { UnityEngine.Rendering.GraphicsDeviceType[] apis = new UnityEngine.Rendering.GraphicsDeviceType[1] { target.graphicsApi }; // Make array from target API PlayerSettings.SetGraphicsAPIs(target.platform, apis); // Set API from array UnityEngine.Rendering.GraphicsDeviceType[] currentApis = PlayerSettings.GetGraphicsAPIs(target.platform); // Get the API list if (currentApis.Length == 0 || currentApis[0] != target.graphicsApi) // Check that API was assigned correctly { Debug.LogError("Invalid Graphics API supplied for platform"); // If it wasnt set return error return(false); // Return fail } else { return(true); // Return true } }
private static void HandleIOSPlayerSetting(BuildTarget buildTarget, BuildTargetGroup targetGroup, PublishPlatformInfo platform_info, PublishCacheChannelInfo cache_channel_info, PublishCachePlatformInfo cache_plat_info) { //图像引擎 PlayerSettings.SetUseDefaultGraphicsAPIs(buildTarget, cache_plat_info.AutoGraphicsAPI); if (!cache_plat_info.AutoGraphicsAPI) { UnityEngine.Rendering.GraphicsDeviceType[] gdt = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3, UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 }; PlayerSettings.SetGraphicsAPIs(buildTarget, gdt); } //多线程渲染 PlayerSettings.MTRendering = !cache_plat_info.MultiThreadRender; //编译版本 PlayerSettings.iOS.buildNumber = platform_info.BundleVersionCode.ToString(); //cpu架构 switch (cache_plat_info.TargetDevice) { case eTargetDevice.iPadOnly: PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPadOnly; break; case eTargetDevice.iPhoneAndiPad: PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneAndiPad; break; case eTargetDevice.iPhoneOnly: PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneOnly; break; } //SDK switch (cache_plat_info.IOSSdkVerions) { case eIOSSdkVerions.DeviceSDK: PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; break; case eIOSSdkVerions.SimulatorSDK: PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK; break; } //目标最低版本 PlayerSettings.iOS.targetOSVersionString = cache_plat_info.OSVersionString; //脚本优化 switch (cache_plat_info.IOSOptLevel) { case eIOSScriptCallOptimizationLevel.SlowAndSafe: PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.SlowAndSafe; break; case eIOSScriptCallOptimizationLevel.FastButNoExceptions: PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.FastButNoExceptions; break; } }
// [MenuItem( "Merge/HardResePlatformWatchert" )] // public static void HardReset() // { // PlatformSwapWatcher.OnPlatformSwapComplete = null; // Debug.Log( "Reset OnPlatformSwapComplete registry" ); // } void InitializeDeviceSettings() { // PlatformSwapWatcher.OnPlatformSwapComplete -= HandleSwapComplete; // // //Setup Build Settings UnityEngine.Rendering.GraphicsDeviceType[] supportedAPIs = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 }; // if ( EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ) // { PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.Android, true); // UnityEngine.Rendering.GraphicsDeviceType[] supportedAPIs = new UnityEngine.Rendering.GraphicsDeviceType[]{ UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 }; PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel23; PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7; PlayerSettings.Android.androidIsGame = false; PlayerSettings.Android.androidTVCompatibility = false; PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false); PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, supportedAPIs); PlayerSettings.Android.forceSDCardPermission = true; //Later functionality: //Auto move Android Manifest file if there isn't an existing one. Warn user if one already exists and inform them on how to manually apply it. // } // else if ( EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS ) // { PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.iOS, true); // UnityEngine.Rendering.GraphicsDeviceType[] supportedAPIs = new UnityEngine.Rendering.GraphicsDeviceType[]{ UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 }; PlayerSettings.iOS.cameraUsageDescription = "Used For Augmented Reality"; PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.iOS, false); PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, supportedAPIs); PlayerSettings.iOS.targetOSVersionString = "9.0"; // } // else // { // Debug.LogError( EditorUserBuildSettings.activeBuildTarget ); // } // // if ( OnChangeBuildPlatformComplete != null ) // { // OnChangeBuildPlatformComplete.Invoke(); // OnChangeBuildPlatformComplete = null; // } }
// Clear the current hardwareInfo public void Clear() { deviceType = DeviceType.Unknown; gpuDeviceType = UnityEngine.Rendering.GraphicsDeviceType.Null; gpuMemory = -1; gpuMultiThread = false; gpuShaderLevel = -1; maxTextureSize = -1; processorCount = -1; processorFrequency = -1; supportsComputeShaders = false; supportsImageEffects = false; supportsShadows = false; systemMemory = -1; SLIScalar = 1.0f; initialized = false; }
internal static RenderTextureFormat GetSupportedRenderTextureFormat(UnityEngine.Rendering.GraphicsDeviceType type) { switch (type) { case UnityEngine.Rendering.GraphicsDeviceType.Direct3D11: case UnityEngine.Rendering.GraphicsDeviceType.Direct3D12: case UnityEngine.Rendering.GraphicsDeviceType.Vulkan: return(RenderTextureFormat.BGRA32); case UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore: case UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2: case UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3: return(RenderTextureFormat.ARGB32); case UnityEngine.Rendering.GraphicsDeviceType.Metal: return(RenderTextureFormat.BGRA32); } return(RenderTextureFormat.Default); }
public static bool BuildTargetSupportsRenderer(BuildPlatform platform, GraphicsDeviceType type) { BuildTarget buildTarget = platform.defaultTarget; if (platform.targetGroup == BuildTargetGroup.Standalone) { buildTarget = DesktopStandaloneBuildWindowExtension.GetBestStandaloneTarget(buildTarget); } foreach (int var in GetRenderList(buildTarget)) { if ((GraphicsDeviceType)var == type) { return(true); } } return(false); }
public void Start() { MonoBehaviour.print("TULoader - Start()"); INSTANCE = this; DontDestroyOnLoad(this); if (partListLoadedEvent == null) { partListLoadedEvent = new EventVoid.OnEvent(onPartListLoaded); GameEvents.OnPartLoaderLoaded.Add(partListLoadedEvent); } //check the graphics API, popup warning if using unsupported gfx (dx9/11/12/legacy-openGL) UnityEngine.Rendering.GraphicsDeviceType graphicsAPI = SystemInfo.graphicsDeviceType; if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore) { //noop, everything is fine } else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D11) { //works, but needs alternate render alternateRender = true; } else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D9) { //has issues -- display warning, and needs alternate render alternateRender = true; if (apiCheckGUI == null) { apiCheckGUI = this.gameObject.AddComponent <GraphicsAPIGUI>(); apiCheckGUI.openGUI(); } } else { //unknown API -- display warning if (apiCheckGUI == null) { apiCheckGUI = this.gameObject.AddComponent <GraphicsAPIGUI>(); apiCheckGUI.openGUI(); } } }
// Set the hardwareInfo using the current system config public void SetFromCurrentConfig() { deviceModel = SystemInfo.deviceModel; deviceName = SystemInfo.deviceName; deviceType = SystemInfo.deviceType; deviceID = SystemInfo.deviceUniqueIdentifier; gpuDeviceID = SystemInfo.graphicsDeviceID; gpuDeviceName = SystemInfo.graphicsDeviceName; gpuDeviceType = SystemInfo.graphicsDeviceType; gpuDeviceVendor = SystemInfo.graphicsDeviceVendor; gpuDeviceVendorID = SystemInfo.graphicsDeviceVendorID; gpuDeviceVersion = SystemInfo.graphicsDeviceVersion; gpuMemory = SystemInfo.graphicsMemorySize; gpuMultiThread = SystemInfo.graphicsMultiThreaded; gpuShaderLevel = SystemInfo.graphicsShaderLevel; maxTextureSize = SystemInfo.maxTextureSize; npotSupport = SystemInfo.npotSupport; operatingSystem = SystemInfo.operatingSystem; // operatingSystemFamily = SystemInfo.operatingSystemFamily; processorCount = SystemInfo.processorCount; processorFrequency = SystemInfo.processorFrequency; processorType = SystemInfo.processorType; supportedRenderTargetCount = SystemInfo.supportedRenderTargetCount; supports2DArrayTextures = SystemInfo.supports2DArrayTextures; supports3DTextures = SystemInfo.supports3DTextures; supportsAudio = SystemInfo.supportsAudio; supportsComputeShaders = SystemInfo.supportsComputeShaders; //supportsCubemapArrayTextures = SystemInfo.supportsCubemapArrayTextures; supportsGyroscope = SystemInfo.supportsGyroscope; supportsImageEffects = SystemInfo.supportsImageEffects; supportsInstancing = SystemInfo.supportsInstancing; supportsLocationService = SystemInfo.supportsLocationService; supportsMotionVectors = SystemInfo.supportsMotionVectors; supportsRawShadowDepthSampling = SystemInfo.supportsRawShadowDepthSampling; supportsRenderToCubemap = SystemInfo.supportsRenderToCubemap; supportsShadows = SystemInfo.supportsShadows; supportsSparseTextures = SystemInfo.supportsSparseTextures; supportsVibration = SystemInfo.supportsVibration; //usesReversedZBuffer = SystemInfo.usesReversedZBuffer; systemMemory = SystemInfo.systemMemorySize; }
public void Start() { MonoBehaviour.print("TULoader - Start()"); INSTANCE = this; DontDestroyOnLoad(this); if (partListLoadedEvent == null) { partListLoadedEvent = new EventVoid.OnEvent(onPartListLoaded); GameEvents.OnPartLoaderLoaded.Add(partListLoadedEvent); } //check the graphics API, popup warning if using unsupported gfx (dx9/11/12/legacy-openGL) UnityEngine.Rendering.GraphicsDeviceType graphicsAPI = SystemInfo.graphicsDeviceType; if (graphicsAPI != UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore) { if (apiCheckGUI == null) { apiCheckGUI = this.gameObject.AddComponent <GraphicsAPIGUI>(); apiCheckGUI.openGUI(); } } }
private void Awake() { // Only allow one instance at runtime. if (instance != null) { enabled = false; DestroyImmediate(this); return; } instance = this; Debug.Log("Unity v" + Application.unityVersion + ", " + "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " + "OVRPlugin v" + OVRPlugin.version + ", " + "SDK v" + OVRPlugin.nativeSDKVersion + "."); #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN var supportedTypes = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.Direct3D11, UnityEngine.Rendering.GraphicsDeviceType.Direct3D12, }; if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType)) { Debug.LogWarning("VR rendering requires one of the following device types: (" + string.Join(", ", supportedTypes.Select(t => t.ToString()).ToArray()) + "). Your graphics device: " + SystemInfo.graphicsDeviceType); } #endif // Detect whether this platform is a supported platform RuntimePlatform currPlatform = Application.platform; isSupportedPlatform |= currPlatform == RuntimePlatform.Android; //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer; if (!isSupportedPlatform) { Debug.LogWarning("This platform is unsupported"); return; } #if UNITY_ANDROID && !UNITY_EDITOR // We want to set up our touchpad messaging system OVRTouchpad.Create(); // Turn off chromatic aberration by default to save texture bandwidth. chromatic = false; #endif if (display == null) { display = new OVRDisplay(); } if (tracker == null) { tracker = new OVRTracker(); } if (boundary == null) { boundary = new OVRBoundary(); } if (resetTrackerOnLoad) { display.RecenterPose(); } // Disable the occlusion mesh by default until open issues with the preview window are resolved. OVRPlugin.occlusionMesh = false; }
// Returns true, if everything is done: private bool ManageGraphicsAPIs() { bool allDone = true; BuildTarget curBuildTarget = EditorUserBuildSettings.activeBuildTarget; EditorGUILayout.LabelField("Current Build Target: " + curBuildTarget); if (curBuildTarget != BuildTarget.StandaloneWindows64) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Recommendation is " + BuildTarget.StandaloneWindows64, GUILayout.MaxWidth(_leftLabelMaxWidth)); #if UNITY_5 || UNITY_2017_1 GUIStyle yellowTextStyle = new GUIStyle(); yellowTextStyle.normal.textColor = Color.yellow; EditorGUILayout.LabelField("Use Build Settings to switch the Build Target to Standalone Windows x64.", yellowTextStyle); #else // #elif UNITY_2017_2_OR_NEWER allDone = false; if (GUILayout.Button("Switch")) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); } #endif EditorGUILayout.EndHorizontal(); } bool useDefaultGraphicsAPI = PlayerSettings.GetUseDefaultGraphicsAPIs(curBuildTarget); if (curBuildTarget == BuildTarget.StandaloneWindows || curBuildTarget == BuildTarget.StandaloneWindows64) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Do not use default graphics API", GUILayout.MaxWidth(_leftLabelMaxWidth)); if (useDefaultGraphicsAPI == true) { allDone = false; if (GUILayout.Button("Disable")) { PlayerSettings.SetUseDefaultGraphicsAPIs(curBuildTarget, false); } } else { EditorGUILayout.LabelField("(Is disabled)"); } EditorGUILayout.EndHorizontal(); if (useDefaultGraphicsAPI == false) { List <UnityEngine.Rendering.GraphicsDeviceType> graphicsDeviceTypes = new List <UnityEngine.Rendering.GraphicsDeviceType>(PlayerSettings.GetGraphicsAPIs(curBuildTarget)); if (graphicsDeviceTypes.Contains(_graphicsDeviceGLCore) == false) // If glcore is not available at all: { allDone = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Missing GLCore Graphics API", GUILayout.MaxWidth(_leftLabelMaxWidth)); if (GUILayout.Button("Add")) { graphicsDeviceTypes.Insert(0, _graphicsDeviceGLCore); PlayerSettings.SetGraphicsAPIs(curBuildTarget, graphicsDeviceTypes.ToArray()); } EditorGUILayout.EndHorizontal(); } if (graphicsDeviceTypes.Contains(_graphicsDeviceDx11) == false) // If dx11 is not available at all: { allDone = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Missing DircetX 11 Graphics API", GUILayout.MaxWidth(_leftLabelMaxWidth)); if (GUILayout.Button("Add")) { graphicsDeviceTypes.Add(_graphicsDeviceDx11); PlayerSettings.SetGraphicsAPIs(curBuildTarget, graphicsDeviceTypes.ToArray()); } EditorGUILayout.EndHorizontal(); } _graphicsApiFoldout = EditorGUILayout.Foldout(_graphicsApiFoldout, "Graphic APIs"); if (_graphicsApiFoldout == true) { if (graphicsDeviceTypes.Count == 0) { EditorGUI.indentLevel++; // Start Intend Level Graphic APIs EditorGUILayout.LabelField("(empty)"); EditorGUI.indentLevel--; // End Intend Level Graphic APIs } else { for (int ii = 0; ii < graphicsDeviceTypes.Count; ++ii) { UnityEngine.Rendering.GraphicsDeviceType graphicDeviceType = graphicsDeviceTypes[ii]; EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; // Start Intend Level Graphic APIs EditorGUILayout.LabelField(graphicDeviceType.ToString(), GUILayout.MaxWidth(_leftLabelMaxWidth)); EditorGUI.indentLevel--; // End Intend Level Graphic APIs if (graphicDeviceType == _graphicsDeviceGLCore || graphicDeviceType == _graphicsDeviceDx11) // If it is the OpenGL or DX11 graphics API: { EditorGUILayout.LabelField("(Is available)"); } else // Another API, but not OpenGL nor DX11 { if (GUILayout.Button("Remove")) { graphicsDeviceTypes.RemoveAt(ii); PlayerSettings.SetGraphicsAPIs(curBuildTarget, graphicsDeviceTypes.ToArray()); } } EditorGUILayout.EndHorizontal(); } } } } } else { EditorGUILayout.LabelField("Switch to Standalone Windows plattform to setup Graphics API."); } return(allDone); }
private void OnGUI() { { GUILayout.Label("Mira Unity Settings", EditorStyles.boldLabel); GUILayout.Label(m_Logo); // Accelorometer Frequency GUI.enabled = true; GUILayout.Label("Accelerometer Frquency" + " (current = " + PlayerSettings.accelerometerFrequency + ")"); if (PlayerSettings.accelerometerFrequency == 60) { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (60 mhz)", GUILayout.Width(250))) { PlayerSettings.accelerometerFrequency = 60; } GUILayout.Space(5); GUI.enabled = true; GUILayout.Label("Current Bundle Id" + " = " + PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS)); if (PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS) == "com.mirareality.example") { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (com.mirareality.example)", GUILayout.Width(250))) { PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.mirareality.example"); } GUILayout.Space(5); GUI.enabled = true; GUILayout.Label("Current Camera Usage Description" + " = " + PlayerSettings.iOS.cameraUsageDescription); if (PlayerSettings.iOS.cameraUsageDescription == "Computer Vision") { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (Computer Vison)", GUILayout.Width(250))) { PlayerSettings.iOS.cameraUsageDescription = "Computer Vision"; } GUILayout.Space(5); GUI.enabled = true; bool isMetal = false; foreach (UnityEngine.Rendering.GraphicsDeviceType graphicsType in PlayerSettings.GetGraphicsAPIs(BuildTarget.iOS)) { if (graphicsType == UnityEngine.Rendering.GraphicsDeviceType.Metal) { isMetal = true; } } GUILayout.Label("Graphics APIs contains metal:" + " = " + isMetal); if (isMetal == false) { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (Remove Metal)", GUILayout.Width(250))) { UnityEngine.Rendering.GraphicsDeviceType[] graphicsAPIs = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 };; PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, graphicsAPIs); } GUILayout.Space(5); GUI.enabled = true; GUILayout.Label("UI Orientation" + " = " + PlayerSettings.defaultInterfaceOrientation); if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation) { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (AutoRotate)", GUILayout.Width(250))) { PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; } GUILayout.Space(5); GUI.enabled = true; GUILayout.Label("Configure Mira AutoRotation (Highly Recommended)"); if (PlayerSettings.allowedAutorotateToLandscapeLeft == true && PlayerSettings.allowedAutorotateToLandscapeRight == false && PlayerSettings.allowedAutorotateToPortrait == true && PlayerSettings.allowedAutorotateToPortraitUpsideDown == false) { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (Allow)", GUILayout.Width(250))) { PlayerSettings.allowedAutorotateToLandscapeLeft = true; PlayerSettings.allowedAutorotateToLandscapeRight = false; PlayerSettings.allowedAutorotateToPortrait = true; PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; } GUILayout.Space(5); GUI.enabled = true; GUILayout.Label("Current Min iOS OS Version" + " = " + PlayerSettings.iOS.targetOSVersionString); if (PlayerSettings.iOS.targetOSVersionString == "8.0") { GUI.enabled = false; } if (GUILayout.Button("Use Recomended (8.0)", GUILayout.Width(250))) { PlayerSettings.iOS.targetOSVersionString = "8.0"; } // GUILayout.Space(15); // GUI.enabled = true; // if (GUILayout.Button("Apply All Recomended Settings", GUILayout.Width(390))) // { // PlayerSettings.accelerometerFrequency = 60; // PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.mirareality.example"); // PlayerSettings.iOS.cameraUsageDescription = "Computer Vision"; // PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; // PlayerSettings.allowedAutorotateToLandscapeLeft = true; // PlayerSettings.iOS.targetOSVersionString = "8.0"; // } GUILayout.Space(15); GUILayout.Label("Mira SDK 0.7.1.", EditorStyles.boldLabel); } }
private static void HandleAndroidPlayerSetting(BuildTarget buildTarget, BuildTargetGroup targetGroup, PublishPlatformInfo platform_info, PublishCacheChannelInfo cache_channel_info, PublishCachePlatformInfo cache_plat_info) { //图像引擎 PlayerSettings.SetUseDefaultGraphicsAPIs(buildTarget, cache_plat_info.AutoGraphicsAPI); if (!cache_plat_info.AutoGraphicsAPI) { UnityEngine.Rendering.GraphicsDeviceType[] gdt = new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3, UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 }; PlayerSettings.SetGraphicsAPIs(buildTarget, gdt); } //多线程渲染 PlayerSettings.MTRendering = !cache_plat_info.MultiThreadRender; //cpu架构 switch (cache_plat_info.TargetDevice) { case eTargetDevice.FAT: PlayerSettings.Android.targetDevice = AndroidTargetDevice.FAT; break; case eTargetDevice.ARMv7: PlayerSettings.Android.targetDevice = AndroidTargetDevice.ARMv7; break; case eTargetDevice.x86: PlayerSettings.Android.targetDevice = AndroidTargetDevice.x86; break; } //安装位置 switch (cache_plat_info.InstallLocation) { case eInstallLocation.Auto: PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.Auto; break; case eInstallLocation.ForceInternal: PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.ForceInternal; break; case eInstallLocation.PreferExternal: PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.PreferExternal; break; } //SD卡读写 PlayerSettings.Android.forceSDCardPermission = cache_plat_info.SDCardPermission; //最小sdk版本 switch (cache_plat_info.MinAndroidSdkVersion) { case eAndroidSdkVersions.AndroidApiLevelAuto: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto; break; case eAndroidSdkVersions.AndroidApiLevel16: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel16; break; case eAndroidSdkVersions.AndroidApiLevel17: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel17; break; case eAndroidSdkVersions.AndroidApiLevel18: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel18; break; case eAndroidSdkVersions.AndroidApiLevel19: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel19; break; case eAndroidSdkVersions.AndroidApiLevel21: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel21; break; case eAndroidSdkVersions.AndroidApiLevel22: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel22; break; case eAndroidSdkVersions.AndroidApiLevel23: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel23; break; case eAndroidSdkVersions.AndroidApiLevel24: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel24; break; case eAndroidSdkVersions.AndroidApiLevel25: PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel25; break; } //代码剥离 switch (cache_plat_info.StrippingLevel) { case eStrippingLevel.Disabled: PlayerSettings.strippingLevel = StrippingLevel.Disabled; break; case eStrippingLevel.StripAssemblies: PlayerSettings.strippingLevel = StrippingLevel.StripAssemblies; break; case eStrippingLevel.StripByteCode: PlayerSettings.strippingLevel = StrippingLevel.StripByteCode; break; case eStrippingLevel.UseMicroMSCorlib: PlayerSettings.strippingLevel = StrippingLevel.UseMicroMSCorlib; break; } //是否分包 PlayerSettings.Android.useAPKExpansionFiles = cache_plat_info.APKExpansionFiles; PlayerSettings.Android.bundleVersionCode = platform_info.BundleVersionCode; if (!string.IsNullOrEmpty(cache_plat_info.KeyStorePath)) { PlayerSettings.Android.keystoreName = cache_plat_info.KeyStorePath; PlayerSettings.Android.keystorePass = cache_plat_info.KetStorePass; PlayerSettings.Android.keyaliasName = cache_plat_info.KeyAliasName; PlayerSettings.Android.keyaliasPass = cache_plat_info.KeyAliasPass; } }
public SystemInfoKun(bool isSet) { if (isSet) { batteryLevel = SystemInfo.batteryLevel; batteryStatus = SystemInfo.batteryStatus; copyTextureSupport = SystemInfo.copyTextureSupport; deviceModel = SystemInfo.deviceModel; deviceName = SystemInfo.deviceName; deviceType = SystemInfo.deviceType; deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier; graphicsDeviceID = SystemInfo.graphicsDeviceID; graphicsDeviceName = SystemInfo.graphicsDeviceName; graphicsDeviceType = SystemInfo.graphicsDeviceType; graphicsDeviceVendor = SystemInfo.graphicsDeviceVendor; graphicsDeviceVendorID = SystemInfo.graphicsDeviceVendorID; graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion; graphicsMemorySize = SystemInfo.graphicsMemorySize; graphicsMultiThreaded = SystemInfo.graphicsMultiThreaded; graphicsShaderLevel = SystemInfo.graphicsShaderLevel; graphicsUVStartsAtTop = SystemInfo.graphicsUVStartsAtTop; hasDynamicUniformArrayIndexingInFragmentShaders = SystemInfo.hasDynamicUniformArrayIndexingInFragmentShaders; hasHiddenSurfaceRemovalOnGPU = SystemInfo.hasHiddenSurfaceRemovalOnGPU; hasMipMaxLevel = SystemInfo.hasMipMaxLevel; maxComputeBufferInputsCompute = SystemInfo.maxComputeBufferInputsCompute; maxComputeBufferInputsDomain = SystemInfo.maxComputeBufferInputsDomain; maxComputeBufferInputsFragment = SystemInfo.maxComputeBufferInputsFragment; maxComputeBufferInputsGeometry = SystemInfo.maxComputeBufferInputsGeometry; maxComputeBufferInputsHull = SystemInfo.maxComputeBufferInputsHull; maxComputeBufferInputsVertex = SystemInfo.maxComputeBufferInputsVertex; maxComputeWorkGroupSize = SystemInfo.maxComputeWorkGroupSize; maxComputeWorkGroupSizeX = SystemInfo.maxComputeWorkGroupSizeX; maxComputeWorkGroupSizeY = SystemInfo.maxComputeWorkGroupSizeY; maxComputeWorkGroupSizeZ = SystemInfo.maxComputeWorkGroupSizeX; maxCubemapSize = SystemInfo.maxCubemapSize; maxTextureSize = SystemInfo.maxTextureSize; #if UNITY_2020_1_OR_NEWER constantBufferOffsetAlignment = SystemInfo.constantBufferOffsetAlignment; #else minConstantBufferOffsetAlignment = SystemInfo.minConstantBufferOffsetAlignment; #endif npotSupport = SystemInfo.npotSupport; operatingSystem = SystemInfo.operatingSystem; operatingSystemFamily = SystemInfo.operatingSystemFamily; processorCount = SystemInfo.processorCount; processorFrequency = SystemInfo.processorFrequency; processorType = SystemInfo.processorType; renderingThreadingMode = SystemInfo.renderingThreadingMode; supportedRandomWriteTargetCount = SystemInfo.supportedRenderTargetCount; supportedRenderTargetCount = SystemInfo.supportedRenderTargetCount; supports2DArrayTextures = SystemInfo.supports2DArrayTextures; supports32bitsIndexBuffer = SystemInfo.supports32bitsIndexBuffer; supports3DRenderTextures = SystemInfo.supports3DRenderTextures; supports3DTextures = SystemInfo.supports3DTextures; supportsAccelerometer = SystemInfo.supportsAccelerometer; supportsAsyncCompute = SystemInfo.supportsAsyncCompute; supportsAsyncGPUReadback = SystemInfo.supportsAsyncGPUReadback; supportsAudio = SystemInfo.supportsAudio; supportsComputeShaders = SystemInfo.supportsComputeShaders; supportsCubemapArrayTextures = SystemInfo.supportsCubemapArrayTextures; supportsGeometryShaders = SystemInfo.supportsGeometryShaders; supportsGraphicsFence = SystemInfo.supportsGraphicsFence; supportsGyroscope = SystemInfo.supportsGyroscope; supportsHardwareQuadTopology = SystemInfo.supportsHardwareQuadTopology; supportsInstancing = SystemInfo.supportsInstancing; supportsLocationService = SystemInfo.supportsLocationService; supportsMipStreaming = SystemInfo.supportsMipStreaming; supportsMotionVectors = SystemInfo.supportsMotionVectors; supportsMultisampleAutoResolve = SystemInfo.supportsMultisampleAutoResolve; supportsMultisampledTextures = SystemInfo.supportsMultisampledTextures; supportsRawShadowDepthSampling = SystemInfo.supportsRawShadowDepthSampling; supportsRayTracing = SystemInfo.supportsRayTracing; supportsSeparatedRenderTargetsBlend = SystemInfo.supportsSeparatedRenderTargetsBlend; supportsSetConstantBuffer = SystemInfo.supportsSetConstantBuffer; supportsShadows = SystemInfo.supportsShadows; supportsSparseTextures = SystemInfo.supportsSparseTextures; supportsTessellationShaders = SystemInfo.supportsTessellationShaders; supportsTextureWrapMirrorOnce = SystemInfo.supportsTextureWrapMirrorOnce; supportsVibration = SystemInfo.supportsVibration; systemMemorySize = SystemInfo.systemMemorySize; unsupportedIdentifier = SystemInfo.unsupportedIdentifier; usesLoadStoreActions = SystemInfo.usesLoadStoreActions; usesReversedZBuffer = SystemInfo.usesReversedZBuffer; } else { deviceModel = ""; deviceName = ""; deviceUniqueIdentifier = ""; graphicsDeviceName = ""; graphicsDeviceVendor = ""; graphicsDeviceVersion = ""; operatingSystem = ""; processorType = ""; unsupportedIdentifier = ""; } }
public virtual void Deserialize(BinaryReader binaryReader) { batteryLevel = binaryReader.ReadSingle(); batteryStatus = (BatteryStatus)binaryReader.ReadInt32(); copyTextureSupport = (UnityEngine.Rendering.CopyTextureSupport)binaryReader.ReadInt32(); deviceModel = binaryReader.ReadString(); deviceName = binaryReader.ReadString(); deviceType = (DeviceType)binaryReader.ReadInt32(); deviceUniqueIdentifier = binaryReader.ReadString(); graphicsDeviceID = binaryReader.ReadInt32(); graphicsDeviceName = binaryReader.ReadString(); graphicsDeviceType = (UnityEngine.Rendering.GraphicsDeviceType)binaryReader.ReadInt32(); graphicsDeviceVendor = binaryReader.ReadString(); graphicsDeviceVendorID = binaryReader.ReadInt32(); graphicsDeviceVersion = binaryReader.ReadString(); graphicsMemorySize = binaryReader.ReadInt32(); graphicsMultiThreaded = binaryReader.ReadBoolean(); graphicsShaderLevel = binaryReader.ReadInt32(); graphicsUVStartsAtTop = binaryReader.ReadBoolean(); hasDynamicUniformArrayIndexingInFragmentShaders = binaryReader.ReadBoolean(); hasHiddenSurfaceRemovalOnGPU = binaryReader.ReadBoolean(); hasMipMaxLevel = binaryReader.ReadBoolean(); maxComputeBufferInputsCompute = binaryReader.ReadInt32(); maxComputeBufferInputsDomain = binaryReader.ReadInt32(); maxComputeBufferInputsFragment = binaryReader.ReadInt32(); maxComputeBufferInputsGeometry = binaryReader.ReadInt32(); maxComputeBufferInputsHull = binaryReader.ReadInt32(); maxComputeBufferInputsVertex = binaryReader.ReadInt32(); maxComputeWorkGroupSize = binaryReader.ReadInt32(); maxComputeWorkGroupSizeX = binaryReader.ReadInt32(); maxComputeWorkGroupSizeY = binaryReader.ReadInt32(); maxComputeWorkGroupSizeZ = binaryReader.ReadInt32(); maxCubemapSize = binaryReader.ReadInt32(); maxTextureSize = binaryReader.ReadInt32(); #if UNITY_2020_1_OR_NEWER constantBufferOffsetAlignment = binaryReader.ReadInt32(); #else minConstantBufferOffsetAlignment = binaryReader.ReadBoolean(); #endif npotSupport = (NPOTSupport)binaryReader.ReadInt32(); operatingSystem = binaryReader.ReadString(); operatingSystemFamily = (OperatingSystemFamily)binaryReader.ReadInt32(); processorCount = binaryReader.ReadInt32(); processorFrequency = binaryReader.ReadInt32(); processorType = binaryReader.ReadString(); renderingThreadingMode = (UnityEngine.Rendering.RenderingThreadingMode)binaryReader.ReadInt32(); supportedRandomWriteTargetCount = binaryReader.ReadInt32(); supportedRenderTargetCount = binaryReader.ReadInt32(); supports2DArrayTextures = binaryReader.ReadBoolean(); supports32bitsIndexBuffer = binaryReader.ReadBoolean(); supports3DRenderTextures = binaryReader.ReadBoolean(); supports3DTextures = binaryReader.ReadBoolean(); supportsAccelerometer = binaryReader.ReadBoolean(); supportsAsyncCompute = binaryReader.ReadBoolean(); supportsAsyncGPUReadback = binaryReader.ReadBoolean(); supportsAudio = binaryReader.ReadBoolean(); supportsComputeShaders = binaryReader.ReadBoolean(); supportsCubemapArrayTextures = binaryReader.ReadBoolean(); supportsGeometryShaders = binaryReader.ReadBoolean(); supportsGraphicsFence = binaryReader.ReadBoolean(); supportsGyroscope = binaryReader.ReadBoolean(); supportsHardwareQuadTopology = binaryReader.ReadBoolean(); supportsInstancing = binaryReader.ReadBoolean(); supportsLocationService = binaryReader.ReadBoolean(); supportsMipStreaming = binaryReader.ReadBoolean(); supportsMotionVectors = binaryReader.ReadBoolean(); supportsMultisampleAutoResolve = binaryReader.ReadBoolean(); supportsMultisampledTextures = binaryReader.ReadInt32(); supportsRawShadowDepthSampling = binaryReader.ReadBoolean(); supportsRayTracing = binaryReader.ReadBoolean(); supportsSeparatedRenderTargetsBlend = binaryReader.ReadBoolean(); supportsSetConstantBuffer = binaryReader.ReadBoolean(); supportsShadows = binaryReader.ReadBoolean(); supportsSparseTextures = binaryReader.ReadBoolean(); supportsTessellationShaders = binaryReader.ReadBoolean(); supportsTextureWrapMirrorOnce = binaryReader.ReadInt32(); supportsVibration = binaryReader.ReadBoolean(); systemMemorySize = binaryReader.ReadInt32(); unsupportedIdentifier = binaryReader.ReadString(); usesLoadStoreActions = binaryReader.ReadBoolean(); usesReversedZBuffer = binaryReader.ReadBoolean(); }
public static SrdXrResult SetGraphicsAPI(IntPtr session, UnityEngine.Rendering.GraphicsDeviceType graphicsAPI) { return(XRRuntimeAPI.SetGraphicsAPI(session, XRRuntimeGraphicsDeviceType[graphicsAPI])); }