1
- using System . Collections . Generic ;
1
+ using OpenCVForUnity . CoreModule ;
2
+ using OpenCVForUnity . UnityUtils ;
3
+ using System ;
4
+ using System . Collections . Generic ;
5
+ using System . Reflection ;
6
+ using System . Text ;
2
7
using UnityEngine ;
3
8
using UnityEngine . SceneManagement ;
4
9
using UnityEngine . UI ;
@@ -9,24 +14,42 @@ public class ShowSystemInfo : MonoBehaviour
9
14
{
10
15
public Text systemInfoText ;
11
16
public InputField systemInfoInputField ;
12
- Dictionary < string , string > dicSystemInfo ;
17
+
18
+ private const string ASSET_NAME = "OpenCVForUnity" ;
13
19
14
20
// Use this for initialization
15
21
void Start ( )
16
22
{
17
- dicSystemInfo = GetSystemInfo ( ) ;
18
23
19
- systemInfoText . text = systemInfoInputField . text = "### System Info ###" + "\n " ;
20
- Debug . Log ( "### System Info ###" ) ;
24
+ StringBuilder sb = new StringBuilder ( ) ;
25
+ sb . Append ( "###### Build Info ######\n " ) ;
26
+ IDictionary < string , string > buildInfo = GetBuildInfo ( ) ;
27
+ foreach ( string key in buildInfo . Keys )
28
+ {
29
+ sb . Append ( key ) . Append ( " = " ) . Append ( buildInfo [ key ] ) . Append ( "\n " ) ;
30
+ }
31
+ sb . Append ( "\n " ) ;
32
+
33
+ #if UNITY_IOS || ( UNITY_ANDROID && UNITY_2018_3_OR_NEWER )
34
+ sb . Append ( "###### Device Info ######\n " ) ;
35
+ IDictionary < string , string > deviceInfo = GetDeviceInfo ( ) ;
36
+ foreach ( string key in deviceInfo . Keys )
37
+ {
38
+ sb . Append ( key ) . Append ( " = " ) . Append ( deviceInfo [ key ] ) . Append ( "\n " ) ;
39
+ }
40
+ sb . Append ( "\n " ) ;
41
+ #endif
21
42
22
- foreach ( string key in dicSystemInfo . Keys )
43
+ sb . Append ( "###### System Info ######\n " ) ;
44
+ IDictionary < string , string > systemInfo = GetSystemInfo ( ) ;
45
+ foreach ( string key in systemInfo . Keys )
23
46
{
24
- systemInfoText . text = systemInfoInputField . text += key + " = " + dicSystemInfo [ key ] + "\n " ;
25
- Debug . Log ( key + "=" + dicSystemInfo [ key ] ) ;
47
+ sb . Append ( key ) . Append ( " = " ) . Append ( systemInfo [ key ] ) . Append ( "\n " ) ;
26
48
}
49
+ sb . Append ( "#########################\n " ) ;
27
50
28
- systemInfoText . text = systemInfoInputField . text += "###################" + " \n " ;
29
- Debug . Log ( "###################" ) ;
51
+ systemInfoText . text = systemInfoInputField . text = sb . ToString ( ) ;
52
+ Debug . Log ( sb . ToString ( ) ) ;
30
53
}
31
54
32
55
// Update is called once per frame
@@ -35,84 +58,119 @@ void Update()
35
58
36
59
}
37
60
38
- public Dictionary < string , string > GetSystemInfo ( )
61
+ public Dictionary < string , string > GetBuildInfo ( )
39
62
{
40
- Dictionary < string , string > dicSystemInfo = new Dictionary < string , string > ( ) ;
63
+ Dictionary < string , string > dict = new Dictionary < string , string > ( ) ;
41
64
42
- dicSystemInfo . Add ( "OpenCVForUnity version", OpenCVForUnity . CoreModule . Core . NATIVE_LIBRARY_NAME + " " + OpenCVForUnity . UnityUtils . Utils . getVersion ( ) + " (" + OpenCVForUnity . CoreModule . Core . VERSION + ")" ) ;
43
- dicSystemInfo . Add ( "Build Unity version" , Application . unityVersion ) ;
65
+ dict . Add ( ASSET_NAME + " version", Core . NATIVE_LIBRARY_NAME + " " + Utils . getVersion ( ) + " (" + Core . VERSION + ")" ) ;
66
+ dict . Add ( "Build Unity version" , Application . unityVersion ) ;
44
67
45
68
#if UNITY_EDITOR
46
- dicSystemInfo . Add ( "Build target" , "Editor" ) ;
69
+ dict . Add ( "Build target" , "Editor" ) ;
47
70
#elif UNITY_STANDALONE_WIN
48
- dicSystemInfo . Add ( "Build target" , "Windows" ) ;
71
+ dict . Add ( "Build target" , "Windows" ) ;
49
72
#elif UNITY_STANDALONE_OSX
50
- dicSystemInfo . Add ( "Build target" , "Mac OSX" ) ;
73
+ dict . Add ( "Build target" , "Mac OSX" ) ;
51
74
#elif UNITY_STANDALONE_LINUX
52
- dicSystemInfo . Add ( "Build target" , "Linux" ) ;
75
+ dict . Add ( "Build target" , "Linux" ) ;
53
76
#elif UNITY_ANDROID
54
- dicSystemInfo . Add ( "Build target" , "Android" ) ;
77
+ dict . Add ( "Build target" , "Android" ) ;
55
78
#elif UNITY_IOS
56
- dicSystemInfo . Add ( "Build target" , "iOS" ) ;
79
+ dict . Add ( "Build target" , "iOS" ) ;
57
80
#elif UNITY_WSA
58
- dicSystemInfo . Add ( "Build target" , "WSA" ) ;
81
+ dict . Add ( "Build target" , "WSA" ) ;
59
82
#elif UNITY_WEBGL
60
- dicSystemInfo . Add ( "Build target" , "WebGL" ) ;
83
+ dict . Add ( "Build target" , "WebGL" ) ;
84
+ #elif PLATFORM_LUMIN
85
+ dict . Add ( "Build target" , "LUMIN" ) ;
61
86
#else
62
- dicSystemInfo . Add ( "Build target" , "" ) ;
87
+ dict . Add ( "Build target" , "" ) ;
63
88
#endif
64
89
65
90
#if ENABLE_MONO
66
- dicSystemInfo . Add ( "Scripting backend" , "Mono" ) ;
91
+ dict . Add ( "Scripting backend" , "Mono" ) ;
67
92
#elif ENABLE_IL2CPP
68
- dicSystemInfo . Add ( "Scripting backend" , "IL2CPP" ) ;
93
+ dict . Add ( "Scripting backend" , "IL2CPP" ) ;
69
94
#elif ENABLE_DOTNET
70
- dicSystemInfo . Add ( "Scripting backend" , ".NET" ) ;
95
+ dict . Add ( "Scripting backend" , ".NET" ) ;
96
+ #else
97
+ dict . Add ( "Scripting backend" , "" ) ;
98
+ #endif
99
+
100
+ #if OPENCV_USE_UNSAFE_CODE
101
+ dict . Add ( "Allow 'unsafe' Code" , "Enabled" ) ;
71
102
#else
72
- dicSystemInfo . Add ( "Scripting backend " , "" ) ;
103
+ dict . Add ( "Allow 'unsafe' Code " , "Disabled " ) ;
73
104
#endif
74
105
75
- dicSystemInfo . Add ( "operatingSystem" , SystemInfo . operatingSystem ) ;
106
+ return dict ;
107
+ }
108
+
109
+ public Dictionary < string , string > GetDeviceInfo ( )
110
+ {
111
+ Dictionary < string , string > dict = new Dictionary < string , string > ( ) ;
76
112
77
113
#if UNITY_IOS
78
- #if UNITY_5_4_OR_NEWER
79
- dicSystemInfo . Add ( "iPhone.generation" , UnityEngine . iOS . Device . generation . ToString ( ) ) ;
80
- #else
81
- dicSystemInfo . Add ( "iPhone.generation" , UnityEngine . iPhone . generation . ToString ( ) ) ;
114
+ dict . Add ( "iOS.Device.generation" , UnityEngine . iOS . Device . generation . ToString ( ) ) ;
115
+ dict . Add ( "iOS.Device.systemVersion" , UnityEngine . iOS . Device . systemVersion . ToString ( ) ) ;
82
116
#endif
83
- #else
84
- dicSystemInfo . Add ( "iPhone.generation" , "" ) ;
117
+ #if UNITY_IOS && UNITY_2018_1_OR_NEWER
118
+ dict . Add ( "UserAuthorization.WebCam" , Application . HasUserAuthorization ( UserAuthorization . WebCam ) . ToString ( ) ) ;
119
+ dict . Add ( "UserAuthorization.Microphone" , Application . HasUserAuthorization ( UserAuthorization . Microphone ) . ToString ( ) ) ;
85
120
#endif
86
-
87
- //dicSystemInfo.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
88
- dicSystemInfo . Add ( "deviceModel" , SystemInfo . deviceModel ) ;
89
- dicSystemInfo . Add ( "deviceName" , SystemInfo . deviceName ) ;
90
- dicSystemInfo . Add ( "deviceType" , SystemInfo . deviceType . ToString ( ) ) ;
91
- dicSystemInfo . Add ( "graphicsDeviceName" , SystemInfo . graphicsDeviceName ) ;
92
- dicSystemInfo . Add ( "graphicsDeviceVendor" , SystemInfo . graphicsDeviceVendor ) ;
93
- dicSystemInfo . Add ( "processorType" , SystemInfo . processorType ) ;
94
- dicSystemInfo . Add ( "graphicsMemorySize" , SystemInfo . graphicsMemorySize . ToString ( ) ) ;
95
- dicSystemInfo . Add ( "systemMemorySize" , SystemInfo . systemMemorySize . ToString ( ) ) ;
96
-
97
- dicSystemInfo . Add ( "graphicsDeviceID" , SystemInfo . graphicsDeviceID . ToString ( ) ) ;
98
- dicSystemInfo . Add ( "graphicsDeviceType" , SystemInfo . graphicsDeviceType . ToString ( ) ) ;
99
- dicSystemInfo . Add ( "graphicsDeviceVendorID" , SystemInfo . graphicsDeviceVendorID . ToString ( ) ) ;
100
- dicSystemInfo . Add ( "graphicsDeviceVersion" , SystemInfo . graphicsDeviceVersion ) ;
101
- dicSystemInfo . Add ( "graphicsMultiThreaded" , SystemInfo . graphicsMultiThreaded . ToString ( ) ) ;
102
- dicSystemInfo . Add ( "graphicsShaderLevel" , SystemInfo . graphicsShaderLevel . ToString ( ) ) ;
103
-
104
- #if UNITY_5_4_OR_NEWER
105
- dicSystemInfo . Add ( "copyTextureSupport" , SystemInfo . copyTextureSupport . ToString ( ) ) ;
106
- #else
107
- dicSystemInfo . Add ( "copyTextureSupport" , "" ) ;
121
+ #if UNITY_ANDROID && UNITY_2018_3_OR_NEWER
122
+ dict . Add ( "Android.Permission.Camera" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . Camera ) . ToString ( ) ) ;
123
+ dict . Add ( "Android.Permission.CoarseLocation" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . CoarseLocation ) . ToString ( ) ) ;
124
+ dict . Add ( "Android.Permission.ExternalStorageRead" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . ExternalStorageRead ) . ToString ( ) ) ;
125
+ dict . Add ( "Android.Permission.ExternalStorageWrite" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . ExternalStorageWrite ) . ToString ( ) ) ;
126
+ dict . Add ( "Android.Permission.FineLocation" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . FineLocation ) . ToString ( ) ) ;
127
+ dict . Add ( "Android.Permission.Microphone" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . Microphone ) . ToString ( ) ) ;
108
128
#endif
109
129
110
- dicSystemInfo . Add ( "supportsAccelerometer" , SystemInfo . supportsAccelerometer . ToString ( ) ) ;
111
- dicSystemInfo . Add ( "supportsGyroscope" , SystemInfo . supportsGyroscope . ToString ( ) ) ;
112
- dicSystemInfo . Add ( "supportsVibration" , SystemInfo . supportsVibration . ToString ( ) ) ;
113
- dicSystemInfo . Add ( "supportsLocationService" , SystemInfo . supportsLocationService . ToString ( ) ) ;
130
+ return dict ;
131
+ }
132
+
133
+ /// SystemInfo Class Propertys
134
+ public SortedDictionary < string , string > GetSystemInfo ( )
135
+ {
136
+ SortedDictionary < string , string > dict = new SortedDictionary < string , string > ( ) ;
137
+
138
+ Type type = typeof ( SystemInfo ) ;
139
+ MemberInfo [ ] members = type . GetMembers (
140
+ BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
141
+
142
+ foreach ( MemberInfo mb in members )
143
+ {
144
+ try
145
+ {
146
+ if ( mb . MemberType == MemberTypes . Property )
147
+ {
148
+ if ( mb . Name == "deviceUniqueIdentifier" )
149
+ {
150
+ dict . Add ( mb . Name , "xxxxxxxxxxxxxxxxxxxxxxxx" ) ;
151
+ continue ;
152
+ }
153
+
154
+ PropertyInfo pr = type . GetProperty ( mb . Name ) ;
155
+
156
+ if ( pr != null )
157
+ {
158
+ object resobj = pr . GetValue ( type , null ) ;
159
+ dict . Add ( mb . Name , resobj . ToString ( ) ) ;
160
+ }
161
+ else
162
+ {
163
+ dict . Add ( mb . Name , "" ) ;
164
+ }
165
+ }
166
+ }
167
+ catch ( Exception e )
168
+ {
169
+ Debug . Log ( "Exception: " + e ) ;
170
+ }
171
+ }
114
172
115
- return dicSystemInfo ;
173
+ return dict ;
116
174
}
117
175
118
176
public void OnBackButtonClick ( )
0 commit comments