Created
November 10, 2020 11:34
-
-
Save baba-s/640a506ba31d223d3d319ebe2367f4d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using JetBrains.Annotations; | |
using System; | |
using UnityEngine; | |
#if UNITY_IOS | |
using UnityEngine.iOS; | |
#endif | |
namespace Kogane | |
{ | |
public static class JsonUnityEngineiOSDevice | |
{ | |
#if UNITY_IOS | |
[Serializable] | |
private struct JsonData | |
{ | |
[SerializeField][UsedImplicitly] public string systemVersion; | |
[SerializeField][UsedImplicitly] public DeviceGeneration generation; | |
[SerializeField][UsedImplicitly] public string vendorIdentifier; | |
[SerializeField][UsedImplicitly] public string advertisingIdentifier; | |
[SerializeField][UsedImplicitly] public bool advertisingTrackingEnabled; | |
[SerializeField][UsedImplicitly] public bool hideHomeButton; | |
[SerializeField][UsedImplicitly] public bool lowPowerModeEnabled; | |
[SerializeField][UsedImplicitly] public bool wantsSoftwareDimming; | |
[SerializeField][UsedImplicitly] public SystemGestureDeferMode deferSystemGesturesMode; | |
} | |
#endif | |
public static string Get() | |
{ | |
#if UNITY_IOS | |
if ( Application.isEditor ) return string.Empty; | |
var jsonData = new JsonData | |
{ | |
systemVersion = Device.systemVersion, | |
generation = Device.generation, | |
vendorIdentifier = Device.vendorIdentifier, | |
advertisingIdentifier = Device.advertisingIdentifier, | |
advertisingTrackingEnabled = Device.advertisingTrackingEnabled, | |
hideHomeButton = Device.hideHomeButton, | |
lowPowerModeEnabled = Device.lowPowerModeEnabled, | |
wantsSoftwareDimming = Device.wantsSoftwareDimming, | |
deferSystemGesturesMode = Device.deferSystemGesturesMode, | |
}; | |
return JsonUtility.ToJson( jsonData, true ); | |
#else | |
return string.Empty; | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment