Exemple #1
0
        public Context()
        {
            os = new OperatingSystem
            {
                // TODO: Will move to raw_description once parsing is done in Sentry
                name = SystemInfo.operatingSystem
            };

            device = new Device();
            switch (Input.deviceOrientation)
            {
            case UnityEngine.DeviceOrientation.Portrait:
            case UnityEngine.DeviceOrientation.PortraitUpsideDown:
                device.orientation = "portrait";
                break;

            case UnityEngine.DeviceOrientation.LandscapeLeft:
            case UnityEngine.DeviceOrientation.LandscapeRight:
                device.orientation = "landscape";
                break;

            case UnityEngine.DeviceOrientation.FaceUp:
            case UnityEngine.DeviceOrientation.FaceDown:
                // TODO: Add to protocol?
                break;
            }

            var model = SystemInfo.deviceModel;

            if (model != SystemInfo.unsupportedIdentifier
                // Returned by the editor
                && model != "System Product Name (System manufacturer)")
            {
                device.model = model;
            }

            device.battery_level  = SystemInfo.batteryLevel * 100;
            device.battery_status = SystemInfo.batteryStatus.ToString();

            // This is the approximate amount of system memory in megabytes.
            // This function is not supported on Windows Store Apps and will always return 0.
            if (SystemInfo.systemMemorySize != 0)
            {
                device.memory_size = SystemInfo.systemMemorySize * 1048576L; // Sentry device mem is in Bytes
            }

            device.device_type     = SystemInfo.deviceType.ToString();
            device.cpu_description = SystemInfo.processorType;

#if UNITY_EDITOR
            device.simulator = true;
#else
            device.simulator = false;
#endif

            gpu = new Gpu
            {
                id          = SystemInfo.graphicsDeviceID,
                name        = SystemInfo.graphicsDeviceName,
                vendor_id   = SystemInfo.graphicsDeviceVendorID,
                vendor_name = SystemInfo.graphicsDeviceVendor,
                memory_size = SystemInfo.graphicsMemorySize,
                multi_threaded_rendering = SystemInfo.graphicsMultiThreaded,
                npot_support             = SystemInfo.npotSupport.ToString(),
                version  = SystemInfo.graphicsDeviceVersion,
                api_type = SystemInfo.graphicsDeviceType.ToString()
            };

            app = new App();
            app.app_start_time = DateTimeOffset.UtcNow
                                 .AddSeconds(-Time.realtimeSinceStartup)
                                 .ToString("yyyy-MM-ddTHH\\:mm\\:ssZ");

            if (Debug.isDebugBuild)
            {
                app.build_type = "debug";
            }
            else
            {
                app.build_type = "release";
            }
        }