in RealityMaterialExplorer/Assets/Oculus/VR/Editor/OVRLint.cs [283:579]
static void CheckStaticCommonIssues()
{
if (OVRManager.IsUnityAlphaOrBetaVersion())
{
AddFix("General", OVRManager.UnityAlphaOrBetaVersionWarningMessage, null, null, false);
}
if (QualitySettings.anisotropicFiltering != AnisotropicFiltering.Enable && QualitySettings.anisotropicFiltering != AnisotropicFiltering.ForceEnable)
{
AddFix("Optimize Aniso", "Anisotropic filtering is recommended for optimal image sharpness and GPU performance.", delegate (UnityEngine.Object obj, bool last, int selected)
{
// Ideally this would be multi-option: offer Enable or ForceEnable.
QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable;
}, null, false, "Fix");
}
#if UNITY_ANDROID
int recommendedPixelLightCount = 1;
#else
int recommendedPixelLightCount = 3;
#endif
if (QualitySettings.pixelLightCount > recommendedPixelLightCount)
{
AddFix("Optimize Pixel Light Count", "For GPU performance set no more than " + recommendedPixelLightCount + " pixel lights in Quality Settings (currently " + QualitySettings.pixelLightCount + ").", delegate (UnityEngine.Object obj, bool last, int selected)
{
QualitySettings.pixelLightCount = recommendedPixelLightCount;
}, null, false, "Fix");
}
#if false
// Should we recommend this? Seems to be mutually exclusive w/ dynamic batching.
if (!PlayerSettings.graphicsJobs)
{
AddFix ("Optimize Graphics Jobs", "For CPU performance, please use graphics jobs.", delegate(UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.graphicsJobs = true;
}, null, false, "Fix");
}
#endif
if ((!PlayerSettings.MTRendering || !PlayerSettings.GetMobileMTRendering(BuildTargetGroup.Android)))
{
AddFix("Optimize MT Rendering", "For CPU performance, please enable multithreaded rendering.", delegate (UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Standalone, true);
PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, true);
}, null, false, "Fix");
}
#if UNITY_ANDROID
if (!PlayerSettings.use32BitDisplayBuffer)
{
AddFix("Optimize Display Buffer Format", "We recommend to enable use32BitDisplayBuffer.", delegate (UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.use32BitDisplayBuffer = true;
}, null, false, "Fix");
}
#endif
#if !UNITY_ANDROID && !USING_XR_SDK && !REQUIRES_XR_SDK
#pragma warning disable 618
if (!PlayerSettings.VROculus.dashSupport)
{
AddFix("Enable Dash Integration", "We recommend to enable Dash Integration for better user experience.", delegate (UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.VROculus.dashSupport = true;
}, null, false, "Fix");
}
if (!PlayerSettings.VROculus.sharedDepthBuffer)
{
AddFix("Enable Depth Buffer Sharing", "We recommend to enable Depth Buffer Sharing for better user experience on Oculus Dash.", delegate (UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.VROculus.sharedDepthBuffer = true;
}, null, false, "Fix");
}
#pragma warning restore 618
#endif
BuildTargetGroup target = EditorUserBuildSettings.selectedBuildTargetGroup;
var tier = UnityEngine.Rendering.GraphicsTier.Tier1;
var tierSettings = UnityEditor.Rendering.EditorGraphicsSettings.GetTierSettings(target, tier);
if ((tierSettings.renderingPath == RenderingPath.DeferredShading ||
tierSettings.renderingPath == RenderingPath.DeferredLighting))
{
AddFix("Optimize Rendering Path", "For CPU performance, please do not use deferred shading.", delegate (UnityEngine.Object obj, bool last, int selected)
{
tierSettings.renderingPath = RenderingPath.Forward;
UnityEditor.Rendering.EditorGraphicsSettings.SetTierSettings(target, tier, tierSettings);
}, null, false, "Use Forward");
}
if (PlayerSettings.stereoRenderingPath == StereoRenderingPath.MultiPass)
{
AddFix("Optimize Stereo Rendering", "For CPU performance, please enable single-pass or instanced stereo rendering.", delegate (UnityEngine.Object obj, bool last, int selected)
{
PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing;
}, null, false, "Fix");
}
if (LightmapSettings.lightmaps.Length > 0 && LightmapSettings.lightmapsMode != LightmapsMode.NonDirectional)
{
AddFix("Optimize Lightmap Directionality", "Switching from directional lightmaps to non-directional lightmaps can save a small amount of GPU time.", delegate (UnityEngine.Object obj, bool last, int selected)
{
LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
}, null, false, "Switch to non-directional lightmaps");
}
if (Lightmapping.realtimeGI)
{
AddFix("Disable Realtime GI", "Disabling real-time global illumination can improve GPU performance.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Lightmapping.realtimeGI = false;
}, null, false, "Set Lightmapping.realtimeGI = false.");
}
var lights = GameObject.FindObjectsOfType<Light>();
for (int i = 0; i < lights.Length; ++i)
{
if (lights [i].type != LightType.Directional && !lights [i].bakingOutput.isBaked && IsLightBaked(lights[i]))
{
AddFix("Unbaked Lights", "The following lights in the scene are marked as Baked, but they don't have up to date lightmap data. Generate the lightmap data, or set it to auto-generate, in Window->Lighting->Settings.", null, lights[i], false, null);
}
if (lights[i].shadows != LightShadows.None && !IsLightBaked(lights[i]))
{
AddFix("Optimize Shadows", "For CPU performance, consider disabling shadows on realtime lights.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Light thisLight = (Light)obj;
thisLight.shadows = LightShadows.None;
}, lights[i], false, "Set \"Shadow Type\" to \"No Shadows\"");
}
}
var sources = GameObject.FindObjectsOfType<AudioSource>();
if (sources.Length > 16)
{
List<AudioSource> playingAudioSources = new List<AudioSource>();
foreach (var audioSource in sources)
{
if (audioSource.isPlaying)
{
playingAudioSources.Add(audioSource);
}
}
if (playingAudioSources.Count > 16)
{
// Sort playing audio sources by priority
playingAudioSources.Sort(delegate (AudioSource x, AudioSource y)
{
return x.priority.CompareTo(y.priority);
});
for (int i = 16; i < playingAudioSources.Count; ++i)
{
AddFix("Optimize Audio Source Count", "For CPU performance, please disable all but the top 16 AudioSources.", delegate (UnityEngine.Object obj, bool last, int selected)
{
AudioSource audioSource = (AudioSource)obj;
audioSource.enabled = false;
}, playingAudioSources[i], false, "Disable");
}
}
}
var clips = GameObject.FindObjectsOfType<AudioClip>();
for (int i = 0; i < clips.Length; ++i)
{
if (clips[i].loadType == AudioClipLoadType.DecompressOnLoad)
{
AddFix("Audio Loading", "For fast loading, please don't use decompress on load for audio clips", delegate (UnityEngine.Object obj, bool last, int selected)
{
AudioClip thisClip = (AudioClip)obj;
if (selected == 0)
{
SetAudioLoadType(thisClip, AudioClipLoadType.CompressedInMemory, last);
}
else
{
SetAudioLoadType(thisClip, AudioClipLoadType.Streaming, last);
}
}, clips[i], false, "Change to Compressed in Memory", "Change to Streaming");
}
if (clips[i].preloadAudioData)
{
AddFix("Audio Preload", "For fast loading, please don't preload data for audio clips.", delegate (UnityEngine.Object obj, bool last, int selected)
{
SetAudioPreload(clips[i], false, last);
}, clips[i], false, "Fix");
}
}
if (Physics.defaultContactOffset < 0.01f)
{
AddFix("Optimize Contact Offset", "For CPU performance, please don't use default contact offset below 0.01.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Physics.defaultContactOffset = 0.01f;
}, null, false, "Fix");
}
if (Physics.sleepThreshold < 0.005f)
{
AddFix("Optimize Sleep Threshold", "For CPU performance, please don't use sleep threshold below 0.005.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Physics.sleepThreshold = 0.005f;
}, null, false, "Fix");
}
if (Physics.defaultSolverIterations > 8)
{
AddFix("Optimize Solver Iterations", "For CPU performance, please don't use excessive solver iteration counts.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Physics.defaultSolverIterations = 8;
}, null, false, "Fix");
}
var materials = Resources.FindObjectsOfTypeAll<Material>();
for (int i = 0; i < materials.Length; ++i)
{
if (materials[i].shader.name.Contains("Parallax") || materials[i].IsKeywordEnabled("_PARALLAXMAP"))
{
AddFix("Optimize Shading", "For GPU performance, please don't use parallax-mapped materials.", delegate (UnityEngine.Object obj, bool last, int selected)
{
Material thisMaterial = (Material)obj;
if (thisMaterial.IsKeywordEnabled("_PARALLAXMAP"))
{
thisMaterial.DisableKeyword("_PARALLAXMAP");
}
if (thisMaterial.shader.name.Contains("Parallax"))
{
var newName = thisMaterial.shader.name.Replace("-ParallaxSpec", "-BumpSpec");
newName = newName.Replace("-Parallax", "-Bump");
var newShader = Shader.Find(newName);
if (newShader)
{
thisMaterial.shader = newShader;
}
else
{
Debug.LogWarning("Unable to find a replacement for shader " + materials[i].shader.name);
}
}
}, materials[i], false, "Fix");
}
}
var renderers = GameObject.FindObjectsOfType<Renderer>();
for (int i = 0; i < renderers.Length; ++i)
{
if (renderers[i].sharedMaterial == null)
{
AddFix("Instanced Materials", "Please avoid instanced materials on renderers.", null, renderers[i], false);
}
}
var overlays = GameObject.FindObjectsOfType<OVROverlay>();
if (overlays.Length > 4)
{
AddFix("Optimize VR Layer Count", "For GPU performance, please use 4 or fewer VR layers.", delegate (UnityEngine.Object obj, bool last, int selected)
{
for (int i = 4; i < OVROverlay.instances.Length; ++i)
{
OVROverlay.instances[i].enabled = false;
}
}, null, false, "Fix");
}
var splashScreen = PlayerSettings.virtualRealitySplashScreen;
if (splashScreen != null)
{
if (splashScreen.filterMode != FilterMode.Trilinear)
{
AddFix("Optimize VR Splash Filtering", "For visual quality, please use trilinear filtering on your VR splash screen.", delegate (UnityEngine.Object obj, bool last, int EditorSelectedRenderState)
{
var assetPath = AssetDatabase.GetAssetPath(splashScreen);
var importer = (TextureImporter)TextureImporter.GetAtPath(assetPath);
importer.filterMode = FilterMode.Trilinear;
AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
}, null, false, "Fix");
}
if (splashScreen.mipmapCount <= 1)
{
AddFix("Generate VR Splash Mipmaps", "For visual quality, please use mipmaps with your VR splash screen.", delegate (UnityEngine.Object obj, bool last, int EditorSelectedRenderState)
{
var assetPath = AssetDatabase.GetAssetPath(splashScreen);
var importer = (TextureImporter)TextureImporter.GetAtPath(assetPath);
importer.mipmapEnabled = true;
AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
}, null, false, "Fix");
}
}
}