2023-11-13 06:48:15 +00:00
//Stylized Water 2
//Staggart Creations (http://staggart.xyz)
//Copyright protected under Unity Asset Store EULA
using System ;
using System.Collections.Generic ;
using System.Text ;
using System.Text.RegularExpressions ;
using UnityEditor ;
using UnityEditor.Build ;
using UnityEngine ;
using UnityEngine.Rendering ;
namespace StylizedWater2
{
public class HelpWindow : EditorWindow
{
//Window properties
private static int width = 600 ;
private static int height = 520 ;
[SerializeField]
private Changelog changelog ;
private bool underwaterExtensionInstalled ;
private bool dynamicEffectsInstalled ;
[NonSerialized] private string projectDetails ;
private Vector2 projectDetailsScrollPos ;
private const string HeaderImgData = "iVBORw0KGgoAAAANSUhEUgAAAgAAAABACAIAAADj3VjoAAAgAElEQVR4AVTdye9k2ZUf9jfF8IvflHNlDaxiVZHsJps9ia2hLUiWDFuQAEMW4J3/BsMbr7y1d954r40AowFtDBu2vBAsyepWt5oS2S0OTbI515hVlfNvjvG958/3RtGwIzMjI17cd++5557zPcMdXv0H3//TSV3VdbOs27qu+3Fsm7oeqmEcqqoaq3p0takmVT1pR78ctN28Hm/GXVXVM/eNVe+uqmqqcVM19Tj2u8FvfTWO1bgd3Fr1Td01ddW2677qxn7W1MumafqhS/1aqB/3zaKtbtXVrq4v+1H5RdfeHXbn237TtHU1nlf1w2ZcDMOjZnI49hr1tx3HRTe+fngym7Q3w2bdD1fb/mw7zOthEqLrthoHFI/VUNebamx2/bTxvWrGoWuqVxaLzVBvxt2vn5wOTfPD5cXXD+/e6RaPtlfztjnv1892m6HfnXTdw8nRaTtvq0W6Ve3Od6sPli+frLdfXJw21TCrJzi1rdZ3J7Orfvt8t344nb/cLe90x4v6cKy21/3Vathu+vqqX5/vhnpscOP+bHbYdBh92BzU9XQ73gxjdba+vuk3Dw9ubxFU7y763YfL9TSN1vN20lZVVzV3JpPFrJm3B4Zpubv85OJy6OvDyfRJqqg+XC7L0I3DMIZLGVBcGLtxPG6GiUqr8Xqot5VxqQ+b3pAtK8PfuHLaDMdY07tLdyq1bYbxbl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XTypG0udsOd2cQ955uUl5P5eMlwDpNh4BLfNFEbdpTDzhime
[MenuItem("Window/Stylized Water 2/Hub Window", false, 1001)]
public static void ShowWindow ( )
{
HelpWindow editorWindow = EditorWindow . GetWindow < HelpWindow > ( true , AssetInfo . ASSET_NAME , true ) ;
//Open somewhat in the center of the screen
editorWindow . position = new Rect ( ( Screen . currentResolution . width / 2f ) - ( width * 0.5f ) , ( Screen . currentResolution . height / 2f ) - ( height * 0.5f ) , ( width * 2 ) , height ) ;
//Fixed size
editorWindow . maxSize = new Vector2 ( width , height ) ;
editorWindow . minSize = new Vector2 ( width , height ) ;
//Init
editorWindow . Init ( ) ;
editorWindow . Show ( ) ;
}
[MenuItem("Window/Stylized Water 2/Forum", false, 1002)]
public static void OpenForum ( )
{
AssetInfo . OpenForumPage ( ) ;
}
private class Constants
{
public readonly GUIStyle sectionScrollView = "PreferencesSectionBox" ;
public readonly GUIStyle sectionElement = "PreferencesSection" ;
public readonly GUIStyle selected = "OL SelectedRow" ;
public readonly GUIStyle sectionHeader = new GUIStyle ( EditorStyles . largeLabel ) ;
public Constants ( )
{
sectionScrollView = new GUIStyle ( sectionScrollView ) ;
sectionScrollView . overflow . bottom + = 1 ;
sectionHeader . fontStyle = FontStyle . Bold ;
sectionHeader . fontSize = 18 ;
sectionHeader . margin . top = 10 ;
sectionHeader . margin . left + = 1 ;
if ( ! EditorGUIUtility . isProSkin )
sectionHeader . normal . textColor = new Color ( 0.4f , 0.4f , 0.4f , 1.0f ) ;
else
sectionHeader . normal . textColor = new Color ( 0.7f , 0.7f , 0.7f , 1.0f ) ;
}
}
static Constants constants = null ;
private void OnEnable ( )
{
AssetInfo . VersionChecking . CheckForUpdate ( false ) ;
AssetInfo . VersionChecking . CheckUnityVersion ( ) ;
underwaterExtensionInstalled = StylizedWaterEditor . UnderwaterRenderingInstalled ( ) ;
dynamicEffectsInstalled = StylizedWaterEditor . DynamicEffectsInstalled ( ) ;
sections = new List < Section > ( ) ;
sections . Add ( new Section ( "Home" , DrawHome ) ) ;
sections . Add ( new Section ( "Installation" , DrawInstallation ) ) ;
sections . Add ( new Section ( "Integrations" , DrawIntegrations ) ) ;
//sections.Add(new Section("Extensions", DrawExtensions));
sections . Add ( new Section ( "Support" , DrawSupport ) ) ;
}
private void Init ( )
{
HeaderImg = UI . CreateIcon ( HeaderImgData ) ;
}
public Texture HeaderImg { get ; set ; }
private Color defaultColor ;
private delegate void OnGUIDelegate ( ) ;
private class Section
{
public GUIContent content ;
public OnGUIDelegate drawFunction ;
public Section ( string name , OnGUIDelegate drawFunction )
{
this . content = new GUIContent ( name ) ;
this . drawFunction = drawFunction ;
}
}
private List < Section > sections ;
private int _selectedSectionIndex ;
private int selectedSectionIndex
{
get = > _selectedSectionIndex ;
set
{
_selectedSectionIndex = value ;
if ( _selectedSectionIndex > = sections . Count )
_selectedSectionIndex = 0 ;
else if ( _selectedSectionIndex < 0 )
_selectedSectionIndex = sections . Count - 1 ;
}
}
private Section selectedSection = > sections [ _selectedSectionIndex ] ;
private Vector2 menuScrollPos ;
private static Vector2 sectionScrollPos = Vector2 . zero ;
private void OnGUI ( )
{
EditorGUIUtility . labelWidth = width / 4f ;
defaultColor = GUI . contentColor ;
if ( constants = = null ) constants = new Constants ( ) ;
if ( changelog = = null ) changelog = new Changelog ( ) ;
if ( EditorApplication . isCompiling )
{
EditorGUILayout . Space ( ) ;
EditorGUILayout . LabelField ( new GUIContent ( " Compiling scripts..." , EditorGUIUtility . FindTexture ( "cs Script Icon" ) ) , UI . Styles . H1 ) ;
EditorGUILayout . Space ( ) ;
return ;
}
Rect rect = EditorGUILayout . GetControlRect ( ) ;
rect . x - = 3f ;
rect . y - = 3f ;
rect . height = 85f ;
rect . width = width ;
GUI . DrawTexture ( rect , HeaderImg ) ;
//float backgroundTint = EditorGUIUtility.isProSkin ? 0f : 1f;
//EditorGUI.DrawRect(rect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f));
GUILayout . Space ( - 7f ) ;
EditorGUILayout . LabelField ( "<size=26><color=#444444><b>" + AssetInfo . ASSET_NAME + "</b></color></size>" , UI . Styles . H1 ) ;
GUILayout . Space ( - 5f ) ;
EditorGUILayout . LabelField ( "<size=12><color=#444444><i>by Staggart Creations</i></color></size>" , UI . Styles . H1 ) ;
GUILayout . Space ( 16f ) ;
#if UNITY_2023_1_OR_NEWER
GUILayout . Space ( 4f ) ;
#endif
if ( sections = = null ) OnEnable ( ) ;
#if ! URP
UI . DrawNotification ( "The Universal Render Pipeline package isn't installed" , MessageType . Error ) ;
#endif
GUILayout . BeginHorizontal ( ) ;
{
menuScrollPos = GUILayout . BeginScrollView ( menuScrollPos , constants . sectionScrollView , GUILayout . Width ( 120f ) ) ;
{
//GUILayout.Space(40f);
for ( int i = 0 ; i < sections . Count ; i + + )
{
var section = sections [ i ] ;
Rect elementRect = GUILayoutUtility . GetRect ( section . content , constants . sectionElement , GUILayout . ExpandWidth ( true ) ) ;
if ( section = = selectedSection & & Event . current . type = = EventType . Repaint )
{
constants . selected . Draw ( elementRect , false , false , section = = selectedSection , false ) ;
}
if ( GUI . Toggle ( elementRect , selectedSectionIndex = = i , section . content , constants . sectionElement ) )
{
selectedSectionIndex = i ;
}
}
}
GUILayout . EndScrollView ( ) ;
GUILayout . Space ( 5f ) ;
GUILayout . BeginVertical ( ) ;
{
//GUILayout.Label(selectedSection.content, constants.sectionHeader);
GUILayout . Space ( 5f ) ;
sectionScrollPos = EditorGUILayout . BeginScrollView ( sectionScrollPos ) ;
selectedSection . drawFunction ( ) ;
EditorGUILayout . EndScrollView ( ) ;
}
GUILayout . EndVertical ( ) ;
}
GUILayout . EndHorizontal ( ) ;
}
void DrawHome ( )
{
using ( new EditorGUILayout . VerticalScope ( ) )
{
UI . DrawH2 ( "Thank you for licensing Stylized Water 2!" ) ;
EditorGUILayout . LabelField ( "This window houses common functionality and installation information." , EditorStyles . label ) ;
EditorGUILayout . Space ( ) ;
using ( new EditorGUILayout . HorizontalScope ( ) )
{
if ( GUILayout . Button ( new GUIContent ( "<b><size=12>Write a review</size></b>\n<i>Support further development</i>" , EditorGUIUtility . IconContent ( "Favorite Icon" ) . image ) , UI . Styles . Button , GUILayout . Height ( 45f ) , GUILayout . Width ( 240f ) ) )
{
AssetInfo . OpenReviewsPage ( ) ;
}
}
EditorGUILayout . Space ( ) ;
}
EditorGUILayout . Space ( ) ;
using ( new EditorGUILayout . VerticalScope ( ) )
{
UI . DrawH2 ( "Extension assets" ) ;
DrawExtensions ( ) ;
EditorGUILayout . Space ( ) ;
}
EditorGUILayout . Space ( ) ;
using ( new EditorGUILayout . VerticalScope ( ) )
{
#if URP
UI . DrawH2 ( "Quick set up" ) ;
using ( new EditorGUILayout . HorizontalScope ( ) )
{
if ( GUILayout . Button ( new GUIContent ( "<b><size=12> Create water grid</size></b>" , EditorGUIUtility . IconContent ( "Mesh Icon" ) . image ) , UI . Styles . Button , GUILayout . Height ( 45f ) , GUILayout . Width ( 200f ) ) )
{
StylizedWaterEditor . CreateWaterGrid ( ) ;
}
if ( GUILayout . Button ( new GUIContent ( "<b><size=12> Setup planar reflections</size></b>" , EditorGUIUtility . IconContent ( "ReflectionProbe Icon" ) . image ) , UI . Styles . Button , GUILayout . Height ( 45f ) , GUILayout . Width ( 200f ) ) )
{
StylizedWaterEditor . CreatePlanarReflectionRenderer ( ) ;
}
}
GUILayout . Space ( 5f ) ;
EditorGUILayout . LabelField ( "<i>These, and more, options can be found under GameObject->3D Object->Water</i>" , UI . Styles . WordWrapLabel ) ;
#endif
EditorGUILayout . Space ( ) ;
}
}
void DrawInstallation ( )
{
//Testing
//AssetInfo.compatibleVersion = false;
//AssetInfo.alphaVersion = true;
//AssetInfo.IS_UPDATED = false;
using ( new EditorGUILayout . VerticalScope ( ) )
{
EditorGUILayout . Separator ( ) ;
//Version
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Asset version" ) ;
using ( new EditorGUILayout . HorizontalScope ( EditorStyles . textField ) )
{
if ( AssetInfo . IS_UPDATED )
{
GUI . contentColor = UI . GreenColor ;
EditorGUILayout . LabelField ( AssetInfo . INSTALLED_VERSION + " (Latest)" ) ;
GUI . contentColor = defaultColor ;
}
else
{
GUI . contentColor = UI . OrangeColor ;
EditorGUILayout . LabelField ( AssetInfo . INSTALLED_VERSION + " (Outdated)" , EditorStyles . boldLabel ) ;
GUI . contentColor = defaultColor ;
}
}
}
UI . DrawNotification ( ! AssetInfo . IS_UPDATED , "Asset can be updated through the Package Manager. Please update any extensions as well!" , "Open" , ( ) = > AssetInfo . OpenInPackageManager ( ) ) ;
changelog . Draw ( ) ;
//Unity version
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Unity " + AssetInfo . VersionChecking . GetUnityVersion ( ) ) ;
using ( new EditorGUILayout . HorizontalScope ( EditorStyles . textField ) )
{
if ( AssetInfo . compatibleVersion & & ! AssetInfo . alphaVersion )
{
GUI . contentColor = UI . GreenColor ;
EditorGUILayout . LabelField ( "Compatible" ) ;
GUI . contentColor = defaultColor ;
}
else if ( ! AssetInfo . supportedVersion )
{
GUI . contentColor = UI . OrangeColor ;
EditorGUILayout . LabelField ( "Unsupported" ) ;
GUI . contentColor = defaultColor ;
}
if ( AssetInfo . alphaVersion )
{
GUI . contentColor = UI . OrangeColor ;
EditorGUILayout . LabelField ( "Alpha/beta" , EditorStyles . boldLabel ) ;
GUI . contentColor = defaultColor ;
}
}
}
UI . DrawNotification ( AssetInfo . compatibleVersion = = false , "This version of Unity is not compatible." +
"\n\nPlease upgrade to at least Unity " + AssetInfo . MIN_UNITY_VERSION , MessageType . Error ) ;
UI . DrawNotification ( AssetInfo . supportedVersion = = false , "This version of Unity is no longer supported. Any errors or issues will need to be resolved locally." +
"\n\nPlease upgrade to at least Unity " + AssetInfo . MIN_UNITY_VERSION , MessageType . Warning ) ;
UI . DrawNotification ( AssetInfo . alphaVersion , "Only release Unity versions are subject to support and fixes. You may run into issues at own risk." , MessageType . Warning ) ;
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Target graphics API" ) ;
using ( new EditorGUILayout . HorizontalScope ( EditorStyles . textField ) )
{
string prefix = "Compatible" ;
#if ! UNITY_2023_1_OR_NEWER //OpenGLES 2.0 no longer supported at all
if ( PlayerSettings . GetGraphicsAPIs ( EditorUserBuildSettings . activeBuildTarget ) [ 0 ] = = GraphicsDeviceType . OpenGLES2 )
{
GUI . contentColor = UI . RedColor ;
prefix = "Incompatible" ;
}
else
#endif
{
GUI . contentColor = UI . GreenColor ;
}
EditorGUILayout . LabelField ( $"{prefix} ({PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget)[0].ToString()})" ) ;
GUI . contentColor = defaultColor ;
}
}
}
}
void DrawIntegrations ( )
{
UI . DrawH2 ( "Scripting integrations" ) ;
//EditorGUILayout.LabelField("Scripting integrations", UI.Styles.H2);
//EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Dynamic Water Physics 2" ) ;
using ( new EditorGUILayout . HorizontalScope ( EditorStyles . textField ) )
{
if ( StylizedWaterEditor . DWP2Installed ) GUI . contentColor = UI . GreenColor ;
EditorGUILayout . LabelField ( StylizedWaterEditor . DWP2Installed ? "Installed" : "Not Installed" , GUILayout . MaxWidth ( ( 75f ) ) ) ;
GUI . contentColor = defaultColor ;
GUILayout . FlexibleSpace ( ) ;
if ( GUILayout . Button ( UI . Styles . AssetStoreBtnContent ) )
{
AssetInfo . OpenAssetStore ( "https://assetstore.unity.com/packages/slug/147990" ) ;
}
}
}
UI . DrawNotification ( StylizedWaterEditor . DWP2Installed , "Set up water data provider component" , "Execute" , StylizedWaterEditor . SetupForDWP2 ) ;
EditorGUILayout . Space ( ) ;
UI . DrawH2 ( "Shader integrations" ) ;
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Curved World 2020" ) ;
using ( new EditorGUILayout . HorizontalScope ( EditorStyles . textField ) )
{
if ( StylizedWaterEditor . CurvedWorldInstalled ( out var _ ) ) GUI . contentColor = UI . GreenColor ;
EditorGUILayout . LabelField ( StylizedWaterEditor . CurvedWorldInstalled ( out var _ ) ? "Installed" : "Not Installed" , GUILayout . MaxWidth ( ( 75f ) ) ) ;
GUI . contentColor = defaultColor ;
GUILayout . FlexibleSpace ( ) ;
if ( GUILayout . Button ( UI . Styles . AssetStoreBtnContent ) )
{
AssetInfo . OpenAssetStore ( "https://assetstore.unity.com/packages/slug/173251" ) ;
}
}
}
EditorGUILayout . Space ( ) ;
UI . DrawH2 ( "Fog integrations" ) ;
foreach ( ShaderConfigurator . Fog . Integration integration in ShaderConfigurator . Fog . Integrations )
{
if ( integration . asset = = ShaderConfigurator . Fog . Assets . None | | integration . asset = = ShaderConfigurator . Fog . Assets . UnityFog ) continue ;
UI . DrawIntegration ( integration ) ;
EditorGUILayout . Space ( ) ;
if ( underwaterExtensionInstalled & & ( integration . underwaterCompatible = = false ) )
{
UI . DrawNotification ( "Editing of shader files for this asset is required to incorporate support for the Underwater Rendering extension. (See documentation section called \"Transparent Materials\")" , MessageType . Warning ) ;
2023-12-15 06:15:44 +00:00
if ( integration . asset = = ShaderConfigurator . Fog . Assets . COZY ) UI . DrawNotification ( "For COZY version 3.0+, an integration package comes with the asset, which must be unpacked. This contains pre-edited shader files." ) ;
2023-11-13 06:48:15 +00:00
}
}
EditorGUILayout . Space ( ) ;
}
void DrawExtensions ( )
{
using ( new EditorGUILayout . VerticalScope ( ) )
{
UI . DrawExtension ( "Dynamic Effects" ,
"Enables advanced effects to be projected onto the water surface. Such as boat wakes, ripples and shoreline waves." , dynamicEffectsInstalled ,
"https://assetstore.unity.com/packages/slug/257865?aid=1011l7Uk8&pubref=sw2editor" , UI . DynamicEffectsAssetIcon ) ;
EditorGUILayout . Separator ( ) ;
UI . DrawExtension ( "Underwater Rendering" ,
"Extends the Stylized Water 2 shader asset with underwater rendering, by seamlessly blending the water with post processing effects." , underwaterExtensionInstalled ,
"https://assetstore.unity.com/packages/slug/185030?aid=1011l7Uk8&pubref=sw2editor" , UI . UnderwaterAssetIcon ) ;
}
}
void DrawSupport ( )
{
UI . DrawNotification ( AssetInfo . alphaVersion , "You are using an beta/alpha version of Unity. You may run into issues at own risk." , MessageType . Warning ) ;
using ( new EditorGUILayout . VerticalScope ( ) )
{
EditorGUILayout . BeginHorizontal ( ) ;
if ( GUILayout . Button ( "<b><size=12>Documentation</size></b>\n<i>Usage instructions</i>" , UI . Styles . Button ) )
{
Application . OpenURL ( AssetInfo . DOC_URL ) ;
}
if ( GUILayout . Button ( "<b><size=12>FAQ/Troubleshooting</size></b>\n<i>Common issues and solutions</i>" , UI . Styles . Button ) )
{
Application . OpenURL ( AssetInfo . DOC_URL + "?section=troubleshooting-10" ) ;
}
EditorGUILayout . EndHorizontal ( ) ;
}
EditorGUILayout . Space ( ) ;
using ( new EditorGUILayout . VerticalScope ( ) )
{
UI . DrawNotification ( "Be sure to consult the documentation, it already covers many common topics" , MessageType . Info ) ;
EditorGUILayout . Space ( ) ;
//Buttons box
EditorGUILayout . BeginHorizontal ( ) ;
if ( GUILayout . Button ( "<b><size=12>Forum</size></b>\n<i>Join the discussion</i>" , UI . Styles . Button ) )
{
Application . OpenURL ( AssetInfo . FORUM_URL ) ;
}
if ( GUILayout . Button ( "<b><size=12>Email</size></b>\n<i>Contact</i>" , UI . Styles . Button ) )
{
if ( EditorUtility . DisplayDialog ( "Email" , "Please be sure to provide your invoice number, so your license can be verified" , "OK" , "Cancel" ) )
{
Application . OpenURL ( AssetInfo . EMAIL_URL ) ;
}
}
if ( GUILayout . Button ( "<b><size=12>Twitter</size></b>\n<i>Follow developments</i>" , UI . Styles . Button ) )
{
Application . OpenURL ( "https://twitter.com/search?q=staggart%20creations&f=user" ) ;
}
EditorGUILayout . EndHorizontal ( ) ; //Buttons box
}
EditorGUILayout . Space ( ) ;
if ( projectDetails = = null ) projectDetails = GetProjectDetails ( ) ;
2023-12-15 06:15:44 +00:00
using ( new EditorGUILayout . HorizontalScope ( ) )
{
EditorGUILayout . LabelField ( "Project details" , EditorStyles . boldLabel ) ;
if ( GUILayout . Button ( "Refresh" , EditorStyles . miniButton ) )
{
projectDetails = GetProjectDetails ( ) ;
}
}
2023-11-13 06:48:15 +00:00
projectDetailsScrollPos = EditorGUILayout . BeginScrollView ( projectDetailsScrollPos , EditorStyles . helpBox , GUILayout . Height ( 200f ) ) ;
EditorGUILayout . LabelField ( projectDetails , UI . Styles . WordWrapLabel ) ;
EditorGUILayout . EndScrollView ( ) ;
using ( new EditorGUILayout . HorizontalScope ( ) )
{
2023-12-15 06:15:44 +00:00
EditorGUILayout . LabelField ( "Supplying this information is always useful!" , EditorStyles . miniLabel ) ;
2023-11-13 06:48:15 +00:00
if ( GUILayout . Button ( new GUIContent ( " Copy to clipboard" , EditorGUIUtility . IconContent ( "Clipboard" ) . image ) ) )
{
2023-12-15 06:15:44 +00:00
EditorGUIUtility . systemCopyBuffer = projectDetails ;
2023-11-13 06:48:15 +00:00
EditorApplication . Beep ( ) ;
}
}
}
private static string GetProjectDetails ( )
{
StringBuilder stringBuilder = new StringBuilder ( ) ;
2023-12-15 06:15:44 +00:00
stringBuilder . AppendLine ( $"Version: v{AssetInfo.INSTALLED_VERSION}" ) ;
2023-11-13 06:48:15 +00:00
stringBuilder . AppendLine ( $"Install location: {AssetInfo.GetRootFolder()}" ) ;
stringBuilder . AppendLine ( $"Unity version: {AssetInfo.VersionChecking.GetUnityVersion()}" ) ;
UnityEditor . PackageManager . PackageInfo urpPackage = AssetInfo . GetURPPackage ( ) ;
if ( urpPackage ! = null )
{
stringBuilder . AppendLine ( $"URP version: {urpPackage.version}" ) ;
}
else
{
stringBuilder . AppendLine ( $"URP version: NONE" ) ;
}
stringBuilder . AppendLine ( $"" ) ;
BuildTargetGroup buildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget ) ;
stringBuilder . AppendLine ( $"OS: {SystemInfo.operatingSystem}" ) ;
stringBuilder . AppendLine ( $"Platform: {EditorUserBuildSettings.activeBuildTarget}" ) ;
string scriptingBackend = string . Empty ;
#if UNITY_2023_1_OR_NEWER
NamedBuildTarget buildTargetName = NamedBuildTarget . FromBuildTargetGroup ( buildTargetGroup ) ;
scriptingBackend = PlayerSettings . GetDefaultScriptingBackend ( buildTargetName ) . ToString ( ) ;
#else
scriptingBackend = PlayerSettings . GetDefaultScriptingBackend ( buildTargetGroup ) . ToString ( ) ;
#endif
stringBuilder . AppendLine ( $"Scripting backend: {scriptingBackend}" ) ;
stringBuilder . AppendLine ( $"Color space: {PlayerSettings.colorSpace}" ) ;
stringBuilder . AppendLine ( $"Graphics API(s): (Auto:{PlayerSettings.GetUseDefaultGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget)}) {String.Join(" - > ", PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget))}" ) ;
stringBuilder . AppendLine ( $"Tessellation support: {SystemInfo.supportsTessellationShaders}" ) ;
string VRProvider = "" ;
#if XR & & UNITY_2020_3_OR_NEWER
EditorBuildSettings . TryGetConfigObject ( UnityEngine . XR . Management . XRGeneralSettings . k_SettingsKey , out UnityEditor . XR . Management . XRGeneralSettingsPerBuildTarget buildTargetSettings ) ;
2023-12-15 06:15:44 +00:00
if ( buildTargetSettings & & buildTargetSettings . SettingsForBuildTarget ( buildTargetGroup ) )
2023-11-13 06:48:15 +00:00
{
if ( buildTargetSettings . SettingsForBuildTarget ( buildTargetGroup ) . AssignedSettings . activeLoaders . Count > 0 )
{
for ( int i = 0 ; i < buildTargetSettings . SettingsForBuildTarget ( buildTargetGroup ) . AssignedSettings . activeLoaders . Count ; i + + )
{
VRProvider + = $"{buildTargetSettings.SettingsForBuildTarget(buildTargetGroup).AssignedSettings.activeLoaders[i].name} + " ;
}
}
}
#endif
stringBuilder . AppendLine ( $"Active VR plugin(s): {VRProvider}" ) ;
stringBuilder . AppendLine ( $"" ) ;
stringBuilder . AppendLine ( $"First available fog integration: {ShaderConfigurator.Fog.GetFirstInstalled().name}" ) ;
stringBuilder . AppendLine ( $"Underwater Rendering installed: {StylizedWaterEditor.UnderwaterRenderingInstalled()}" ) ;
stringBuilder . AppendLine ( $"Dynamic Effects installed: {StylizedWaterEditor.DynamicEffectsInstalled()}" ) ;
2023-12-15 06:15:44 +00:00
#if URP
stringBuilder . AppendLine ( $"Render feature present: {(StylizedWaterRenderFeature.GetDefault() ? " True " : " False ")}" ) ;
#endif
2023-11-13 06:48:15 +00:00
#if URP
stringBuilder . AppendLine ( $"" ) ;
stringBuilder . AppendLine ( $"Depth texture option disabled (anywhere): {PipelineUtilities.IsDepthTextureOptionDisabledAnywhere()}" ) ;
stringBuilder . AppendLine ( $"Opaque texture option disabled (anywhere): {PipelineUtilities.IsOpaqueTextureOptionDisabledAnywhere()}" ) ;
#endif
stringBuilder . AppendLine ( $"" ) ;
stringBuilder . AppendLine ( $"Async shader compilation: {EditorSettings.asyncShaderCompilation}" ) ;
#if UNITY_2020_3_OR_NEWER
stringBuilder . AppendLine ( $"Caching Shader Preprocessor: {EditorSettings.cachingShaderPreprocessor}" ) ;
#endif
#if UNITY_2022_2_OR_NEWER
stringBuilder . AppendLine ( $"Strict shader variant matching: {PlayerSettings.strictShaderVariantMatching}" ) ;
#endif
2023-12-15 06:15:44 +00:00
stringBuilder . AppendLine ( $"" ) ;
string defaultShaderPath = AssetDatabase . GUIDToAssetPath ( "d7b0192b9bf19c949900035fa781fdc4" ) ;
Shader defaultShader = AssetDatabase . LoadAssetAtPath < Shader > ( defaultShaderPath ) ;
ShaderMessage [ ] shaderMessages = ShaderConfigurator . GetErrorMessages ( defaultShader ) ;
stringBuilder . AppendLine ( $"Shader compile errors ({shaderMessages?.Length ?? 0}):" ) ;
if ( shaderMessages ! = null )
{
foreach ( var t in shaderMessages )
{
stringBuilder . AppendLine ( $"• {t.message} {t.file}:{t.line} ({t.platform})" ) ;
}
}
2023-11-13 06:48:15 +00:00
2023-12-15 06:15:44 +00:00
return stringBuilder . ToString ( ) ;
2023-11-13 06:48:15 +00:00
}
private class Changelog
{
private GUIStyle changelogStyle ;
private string changelogContent ;
private Vector2 scrollPos ;
public float maxHeight = 300f ;
public Changelog ( )
{
string changelogPath = AssetDatabase . GUIDToAssetPath ( "f07fbdad38458814a87e9b627e287ccb" ) ;
TextAsset textAsset = ( ( TextAsset ) AssetDatabase . LoadAssetAtPath ( changelogPath , typeof ( TextAsset ) ) ) ;
if ( textAsset = = null ) return ;
changelogContent = textAsset . text ;
//Format version header
changelogContent = Regex . Replace ( changelogContent , @"^[0-9].*" , "<size=18><b>Version $0</b></size>" , RegexOptions . Multiline ) ;
//Format headers
changelogContent = Regex . Replace ( changelogContent , @"(\w*Added:|Changed:|Fixed:\w*)" , "<size=14><b>$0</b></size>" , RegexOptions . Multiline ) ;
//Indent items with dashes
changelogContent = Regex . Replace ( changelogContent , @"^-.*" , " $0" , RegexOptions . Multiline ) ;
changelogStyle = new GUIStyle ( GUI . skin . label ) ;
changelogStyle . fontSize = 12 ;
changelogStyle . richText = true ;
changelogStyle . wordWrap = true ;
}
public void Draw ( )
{
if ( changelogContent = = null )
{
UI . DrawNotification ( "Changelog text file could not be found. It probably wasn't imported from the asset store..." , MessageType . Error ) ;
return ;
}
scrollPos = GUILayout . BeginScrollView ( scrollPos , EditorStyles . textArea , GUILayout . MaxHeight ( maxHeight ) ) ;
GUILayout . TextArea ( changelogContent , changelogStyle ) ;
GUILayout . EndScrollView ( ) ;
}
}
}
}