File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Assets/Plugins/WebGL/WebGLTools Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 88// </author>
99// --------------------------------------------------------------------------------------------------------------------
1010
11+ using System ;
12+ using System . Collections . Generic ;
1113using Supyrb . Attributes ;
1214using UnityEngine ;
1315
@@ -125,5 +127,39 @@ public void LogMessage(string message)
125127 {
126128 Debug . Log ( message ) ;
127129 }
130+
131+ /// <summary>
132+ /// Log information of all texture formats that Unity supports, which ones are supported by
133+ /// the current platform and browser, and which ones are not supported
134+ /// </summary>
135+ [ WebGlCommand ( Description = "Log supported and unsupported texture formats" ) ]
136+ public void LogTextureSupport ( )
137+ {
138+ List < TextureFormat > supportedFormats = new List < TextureFormat > ( ) ;
139+ List < TextureFormat > unsupportedFormats = new List < TextureFormat > ( ) ;
140+
141+ foreach ( TextureFormat textureFormat in Enum . GetValues ( typeof ( TextureFormat ) ) )
142+ {
143+ var memberInfos = typeof ( TextureFormat ) . GetMember ( textureFormat . ToString ( ) ) ;
144+ object [ ] obsoleteAttributes = memberInfos [ 0 ] . GetCustomAttributes ( typeof ( ObsoleteAttribute ) , false ) ;
145+ if ( obsoleteAttributes . Length > 0 )
146+ {
147+ // don't evaluate obsolete enum values
148+ continue ;
149+ }
150+
151+ if ( SystemInfo . SupportsTextureFormat ( textureFormat ) )
152+ {
153+ supportedFormats . Add ( textureFormat ) ;
154+ }
155+ else
156+ {
157+ unsupportedFormats . Add ( textureFormat ) ;
158+ }
159+ }
160+
161+ Debug . Log ( $ "Supported Texture formats: \n { string . Join ( ", " , supportedFormats ) } ") ;
162+ Debug . Log ( $ "Unsupported Texture formats: \n { string . Join ( ", " , unsupportedFormats ) } ") ;
163+ }
128164 }
129165}
You can’t perform that action at this time.
0 commit comments