Astra Unity 2.6.6
Astra Unity Plugin
Astra.Utils.FeatureDetection Class Reference

Public Types

enum  PREFERRED_TEXTURE_FORMAT {
  SRC = 1 , DXT = 2 , ETC1 = 3 , PVR = 4 ,
  DXT5 = 5 , ETC2 = 6 , DXT1 = 7 , ASTC = 8 ,
  BASISU = 9 , BC7 = 10
}
 

Static Public Member Functions

static PokethroughPreventionMode GetPokethroughPreventionMode ()
 Whether pokethrough prevention mode is enabled
 
static void SetPokethroughPreventionMode (PokethroughPreventionMode mode)
 Set whether pokethrough prevention mode is enabled More...
 
static void ToggleDecalsUseNormals (bool enabled)
 Set whether decals will use normals More...
 
static bool GetDecalsUseNormals ()
 Whether decals will use normals
 
static bool IsSRP (bool refresh=false)
 Whether we are using the SRP rendering pipeline
 
static bool IsHDRP (bool refresh=false)
 Whether we are using the HDRP rendering pipeline
 
static bool IsURP (bool refresh=false)
 Whether we are using the URP rendering pipeline
 
static bool IsLegacyPipeline (bool refresh=false)
 Whether we are using the builtin/legacy render pipeline More...
 
static bool IsBuiltinRenderPipeline (bool refresh=false)
 Whether we are using the builtin/legacy render pipeline More...
 
static string GetRenderPipeline ()
 Returns the unity render pipeline name or null Examples: UnityEngine.Experimental.Rendering.HDPipeline.HDRenderPipeline
 
static void ToggleShaderSwapToHDRP (bool enable)
 Set whether we should swap shaders to use HDRP More...
 
static bool ShouldReplaceShaderWithHDRP ()
 Whether we should swap shaders to use HDRP
 
static void ToggleShaderSwapToURP (bool enable)
 Set whether we should swap shaders to use URP More...
 
static bool ShouldReplaceShaderWithURP ()
 Whether we should swap shaders to use URP
 
static void ForceIsMobile (bool isMobile)
 This is a public override that can be used to FORCE the mobile boolean You should AVOID using this unless you have to (due to compile/editor type issues) More...
 
static bool GPUSupportsPowerVR ()
 Whether this GPU supports the PowerVR texture format
 
static bool GPUSupportsETC2 ()
 Whether this GPU supports the ETC2 texture format
 
static bool GPUSupportsETC1 ()
 Whether this GPU supports the ETC2 texture format
 
static bool GPUSupportsDXT5 ()
 Whether this GPU supports the ETC2 texture format
 
static bool GPUSupportsDXT1 ()
 Whether this GPU supports the ETC2 texture format
 
static bool GPUSupportsASTC ()
 True if the GPU supports ASTC texture formats More...
 
static bool GPUSupportsBC7 ()
 True if the GPU supports BC7 texture formats More...
 
static bool SupportsRuntimeCompression ()
 Do we support compression of the texture on the fly, this is typically only allowed on DXT as this is a quick compression format
 
static int GPUMaxTextureSize ()
 What is the maximum width or height supported in pixels, eg: 2048 (desktops are usually 4k or 8k)
 
static bool GPUSupportsR8 ()
 Whether this GPU supports the R8 render texture format
 
static bool SupportsComputeShaders ()
 Whether this platform supports compute shaders
 
static void ToggleSupportsComputeShaders (bool enabled)
 
static bool SupportsConvertTexture ()
 Whether this platform supports the Graphics.ConvertTexture function
 
static bool SupportsCopyTexture ()
 Whether this platform supports copying a texture in the gpu to the gpu (much faster then blitting to cpu back to gpu) NOTE: currently this is disabled for all platforms that are not windows
 
static bool SupportsCopyTextureRTToTexture ()
 Does this system support CopyTexture between a render texture using RT to texture2D? Most DX11+ systems will support this, if we have support we can more efficiently copy between a gpu to cpu texture
 
static bool SupportsCopyTextureDifferentTypes ()
 Does this system support CopyTexture between a render texture not using RT to texture2D? Most DX11+ systems will support this, if we have support we can more efficiently copy between a gpu to cpu texture
 
static bool SupportsFastTextureIsReadable (bool refresh=false)
 Does this version of unity support Texture2D.isReadable flag This was added in version 2018.3 NOTE: this check is compile time dependent (at time of Astra compilation) More...
 
static void ToggleFastTextureIsReadable (bool flag)
 
static bool IsMobile ()
 Whether this is targetting a mobile platform NOTE: returns true for tablets as well NOTE: this only returns TRUE if the ACTIVE RUNNING PLATFORM is mobile which means if you're in editor this will always be false regardless of build target but when you run your build on a phone it will return true
 
static bool isIOS ()
 Whether this is running on an iOS platform
 
static PREFERRED_TEXTURE_FORMAT GetPreferredTextureFormat ()
 Return the preferred render format for this platform
 
static int GetPreferredTextureMaxSize ()
 What is the preferred max texture resoultion we want to use Returns the single dimension in powers of 2 for tex size, returns 0 if no preferrence More...
 
static void OverridePreferredTextureMaxSize (int preferredTextureMaxSize)
 Override the setting for maximum texture size. This is normally set by the memory constraints of your player or what platform you are on, but you can override that setting here More...
 
static void OverridePreferredTextureCompression (PREFERRED_TEXTURE_FORMAT preferredTextureFormat)
 Override the setting for texture format. This is normally set by the device constraints of your player or what platform you are on, but you can override that setting here More...
 
static int GetPreferredTextureMaskMaxSize ()
 When using simple mask textures (like alpha injection) what size do we want to use?
 
static int GetPreferredTextureDecalMaxSize ()
 When using decal textures, what size do we want to use?
 
static int GetPreferredTextureThumbnailMaxSize ()
 When using thumbnail textures, what size do we want to use
 
static int GetPreferredSlabIconSize ()
 
static void PreferDynamicTextureCompression (bool enable)
 Should dynamic textures (eg: alpha injection, decals, etc) be compressed By enabling true, you will currently take a 2x 5-10ms hit per texture More...
 
static bool GetPreferredDynamicTextureCompression ()
 For textures like alpha injection masks and computed decals, should those be compressed This is typically turned off for VR applications as runtime compression introduces frame drop (until we add our own GetPixels and compression library)
 
static bool GetSupportsPackedMesh ()
 Whether this platform supports packing a mesh
 
static bool SetSupportsPackedMesh (bool enable)
 Set whether this platform should support packing a mesh More...
 
static bool IsIL2CPP ()
 Guess if we are running on IL2CPP vs mono More...
 
static bool UseDelegatesFromC ()
 Should we use delegates during calls to our C APU (such as progress updates) More...
 
static void ToggleUseDelegatesFromC (bool enabled)
 Manually override if we want to use progress delegates More...
 
static bool IsDebuggerAttached ()
 Tells us if we have a debugger attached (managed or unmanaged handling) More...
 

Static Protected Member Functions

static bool _GPUSupportsPowerVR ()
 
static bool _GPUSupportsETC2 ()
 
static bool _GPUSupportsETC1 ()
 
static bool _GPUSupportsDXT5 ()
 
static bool _GPUSupportsDXT1 ()
 
static bool _GPUSupportsASTC ()
 
static bool _GPUSupportsBC7 ()
 
static bool _SupportsRuntimeCompression ()
 
static int _GPUMaxTextureSize ()
 
static bool _SupportsComputeShaders ()
 

Static Protected Attributes

static bool _supportsPowerVR = false
 
static bool _supportsETC2 = false
 
static bool _supportsETC1 = false
 
static bool _supportsDXT5 = false
 
static bool _supportsDXT1 = false
 
static bool _supportsASTC = false
 
static bool _supportsBC7 = false
 
static bool _supportsCompression = false
 
static ? bool _supportsFastTextureIsReadable = null
 
static int _maxTextureSize = 0
 
static UnityEngine.Rendering.CopyTextureSupport _copyTextureSupport = UnityEngine.Rendering.CopyTextureSupport.None
 
static bool _compressDynamicTextures = true
 If true, this means that when possible dynamic textures will be compressed, this has a performance cost currently (we'll fix this later) of about 2x 5-10ms hit on main thread due to a necessary gpu->cpu read pixels call and compress call, for VR applications you should consider setting this to false when possible
 
static bool _isMobileSet = false
 
static bool _isMobile = false
 
static bool _decalsUseNormals = true
 If true when applying decals the normal maps will be blended into the final mesh If false normal textures in the decals will be ignored
 
static bool _supportsComputeShaders = false
 If true this platform supports compute shaders Note: compute shaders are not supported on MacOS for OpenGL 4.3
 
static ? bool _isSRP = null
 
static ? bool _isURP = null
 
static ? bool _isHDRP = null
 
static ? bool _isLegacyPipeline = null
 
static bool _autoReplaceLegacyShadersWithHDRP = false
 
static bool _autoReplaceLegacyShadersWithURP = false
 
static PokethroughPreventionMode _pokethroughPreventionMode = PokethroughPreventionMode.AlphaTest
 
static ? bool _isIOS = null
 
static ? bool _isIL2CPP = null
 
static ? bool _useDelegatesFromC = null
 

Detailed Description

A simple tool for determining what features and preferences are available on the device

Resources: http://wiki.polycount.com/wiki/DXT https://docs.unrealengine.com/udk/Two/TextureComparison.html

Member Function Documentation

◆ ForceIsMobile()

static void Astra.Utils.FeatureDetection.ForceIsMobile ( bool  isMobile)
inlinestatic

This is a public override that can be used to FORCE the mobile boolean You should AVOID using this unless you have to (due to compile/editor type issues)

Parameters
isMobile

◆ GetPreferredTextureMaxSize()

static int Astra.Utils.FeatureDetection.GetPreferredTextureMaxSize ( )
inlinestatic

What is the preferred max texture resoultion we want to use Returns the single dimension in powers of 2 for tex size, returns 0 if no preferrence

1080ti ~ 11 1070 ~ 8 1030 ~ 2 iPad 2017 ~ 2

◆ GPUSupportsASTC()

static bool Astra.Utils.FeatureDetection.GPUSupportsASTC ( )
inlinestatic

True if the GPU supports ASTC texture formats

Returns

◆ GPUSupportsBC7()

static bool Astra.Utils.FeatureDetection.GPUSupportsBC7 ( )
inlinestatic

True if the GPU supports BC7 texture formats

Returns

◆ IsBuiltinRenderPipeline()

static bool Astra.Utils.FeatureDetection.IsBuiltinRenderPipeline ( bool  refresh = false)
inlinestatic

Whether we are using the builtin/legacy render pipeline

Parameters
refreshIf true clears the detection cache
Returns
True if builtin/legacy false otherwise

◆ IsDebuggerAttached()

static bool Astra.Utils.FeatureDetection.IsDebuggerAttached ( )
inlinestatic

Tells us if we have a debugger attached (managed or unmanaged handling)

Returns

◆ IsIL2CPP()

static bool Astra.Utils.FeatureDetection.IsIL2CPP ( )
inlinestatic

Guess if we are running on IL2CPP vs mono

Returns
True if running in IL2CPP

◆ IsLegacyPipeline()

static bool Astra.Utils.FeatureDetection.IsLegacyPipeline ( bool  refresh = false)
inlinestatic

Whether we are using the builtin/legacy render pipeline

Parameters
refreshIf true clears the detection cache
Returns
True if builtin/legacy false otherwise

◆ OverridePreferredTextureCompression()

static void Astra.Utils.FeatureDetection.OverridePreferredTextureCompression ( PREFERRED_TEXTURE_FORMAT  preferredTextureFormat)
inlinestatic

Override the setting for texture format. This is normally set by the device constraints of your player or what platform you are on, but you can override that setting here

Parameters
preferredTextureFormatMaximum size to use (use a power of 2). Set to 0 to indicate no preference (for high end machines)

◆ OverridePreferredTextureMaxSize()

static void Astra.Utils.FeatureDetection.OverridePreferredTextureMaxSize ( int  preferredTextureMaxSize)
inlinestatic

Override the setting for maximum texture size. This is normally set by the memory constraints of your player or what platform you are on, but you can override that setting here

Parameters
preferredTextureMaxSizeMaximum size to use (use a power of 2). Set to 0 to indicate no preference (for high end machines)

◆ PreferDynamicTextureCompression()

static void Astra.Utils.FeatureDetection.PreferDynamicTextureCompression ( bool  enable)
inlinestatic

Should dynamic textures (eg: alpha injection, decals, etc) be compressed By enabling true, you will currently take a 2x 5-10ms hit per texture

Parameters
enableWhether this should be enabled

◆ SetPokethroughPreventionMode()

static void Astra.Utils.FeatureDetection.SetPokethroughPreventionMode ( PokethroughPreventionMode  mode)
inlinestatic

Set whether pokethrough prevention mode is enabled

Parameters
modeWhether it should be enabled

◆ SetSupportsPackedMesh()

static bool Astra.Utils.FeatureDetection.SetSupportsPackedMesh ( bool  enable)
inlinestatic

Set whether this platform should support packing a mesh

Parameters
enableWhether mesh packing is enabled

◆ SupportsFastTextureIsReadable()

static bool Astra.Utils.FeatureDetection.SupportsFastTextureIsReadable ( bool  refresh = false)
inlinestatic

Does this version of unity support Texture2D.isReadable flag This was added in version 2018.3 NOTE: this check is compile time dependent (at time of Astra compilation)

Returns
true is Texture2D.isReadable is available

◆ ToggleDecalsUseNormals()

static void Astra.Utils.FeatureDetection.ToggleDecalsUseNormals ( bool  enabled)
inlinestatic

Set whether decals will use normals

Parameters
enabledWhether normals are enabled

◆ ToggleShaderSwapToHDRP()

static void Astra.Utils.FeatureDetection.ToggleShaderSwapToHDRP ( bool  enable)
inlinestatic

Set whether we should swap shaders to use HDRP

Parameters
enable

◆ ToggleShaderSwapToURP()

static void Astra.Utils.FeatureDetection.ToggleShaderSwapToURP ( bool  enable)
inlinestatic

Set whether we should swap shaders to use URP

Parameters
enable

◆ ToggleUseDelegatesFromC()

static void Astra.Utils.FeatureDetection.ToggleUseDelegatesFromC ( bool  enabled)
inlinestatic

Manually override if we want to use progress delegates

Parameters
enabled

◆ UseDelegatesFromC()

static bool Astra.Utils.FeatureDetection.UseDelegatesFromC ( )
inlinestatic

Should we use delegates during calls to our C APU (such as progress updates)

Returns
True if we should use progress updates

See: https://docs.unity3d.com/Manual/ScriptingRestrictions.html


The documentation for this class was generated from the following file: