1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public class Preferences
{
public enum ShowOption
{
Always = 0,
OnNewVersion = 1,
Never = 2
}
private static readonly GUIContent StartUp = new GUIContent( "Show start screen on Unity launch", "You can set if you want to see the start screen everytime Unity launchs, only just when there's a new version available or never." );
public static readonly string PrefStartUp = "ASELastSession" + Application.productName;
public static ShowOption GlobalStartUp = ShowOption.Always;
private static readonly GUIContent AutoSRP = new GUIContent( "Auto import SRP shader templates", "By default Amplify Shader Editor checks for your SRP version and automatically imports the correct corresponding shader templates.\nTurn this OFF if you prefer to import them manually." );
public static readonly string PrefAutoSRP = "ASEAutoSRP" + Application.productName;
public static bool GlobalAutoSRP = true;
private static readonly GUIContent UseMacros = new GUIContent( "Use Unity's sampling macros in SRP", "Setting this ON will force the code generation to use Unity's macros when sampling textures in SRP.\nThis macros ensures better compatibility between platforms but makes the code less readable." );
public static readonly string PrefUseMacros = "ASEUseMacros" + Application.productName;
public static bool GlobalUseMacros = false;
private static readonly GUIContent DefineSymbol = new GUIContent( "Add Amplify Shader Editor define symbol", "Turning it OFF will disable the automatic insertion of the define symbol and remove it from the list while turning it ON will do the opposite.\nThis is used for compatibility with other plugins, if you are not sure if you need this leave it ON." );
public static readonly string PrefDefineSymbol = "ASEDefineSymbol" + Application.productName;
public static bool GlobalDefineSymbol = true;
private static bool PrefsLoaded = false;
#if UNITY_2019_1_OR_NEWER
[SettingsProvider]
public static SettingsProvider ImpostorsSettings()
{
var provider = new SettingsProvider( "Preferences/Amplify Shader Editor", SettingsScope.User )
{
guiHandler = ( string searchContext ) =>
{
PreferencesGUI();
},
keywords = new HashSet<string>( new[] { "start", "screen", "import", "shader", "templates", "macros", "macros", "define", "symbol" } ),
};
return provider;
}
#else
[PreferenceItem( "Amplify Shader Editor" )]
#endif
public static void PreferencesGUI()
{
if( !PrefsLoaded )
{
LoadDefaults();
PrefsLoaded = true;
}
var cache = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 250;
EditorGUI.BeginChangeCheck();
GlobalStartUp = (ShowOption) EditorGUILayout.EnumPopup( StartUp, GlobalStartUp );
if( EditorGUI.EndChangeCheck() )
{
EditorPrefs.SetInt( PrefStartUp, (int)GlobalStartUp );
}
EditorGUI.BeginChangeCheck();
GlobalAutoSRP = EditorGUILayout.Toggle( AutoSRP, GlobalAutoSRP );
if( EditorGUI.EndChangeCheck() )
{
EditorPrefs.SetBool( PrefAutoSRP, GlobalAutoSRP );
}
EditorGUI.BeginChangeCheck();
GlobalUseMacros = EditorGUILayout.Toggle( UseMacros, GlobalUseMacros );
if( EditorGUI.EndChangeCheck() )
{
EditorPrefs.SetBool( PrefUseMacros, GlobalUseMacros );
if( UIUtils.CurrentWindow != null )
{
UIUtils.CurrentWindow.CurrentGraph.SamplingThroughMacros = GlobalUseMacros;
}
}
EditorGUI.BeginChangeCheck();
GlobalDefineSymbol = EditorGUILayout.Toggle( DefineSymbol, GlobalDefineSymbol );
if( EditorGUI.EndChangeCheck() )
{
EditorPrefs.SetBool( PrefDefineSymbol, GlobalDefineSymbol );
if( GlobalDefineSymbol )
IOUtils.SetAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
else
IOUtils.RemoveAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
}
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if( GUILayout.Button( "Reset and Forget All" ) )
{
EditorPrefs.DeleteKey( PrefStartUp );
GlobalStartUp = ShowOption.Always;
EditorPrefs.DeleteKey( PrefAutoSRP );
GlobalAutoSRP = true;
EditorPrefs.DeleteKey( PrefUseMacros );
GlobalUseMacros = false;
if( UIUtils.CurrentWindow != null )
{
UIUtils.CurrentWindow.CurrentGraph.SamplingThroughMacros = false;
}
EditorPrefs.DeleteKey( PrefDefineSymbol );
GlobalDefineSymbol = true;
IOUtils.SetAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
}
EditorGUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = cache;
}
public static void LoadDefaults()
{
GlobalStartUp = (ShowOption) EditorPrefs.GetInt( PrefStartUp, 0 );
GlobalAutoSRP = EditorPrefs.GetBool( PrefAutoSRP, true );
GlobalUseMacros = EditorPrefs.GetBool( PrefUseMacros, false );
GlobalDefineSymbol = EditorPrefs.GetBool( PrefDefineSymbol, true );
}
}
}
|