public SystemInfoSimulation(DeviceInfoAsset device, SimulationPlayerSettings playerSettings)
 {
     m_SystemInfo       = device.deviceInfo.systemInfo;
     m_SystemInfoFields = device.availableSystemInfoFields;
     if (device.deviceInfo.systemInfo.graphicsDependentData?.Length > 0)
     {
         if (device.deviceInfo.IsAndroidDevice())
         {
             m_GraphicsSystemInfo = (
                 from selected in playerSettings.androidGraphicsAPIs
                 from gfxDevice in m_SystemInfo.graphicsDependentData
                 where selected == gfxDevice.graphicsDeviceType select gfxDevice).FirstOrDefault();
         }
         else if (device.deviceInfo.IsiOSDevice())
         {
             m_GraphicsSystemInfo = (
                 from selected in playerSettings.iOSGraphicsAPIs
                 from gfxDevice in m_SystemInfo.graphicsDependentData
                 where selected == gfxDevice.graphicsDeviceType select gfxDevice).FirstOrDefault();
         }
         if (m_GraphicsSystemInfo == null)
         {
             Debug.LogWarning("Could not pick GraphicsDeviceType, the game would fail to launch");
         }
     }
     m_GraphicsSystemInfoFields = m_GraphicsSystemInfo != null ? device.availableGraphicsSystemInfoFields[m_GraphicsSystemInfo.graphicsDeviceType] : new HashSet <string>();
     Enable();
 }
示例#2
0
        public static Texture LoadOverlay(DeviceInfoAsset device, int screenIndex)
        {
            var screen = device.deviceInfo.screens[screenIndex];
            var path   = screen.presentation.overlayPath;

            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            if (device.editorResource)
            {
                var filePath = Path.Combine(device.directory, screen.presentation.overlayPath);
                var overlay  = EditorGUIUtility.Load(filePath) as Texture;
                Debug.Assert(overlay != null, $"Failed to load built-in device {device.deviceInfo} overlay");
                return(overlay);
            }

            path = path.Replace("\\", "/");
            if (!path.StartsWith("Assets/") && !path.StartsWith("Packages/"))
            {
                path = Path.Combine(device.directory, path);
            }

            // Custom textures need to be readable for us to accurately map touches in cutouts
            // but we can full back to the .device cutouts. We need the .meta file to be unlocked in VCS.
            var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;

            if (textureImporter != null && !textureImporter.isReadable)
            {
                if (AssetDatabase.MakeEditable(path + ".meta"))
                {
                    textureImporter.isReadable = true;
                    AssetDatabase.ImportAsset(path);
                    AssetDatabase.Refresh();
                }
                else
                {
                    Debug.LogWarning(
                        "Read/Write not enabled on simulator texture\nRead/Write is required to simulate touch over the device bezel and cutouts accurately.");
                }
            }

            return(AssetDatabase.LoadAssetAtPath <Texture>(path));
        }
示例#3
0
        internal static void FindOptionalFieldAvailability(DeviceInfoAsset asset, XElement systemInfoElement, List <GraphicsTypeElement> graphicsDataElements)
        {
            string[] systemInfoFields =
            {
                "deviceModel",
                "deviceType",
                "operatingSystemFamily",
                "processorCount",
                "processorFrequency",
                "processorType",
                "supportsAccelerometer",
                "supportsAudio",
                "supportsGyroscope",
                "supportsLocationService",
                "supportsVibration",
                "systemMemorySize"
            };

            string[] graphicsSystemInfoFields =
            {
                "graphicsMemorySize",
                "graphicsDeviceName",
                "graphicsDeviceVendor",
                "graphicsDeviceID",
                "graphicsDeviceVendorID",
                "graphicsUVStartsAtTop",
                "graphicsDeviceVersion",
                "graphicsShaderLevel",
                "graphicsMultiThreaded",
                "renderingThreadingMode",
                "hasHiddenSurfaceRemovalOnGPU",
                "hasDynamicUniformArrayIndexingInFragmentShaders",
                "supportsShadows",
                "supportsRawShadowDepthSampling",
                "supportsMotionVectors",
                "supports3DTextures",
                "supports2DArrayTextures",
                "supports3DRenderTextures",
                "supportsCubemapArrayTextures",
                "copyTextureSupport",
                "supportsComputeShaders",
                "supportsGeometryShaders",
                "supportsTessellationShaders",
                "supportsInstancing",
                "supportsHardwareQuadTopology",
                "supports32bitsIndexBuffer",
                "supportsSparseTextures",
                "supportedRenderTargetCount",
                "supportsSeparatedRenderTargetsBlend",
                "supportedRandomWriteTargetCount",
                "supportsMultisampledTextures",
                "supportsMultisampleAutoResolve",
                "supportsTextureWrapMirrorOnce",
                "usesReversedZBuffer",
                "npotSupport",
                "maxTextureSize",
                "maxCubemapSize",
                "maxComputeBufferInputsVertex",
                "maxComputeBufferInputsFragment",
                "maxComputeBufferInputsGeometry",
                "maxComputeBufferInputsDomain",
                "maxComputeBufferInputsHull",
                "maxComputeBufferInputsCompute",
                "maxComputeWorkGroupSize",
                "maxComputeWorkGroupSizeX",
                "maxComputeWorkGroupSizeY",
                "maxComputeWorkGroupSizeZ",
                "supportsAsyncCompute",
                "supportsGraphicsFence",
                "supportsAsyncGPUReadback",
                "supportsRayTracing",
                "supportsSetConstantBuffer",
                "hasMipMaxLevel",
                "supportsMipStreaming",
                "usesLoadStoreActions"
            };

            foreach (var field in systemInfoFields)
            {
                if (systemInfoElement.Element(field) != null)
                {
                    asset.availableSystemInfoFields.Add(field);
                }
            }
            foreach (var graphicsDataElement in graphicsDataElements)
            {
                var availableFields = new HashSet <string>();
                asset.availableGraphicsSystemInfoFields.Add(graphicsDataElement.type, availableFields);
                foreach (var field in graphicsSystemInfoFields)
                {
                    if (graphicsDataElement.element.Element(field) != null)
                    {
                        availableFields.Add(field);
                    }
                }
            }
        }