[Add] All in one shader
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn13DShaderWindow : EditorWindow
|
||||
{
|
||||
private static AllIn13DShaderWindow instance;
|
||||
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
private AssetWindowTabDrawer currentTabDrawer;
|
||||
|
||||
private int currTab = 0;
|
||||
private string[] tabsNames;
|
||||
private AssetWindowTabDrawer[] tabDrawers;
|
||||
|
||||
private CommonStyles commonStyles;
|
||||
private GlobalConfiguration globalConfiguration;
|
||||
|
||||
private Texture imageInspector;
|
||||
|
||||
private SavePathsTabDrawer savePathsTabDrawer;
|
||||
private TextureEditorTabDrawer textureEditorTabDrawer;
|
||||
private TextureCreatorTabDrawer textureCreatorTabDrawer;
|
||||
|
||||
private OverrideMaterialsTabDrawer overrideMaterialsTabDrawer;
|
||||
private OtherTabDrawer otherTabDrawer;
|
||||
private EffectsProfileTabDrawer effectsProfileTabDrawer;
|
||||
private URPSettingsDrawer urpSettingsDrawer;
|
||||
|
||||
|
||||
private bool initialized;
|
||||
|
||||
|
||||
[MenuItem("Tools/AllIn1/3DShaderWindow")]
|
||||
public static void ShowAllIn13DShaderWindow()
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
instance = GetWindow<AllIn13DShaderWindow>("All In 1 3DShader Window");
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
commonStyles = new CommonStyles();
|
||||
globalConfiguration = EditorUtils.FindAssetByName<GlobalConfiguration>("GlobalConfiguration");
|
||||
|
||||
PropertiesConfigCollection propertiesConfigCollection = EditorUtils.FindAsset<ScriptableObject>("PropertiesConfigCollection") as PropertiesConfigCollection;
|
||||
|
||||
scrollPosition = Vector2.zero;
|
||||
|
||||
savePathsTabDrawer = new SavePathsTabDrawer(commonStyles, this);
|
||||
textureEditorTabDrawer = new TextureEditorTabDrawer(commonStyles, this);
|
||||
textureCreatorTabDrawer = new TextureCreatorTabDrawer(commonStyles, this);
|
||||
overrideMaterialsTabDrawer = new OverrideMaterialsTabDrawer(commonStyles, this);
|
||||
otherTabDrawer = new OtherTabDrawer(globalConfiguration, commonStyles, this);
|
||||
effectsProfileTabDrawer = new EffectsProfileTabDrawer(propertiesConfigCollection.propertiesConfig, globalConfiguration, commonStyles, this);
|
||||
urpSettingsDrawer = new URPSettingsDrawer(commonStyles, this);
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
tabDrawers = new AssetWindowTabDrawer[]
|
||||
{
|
||||
savePathsTabDrawer,
|
||||
textureEditorTabDrawer,
|
||||
textureCreatorTabDrawer,
|
||||
overrideMaterialsTabDrawer,
|
||||
effectsProfileTabDrawer,
|
||||
urpSettingsDrawer,
|
||||
otherTabDrawer
|
||||
};
|
||||
|
||||
#else
|
||||
tabDrawers = new AssetWindowTabDrawer[]
|
||||
{
|
||||
savePathsTabDrawer,
|
||||
textureEditorTabDrawer,
|
||||
textureCreatorTabDrawer,
|
||||
overrideMaterialsTabDrawer,
|
||||
effectsProfileTabDrawer,
|
||||
otherTabDrawer
|
||||
};
|
||||
#endif
|
||||
|
||||
tabsNames = new string[tabDrawers.Length];
|
||||
for(int i = 0; i < tabsNames.Length; i++)
|
||||
{
|
||||
tabsNames[i] = tabDrawers[i].GetTabName();
|
||||
}
|
||||
|
||||
if (imageInspector == null)
|
||||
{
|
||||
imageInspector = AllIn13DShaderConfig.GetInspectorImage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
currentTabDrawer = savePathsTabDrawer;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Init();
|
||||
|
||||
EditorApplication.playModeStateChanged += PlayModeStateChanged;
|
||||
currentTabDrawer.OnEnable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EditorApplication.playModeStateChanged -= PlayModeStateChanged;
|
||||
currentTabDrawer.OnDisable();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
WindowClosed();
|
||||
}
|
||||
|
||||
private void WindowClosed()
|
||||
{
|
||||
overrideMaterialsTabDrawer.Close();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
commonStyles.InitStyles();
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
bool urpCorrectlyConfigured = URPConfigurator.IsURPCorrectlyConfigured();
|
||||
if (!urpCorrectlyConfigured)
|
||||
{
|
||||
Draw_URPError();
|
||||
}
|
||||
else
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
#else
|
||||
Draw();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
DrawEditor();
|
||||
}
|
||||
|
||||
private void DrawEditor()
|
||||
{
|
||||
using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height)))
|
||||
{
|
||||
scrollPosition = scrollView.scrollPosition;
|
||||
|
||||
if (imageInspector)
|
||||
{
|
||||
Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(50));
|
||||
GUI.DrawTexture(rect, imageInspector, ScaleMode.ScaleToFit, true);
|
||||
}
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
DrawPlayMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
int newTab = GUILayout.Toolbar(currTab, tabsNames);
|
||||
AssetWindowTabDrawer newTabDrawer = tabDrawers[newTab];
|
||||
|
||||
if (newTabDrawer != currentTabDrawer)
|
||||
{
|
||||
currentTabDrawer.Hide();
|
||||
newTabDrawer.Show();
|
||||
|
||||
this.currTab = newTab;
|
||||
this.currentTabDrawer = newTabDrawer;
|
||||
}
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
currentTabDrawer.Draw();
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorUtils.DrawThinLine();
|
||||
GUILayout.Label("Current asset version is " + Constants.VERSION, EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPlayMode()
|
||||
{
|
||||
GUILayout.Label("Not available during play mode", commonStyles.bigLabel);
|
||||
}
|
||||
|
||||
private void Draw_URPError()
|
||||
{
|
||||
EditorGUILayout.LabelField(CommonMessages.URP_PIPELINE_NOT_ASSIGNED, commonStyles.warningLabel);
|
||||
EditorUtils.DrawButtonLink(CommonMessages.URP_PIPELINE_NOT_ASSIGNED_DOC_LINK);
|
||||
}
|
||||
|
||||
private void PlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
if(state == PlayModeStateChange.ExitingEditMode)
|
||||
{
|
||||
currentTabDrawer.ExitingEditMode();
|
||||
}
|
||||
else if(state == PlayModeStateChange.EnteredPlayMode)
|
||||
{
|
||||
currentTabDrawer.EnteredPlayMode();
|
||||
Repaint();
|
||||
}
|
||||
else if(state == PlayModeStateChange.ExitingPlayMode)
|
||||
{
|
||||
Init();
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AllAssetProcessed()
|
||||
{
|
||||
CheckURPCorrectlyConfigured();
|
||||
}
|
||||
|
||||
private static void CheckURPCorrectlyConfigured()
|
||||
{
|
||||
#if ALLIN13DSHADER_URP
|
||||
if (!URPConfigurator.IsURPCorrectlyConfigured())
|
||||
{
|
||||
ShowAllIn13DShaderWindow();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51e8848e3c58c334eacf2c12d0e69b68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/AllIn13DShaderWindow.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public abstract class AssetWindowTabDrawer
|
||||
{
|
||||
protected CommonStyles commonStyles;
|
||||
protected AllIn13DShaderWindow parentWindow;
|
||||
|
||||
public AssetWindowTabDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow)
|
||||
{
|
||||
this.commonStyles = commonStyles;
|
||||
this.parentWindow = parentWindow;
|
||||
}
|
||||
|
||||
public abstract void Hide();
|
||||
|
||||
public abstract void Show();
|
||||
|
||||
public abstract void OnDisable();
|
||||
|
||||
public abstract void OnEnable();
|
||||
|
||||
public abstract void Draw();
|
||||
|
||||
public abstract void EnteredPlayMode();
|
||||
|
||||
public virtual void ExitingEditMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract string GetTabName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00d52e9709d8b1b439bae51fe4b61969
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/AssetWindowTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,151 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class EffectsProfileTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Active Effects List";
|
||||
|
||||
private EffectsProfileCollection effectsProfileCollection;
|
||||
private EffectsProfile effectsProfile;
|
||||
private PropertiesConfig propertiesConfig;
|
||||
|
||||
public EffectsProfileTabDrawer(PropertiesConfig propertiesConfig, GlobalConfiguration globalConfiguration, CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
this.propertiesConfig = propertiesConfig;
|
||||
this.effectsProfileCollection = globalConfiguration.effectsProfileCollection;
|
||||
this.effectsProfile = effectsProfileCollection.generalProfile;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if(GUILayout.Button("Enable All"))
|
||||
{
|
||||
EnableAll();
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Disable All"))
|
||||
{
|
||||
DisableAll();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
for(int i = 0; i < effectsProfile.groups.Count; i++)
|
||||
{
|
||||
DrawGroup(effectsProfile.groups[i]);
|
||||
}
|
||||
bool hasChanges = EditorGUI.EndChangeCheck();
|
||||
if (hasChanges)
|
||||
{
|
||||
EditorUtility.SetDirty(effectsProfileCollection);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Configure"))
|
||||
{
|
||||
Configure();
|
||||
}
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Configure()
|
||||
{
|
||||
ShaderFeaturesFileCreator.CreateFile(effectsProfile);
|
||||
}
|
||||
|
||||
private void DrawGroup(EffectsProfileGroup effectsProfileGroup)
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Label(effectsProfileGroup.effectGroupConfig.displayName, commonStyles.bigLabel);
|
||||
|
||||
for(int i = 0; i < effectsProfileGroup.entries.Count; i++)
|
||||
{
|
||||
DrawEntry(effectsProfileGroup.entries[i]);
|
||||
}
|
||||
|
||||
GUILayout.Space(15f);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawEntry(EffectsProfileEntry entry)
|
||||
{
|
||||
string label = $"{entry.GetDisplayIndex()}. {entry.displayName}";
|
||||
|
||||
AllIn13DEffectConfig effectConfig = propertiesConfig.FindEffectConfigByID(entry.effectID);
|
||||
entry.BindEffectConfig(effectConfig);
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
entry.isEnabled = GUILayout.Toggle(entry.isEnabled, string.Empty, GUILayout.Width(15));
|
||||
GUILayout.Label(label, GUILayout.Width(200f));
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawSubKeywordToggle(SubkeywordEntryToggle subkeywordEntryToggle)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(commonStyles.shaderPropertiesStyle);
|
||||
|
||||
subkeywordEntryToggle.isEnabled = GUILayout.Toggle(subkeywordEntryToggle.isEnabled, string.Empty, GUILayout.Width(15));
|
||||
GUILayout.Label(subkeywordEntryToggle.displayName, GUILayout.Width(200f));
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawSubKeywordEnum(SubkeywordEntryEnum subkeywordEntryEnum)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(commonStyles.shaderPropertiesStyle);
|
||||
|
||||
subkeywordEntryEnum.kwIndexEnabled = EditorGUILayout.Popup(subkeywordEntryEnum.kwIndexEnabled, subkeywordEntryEnum.displayNames);
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void EnableAll()
|
||||
{
|
||||
effectsProfile.EnableAllEffects();
|
||||
EditorUtility.SetDirty(effectsProfileCollection);
|
||||
}
|
||||
|
||||
private void DisableAll()
|
||||
{
|
||||
effectsProfile.DisableAllEffects();
|
||||
EditorUtility.SetDirty(effectsProfileCollection);
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc7d46d942abc6d4693c2383e2ae5fe2
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/EffectsProfileTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,101 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class OtherTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Other";
|
||||
|
||||
private GlobalConfiguration globalConfiguration;
|
||||
|
||||
public OtherTabDrawer(GlobalConfiguration globalConfiguration, CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
this.globalConfiguration = globalConfiguration;
|
||||
|
||||
if (globalConfiguration.defaultPreset == null)
|
||||
{
|
||||
globalConfiguration.projectType = GlobalConfiguration.ProjectType.STANDARD_BASIC;
|
||||
globalConfiguration.RefreshDefaultMaterial();
|
||||
globalConfiguration.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
GUILayout.Label("Default Materials", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
globalConfiguration.projectType = (GlobalConfiguration.ProjectType)EditorGUILayout.EnumPopup("Project Type", globalConfiguration.projectType);
|
||||
bool projectTypeChanged = EditorGUI.EndChangeCheck();
|
||||
|
||||
bool disabled = globalConfiguration.projectType != GlobalConfiguration.ProjectType.CUSTOM;
|
||||
EditorGUI.BeginDisabledGroup(disabled);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
globalConfiguration.defaultPreset = (Material)EditorGUILayout.ObjectField("Default Material", globalConfiguration.defaultPreset, typeof(Material), false);
|
||||
bool defaultPresetChanged = EditorGUI.EndChangeCheck();
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (projectTypeChanged)
|
||||
{
|
||||
globalConfiguration.RefreshDefaultMaterial();
|
||||
}
|
||||
|
||||
if(projectTypeChanged || defaultPresetChanged)
|
||||
{
|
||||
globalConfiguration.Save();
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorUtils.DrawThinLine();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Refresh the Material Inspector Properties Configuration"))
|
||||
{
|
||||
ShadersCreatorTool.BuildShaderFiles();
|
||||
PropertiesConfigCollection propertiesConfigCollection = PropertiesConfigCreator.CreateConfig();
|
||||
|
||||
EffectsProfileCollection effectsProfileCollection = EffectsProfileCollection.CreateAsset(propertiesConfigCollection);
|
||||
if (AssetDatabase.IsValidFolder(Constants.DEMO_SHADERS_BAKED_FOLDER_PATH))
|
||||
{
|
||||
effectsProfileCollection.CheckBakedShadersFolder(Constants.DEMO_SHADERS_BAKED_FOLDER_PATH, propertiesConfigCollection.propertiesConfig);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("The asset uses auto generated cached data to display the properties of the Material inspector\nYou should never need this button", commonStyles.wordWrappedStyle);
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 305faffa5984380458d6390103d1a838
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/OtherTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,489 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class OverrideMaterialsTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Override Materials";
|
||||
|
||||
private enum State
|
||||
{
|
||||
NONE = 0,
|
||||
PREVIEW = 1,
|
||||
}
|
||||
|
||||
private PropertySelectorAuxWindow propertySelectorWindow;
|
||||
|
||||
private State state;
|
||||
|
||||
private static MaterialOverrideData overrideData;
|
||||
private SerializedObject dataSO;
|
||||
private SerializedProperty spFolders;
|
||||
|
||||
private GUIStyle propertiesStyle;
|
||||
|
||||
public OverrideMaterialsTabDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
overrideData = ScriptableObject.CreateInstance<MaterialOverrideData>();
|
||||
overrideData.Initialize();
|
||||
|
||||
state = State.NONE;
|
||||
|
||||
dataSO = new SerializedObject(overrideData);
|
||||
spFolders = dataSO.FindProperty("folders");
|
||||
}
|
||||
|
||||
private void SubscribeEvents()
|
||||
{
|
||||
EditorApplication.wantsToQuit += OnWantsToQuit;
|
||||
EditorSceneManager.sceneClosing += OnSceneClosing;
|
||||
EditorSceneManager.sceneSaving += OnSceneSaving;
|
||||
EditorSceneManager.sceneSaved += OnSceneSaved;
|
||||
EditorSceneManager.sceneDirtied += OnSceneDirtied;
|
||||
|
||||
EditorApplication.hierarchyChanged += OnHierarchyChanged;
|
||||
|
||||
AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload;
|
||||
|
||||
}
|
||||
|
||||
private void UnsubscribeEvents()
|
||||
{
|
||||
EditorApplication.wantsToQuit -= OnWantsToQuit;
|
||||
EditorSceneManager.sceneClosing -= OnSceneClosing;
|
||||
EditorSceneManager.sceneSaving -= OnSceneSaving;
|
||||
EditorSceneManager.sceneSaved -= OnSceneSaved;
|
||||
EditorSceneManager.sceneDirtied -= OnSceneDirtied;
|
||||
|
||||
EditorApplication.hierarchyChanged -= OnHierarchyChanged;
|
||||
|
||||
AssemblyReloadEvents.beforeAssemblyReload -= BeforeAssemblyReload;
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
SubscribeEvents();
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
UnsubscribeEvents();
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
Initialize();
|
||||
SubscribeEvents();
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
UnsubscribeEvents();
|
||||
Close();
|
||||
}
|
||||
|
||||
//public void Setup(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow)
|
||||
//{
|
||||
// this.commonStyles = commonStyles;
|
||||
// this.parentWindow = parentWindow;
|
||||
//}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExitingEditMode()
|
||||
{
|
||||
EndOverrideProcess(false);
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
UnsubscribeEvents();
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
if(propertiesStyle == null)
|
||||
{
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
dataSO.Update();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
if (state == State.NONE)
|
||||
{
|
||||
DrawStateNone();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawStatePreview();
|
||||
}
|
||||
|
||||
dataSO.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void StartOverrideProcess()
|
||||
{
|
||||
overrideData.ResetData();
|
||||
overrideData.CreateRendererOverride();
|
||||
|
||||
overrideData.ShowPreviewChanges();
|
||||
|
||||
state = State.PREVIEW;
|
||||
}
|
||||
|
||||
private void EndOverrideProcess(bool applyChanges)
|
||||
{
|
||||
if (applyChanges)
|
||||
{
|
||||
List<Material> affectedMaterials = overrideData.CollectAffectedMaterials();
|
||||
|
||||
string title = "Overriding AllIn13D materials";
|
||||
string message = $"You are about to override {affectedMaterials.Count} materials";
|
||||
string okButton = "Override";
|
||||
string cancelButton = "Cancel";
|
||||
|
||||
bool isOk = EditorUtility.DisplayDialog(title, message, okButton, cancelButton);
|
||||
|
||||
if (isOk)
|
||||
{
|
||||
overrideData.ApplyChangesToMaterials(affectedMaterials);
|
||||
overrideData.EndOverrideProcess();
|
||||
|
||||
if(overrideData.applyTarget == MaterialOverrideData.ApplyTarget.CURRENT_SCENE)
|
||||
{
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
state = State.NONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
overrideData.EndOverrideProcess();
|
||||
state = State.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawStateNone()
|
||||
{
|
||||
if (GUILayout.Button("Start"))
|
||||
{
|
||||
StartOverrideProcess();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawStatePreview()
|
||||
{
|
||||
overrideData.applyTarget = (MaterialOverrideData.ApplyTarget)EditorGUILayout.EnumPopup("Apply Target", overrideData.applyTarget);
|
||||
if(overrideData.applyTarget == MaterialOverrideData.ApplyTarget.SELECTED_FOLDERS)
|
||||
{
|
||||
EditorGUILayout.PropertyField(spFolders);
|
||||
}
|
||||
|
||||
GUILayout.Space(20f);
|
||||
|
||||
if (GUILayout.Button("+"))
|
||||
{
|
||||
propertySelectorWindow = PropertySelectorAuxWindow.GetWindow<PropertySelectorAuxWindow>(title: "Select Property", utility: true);
|
||||
propertySelectorWindow.Setup(PropertyAddedCallback);
|
||||
}
|
||||
|
||||
GUILayout.Space(20f);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
for(int i = 0; i < overrideData.generalPropertiesOverrides.Count; i++)
|
||||
{
|
||||
DrawOverriddenEffectProperty(overrideData.generalPropertiesOverrides[i]);
|
||||
}
|
||||
|
||||
if (!overrideData.IsEmpty())
|
||||
{
|
||||
GUILayout.Space(10f);
|
||||
}
|
||||
|
||||
for (int i = 0; i < overrideData.effectOverrides.Count; i++)
|
||||
{
|
||||
DrawEffectOverride(overrideData.effectOverrides[i]);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
overrideData.ShowPreviewChanges();
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!overrideData.IsApplyEnabled() || overrideData.IsEmpty());
|
||||
if (GUILayout.Button("Apply"))
|
||||
{
|
||||
EndOverrideProcess(applyChanges: true);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (GUILayout.Button("Cancel"))
|
||||
{
|
||||
EndOverrideProcess(applyChanges: false);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawEffectOverride(AbstractEffectOverride effectOverride)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
float lastLabelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 150f;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
effectOverride.overrideEnabled = EditorGUILayout.Toggle($"{effectOverride.displayName} Override", effectOverride.overrideEnabled);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
overrideData.RebuildPreviewMaterial();
|
||||
}
|
||||
EditorGUIUtility.labelWidth = lastLabelWidth;
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!effectOverride.overrideEnabled);
|
||||
if (effectOverride is EffectToggleOverride)
|
||||
{
|
||||
EffectToggleOverride effectToggleOverride = (EffectToggleOverride)effectOverride;
|
||||
effectToggleOverride.boolValue = EditorGUILayout.Toggle("On/Off", effectToggleOverride.boolValue);
|
||||
}
|
||||
else if(effectOverride is EffectEnumOverride)
|
||||
{
|
||||
EffectEnumOverride effectEnumOverride = (EffectEnumOverride)effectOverride;
|
||||
effectEnumOverride.index = EditorGUILayout.Popup("Value", effectEnumOverride.index, effectEnumOverride.enumOptions);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (GUILayout.Button("-", GUILayout.Width(50f)))
|
||||
{
|
||||
overrideData.RemoveEffectOverride(effectOverride);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
DrawEffectOverrideProperties(effectOverride);
|
||||
}
|
||||
|
||||
private void DrawEffectOverrideProperties(AbstractEffectOverride effectOverride)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(propertiesStyle);
|
||||
for (int i = 0; i < effectOverride.propertyOverrides.Count; i++)
|
||||
{
|
||||
DrawOverriddenEffectProperty(effectOverride.propertyOverrides[i]);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawOverriddenEffectProperty(PropertyOverride propertyOverride)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (propertyOverride.propertyOverrideType == PropertyOverrideType.ENUM)
|
||||
{
|
||||
propertyOverride.floatValue = EditorGUILayout.Popup(propertyOverride.displayName, (int)propertyOverride.floatValue, propertyOverride.keywords);
|
||||
}
|
||||
else if (propertyOverride.propertyOverrideType == PropertyOverrideType.TOGGLE)
|
||||
{
|
||||
bool toggleBool = ((int)propertyOverride.floatValue) == 1f;
|
||||
toggleBool = EditorGUILayout.Toggle(propertyOverride.displayName, toggleBool);
|
||||
|
||||
float toggleFloat = toggleBool ? 1f : 0f;
|
||||
propertyOverride.floatValue = toggleFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (propertyOverride.shaderPropertyType)
|
||||
{
|
||||
case ShaderPropertyType.Float:
|
||||
propertyOverride.floatValue = EditorGUILayout.FloatField(propertyOverride.displayName, propertyOverride.floatValue);
|
||||
break;
|
||||
case ShaderPropertyType.Range:
|
||||
propertyOverride.floatValue = EditorGUILayout.Slider(propertyOverride.displayName, propertyOverride.floatValue, propertyOverride.rangeLimits.x, propertyOverride.rangeLimits.y);
|
||||
break;
|
||||
case ShaderPropertyType.Int:
|
||||
propertyOverride.intValue = EditorGUILayout.IntField(propertyOverride.displayName, propertyOverride.intValue);
|
||||
break;
|
||||
case ShaderPropertyType.Color:
|
||||
GUIContent guiContent = new GUIContent(propertyOverride.displayName);
|
||||
propertyOverride.colorValue = EditorGUILayout.ColorField(guiContent, propertyOverride.colorValue, true, true, propertyOverride.isHDR);
|
||||
break;
|
||||
case ShaderPropertyType.Texture:
|
||||
EditorGUILayout.BeginVertical();
|
||||
propertyOverride.texValue = (Texture)EditorGUILayout.ObjectField(propertyOverride.displayName, propertyOverride.texValue, typeof(Texture), false);
|
||||
|
||||
float lastLabelWidth = EditorGUIUtility.labelWidth;
|
||||
if (propertyOverride.hasTilingAndOffset)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
Vector2 tiling = new Vector2(propertyOverride.tilingAndOffset.x, propertyOverride.tilingAndOffset.y);
|
||||
EditorGUILayout.LabelField("Tiling", GUILayout.Width(50));
|
||||
tiling = EditorGUILayout.Vector2Field(string.Empty, tiling, GUILayout.Width(400));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
Vector2 offset = new Vector2(propertyOverride.tilingAndOffset.z, propertyOverride.tilingAndOffset.w);
|
||||
EditorGUILayout.LabelField("Offset", GUILayout.Width(50));
|
||||
offset = EditorGUILayout.Vector2Field(string.Empty, offset, GUILayout.Width(400));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
propertyOverride.tilingAndOffset = new Vector4(tiling.x, tiling.y, offset.x, offset.y);
|
||||
}
|
||||
EditorGUIUtility.labelWidth = lastLabelWidth;
|
||||
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
break;
|
||||
case ShaderPropertyType.Vector:
|
||||
propertyOverride.vectorValue = EditorGUILayout.Vector4Field(propertyOverride.displayName, propertyOverride.vectorValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("-", GUILayout.Width(50f)))
|
||||
{
|
||||
overrideData.RemovePropertyOverride(propertyOverride);
|
||||
overrideData.RebuildPreviewMaterial();
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void PropertyAddedCallback(AllIn13DEffectConfig effectConfig, int propertyIndex, Shader shader,
|
||||
PropertySelectorAuxWindow.TypeOfPropertyAdded typeOfPropertyAdded)
|
||||
{
|
||||
if(typeOfPropertyAdded == PropertySelectorAuxWindow.TypeOfPropertyAdded.EFFECT_MAIN)
|
||||
{
|
||||
overrideData.AddCopmleteEffectOverride(effectConfig, shader);
|
||||
}
|
||||
else if(typeOfPropertyAdded == PropertySelectorAuxWindow.TypeOfPropertyAdded.GLOBAL_PROPERTY || typeOfPropertyAdded == PropertySelectorAuxWindow.TypeOfPropertyAdded.ADVANCED_PROPERTY)
|
||||
{
|
||||
overrideData.AddGeneralPropertyOverride(propertyIndex, shader);
|
||||
}
|
||||
//else if(typeOfPropertyAdded == PropertySelectorAuxWindow.TypeOfPropertyAdded.EFFECT_MAIN)
|
||||
//{
|
||||
// overrideData.AddEffectOverride(effectConfig);
|
||||
//}
|
||||
|
||||
overrideData.ShowPreviewChanges();
|
||||
parentWindow.Repaint();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
EndOverrideProcess(applyChanges: false);
|
||||
//EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
//AssetDatabase.SaveAssets();
|
||||
|
||||
if (propertySelectorWindow != null)
|
||||
{
|
||||
propertySelectorWindow.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneClosing(Scene scene, bool removingScene)
|
||||
{
|
||||
Close();
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(scene);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void OnSceneSaving(Scene scene, string path)
|
||||
{
|
||||
overrideData.UseMaterialSource();
|
||||
EditorSceneManager.MarkSceneDirty(scene);
|
||||
}
|
||||
|
||||
private void OnSceneSaved(Scene scene)
|
||||
{
|
||||
if(state == State.PREVIEW)
|
||||
{
|
||||
overrideData.UsePreviewMaterials();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneDirtied(Scene scene)
|
||||
{
|
||||
if(state == State.PREVIEW && Event.current != null)
|
||||
{
|
||||
bool deletingObject = false;
|
||||
if(Event.current.commandName == "Delete" || Event.current.commandName == "SoftDelete")
|
||||
{
|
||||
deletingObject = true;
|
||||
}
|
||||
|
||||
if (deletingObject)
|
||||
{
|
||||
Transform[] transformsSelected = Selection.transforms;
|
||||
for (int i = 0; i < transformsSelected.Length; i++)
|
||||
{
|
||||
Renderer[] renderers = transformsSelected[i].GetComponentsInChildren<Renderer>();
|
||||
bool changesDiscarded = overrideData.DiscardChanges(renderers);
|
||||
|
||||
if (changesDiscarded)
|
||||
{
|
||||
EditorSceneManager.MarkSceneDirty(scene);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnWantsToQuit()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if(state == State.PREVIEW)
|
||||
{
|
||||
bool dialog = EditorUtility.DisplayDialog("Overriding in process", "You are using preview materials. Finish override process before closing Unity", "End override process", "Cancel");
|
||||
if (dialog)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
res = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void OnHierarchyChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void BeforeAssemblyReload()
|
||||
{
|
||||
if(overrideData != null)
|
||||
{
|
||||
overrideData.EndOverrideProcess();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ff44cb967a47df41a2c11c4f4bc3bbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/OverrideMaterialsTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,77 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class SavePathsTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Save Paths";
|
||||
|
||||
public SavePathsTabDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
GUILayout.Label("Material Save Path", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where new Materials will be saved when the Save Material To Folder button of the asset component is pressed", EditorStyles.boldLabel);
|
||||
GlobalConfiguration.instance.MaterialSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.MaterialSavePath, "New Material Folder");
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
GUILayout.Label("Render Material to Image Save Path", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Rendered Image Texture Scale", GUILayout.MaxWidth(190));
|
||||
GlobalConfiguration.instance.RenderImageScale = EditorGUILayout.Slider(GlobalConfiguration.instance.RenderImageScale, 0.2f, 5f, GUILayout.MaxWidth(200));
|
||||
if (GUILayout.Button("Default Value", GUILayout.MaxWidth(100)))
|
||||
{
|
||||
GlobalConfiguration.instance.RenderImageScale = 1f;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GlobalConfiguration.instance.RenderImageSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.RenderImageSavePath, "New Images Folder");
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
GUILayout.Label("Baked Shader Save Path", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where baked shaders will be saved when the Bake Shader Keywords button of the material inspector is pressed", EditorStyles.boldLabel);
|
||||
GlobalConfiguration.instance.BakedShaderSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.BakedShaderSavePath, "New Bake Shader Folder");
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
GUILayout.Label("Gradients Save Path", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GlobalConfiguration.instance.GradientsSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.GradientsSavePath, "Gradients Folder");
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dedcd72b9fe8cc46920937a02695a3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/SavePathsTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,101 @@
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureCreatorTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Texture Creators";
|
||||
|
||||
private NormalMapCreatorTool normalMapCreatorTool;
|
||||
private NormalMapCreatorDrawer normalMapCreatorDrawer;
|
||||
|
||||
private GradientCreatorTool gradientCreatorTool;
|
||||
private GradientCreatorDrawer gradientCreatorDrawer;
|
||||
|
||||
private AtlasPackerTool atlasPackerTool;
|
||||
private AtlasPackerDrawer atlasPackerDrawer;
|
||||
|
||||
private NoiseCreatorTool noiseCreatorTool;
|
||||
private NoiseCreatorDrawer noiseCreatorDrawer;
|
||||
|
||||
private RGBAPackerTool rgbaPackerTool;
|
||||
private RGBAPackerDrawer rgbaPackerDrawer;
|
||||
|
||||
public TextureCreatorTabDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
normalMapCreatorTool = new NormalMapCreatorTool();
|
||||
normalMapCreatorDrawer = new NormalMapCreatorDrawer(normalMapCreatorTool, commonStyles, Repaint);
|
||||
|
||||
gradientCreatorTool = new GradientCreatorTool();
|
||||
gradientCreatorDrawer = new GradientCreatorDrawer(gradientCreatorTool, commonStyles);
|
||||
|
||||
atlasPackerTool = new AtlasPackerTool();
|
||||
atlasPackerDrawer = new AtlasPackerDrawer(atlasPackerTool, commonStyles);
|
||||
|
||||
noiseCreatorTool = new NoiseCreatorTool();
|
||||
noiseCreatorDrawer = new NoiseCreatorDrawer(noiseCreatorTool, commonStyles);
|
||||
|
||||
rgbaPackerTool = new RGBAPackerTool();
|
||||
rgbaPackerDrawer = new RGBAPackerDrawer(rgbaPackerTool, commonStyles);
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
normalMapCreatorDrawer.Draw();
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
gradientCreatorDrawer.Draw();
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
atlasPackerDrawer.Draw();
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
noiseCreatorDrawer.Draw();
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
rgbaPackerDrawer.Draw();
|
||||
}
|
||||
|
||||
private void Repaint()
|
||||
{
|
||||
parentWindow.Repaint();
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13ec4b12120f25c43bfae408eec0aa1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/TextureCreatorTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,73 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureEditorTabDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "Texture Editor";
|
||||
|
||||
private TextureEditorTool textureEditorTool;
|
||||
private TextureEditorValuesDrawer textureEditorValuesDrawer;
|
||||
|
||||
public TextureEditorTabDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
textureEditorTool = new TextureEditorTool();
|
||||
textureEditorValuesDrawer = new TextureEditorValuesDrawer();
|
||||
textureEditorValuesDrawer.Setup(textureEditorTool);
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
textureEditorTool.editorTexInput = EditorGUILayout.ObjectField("Image to Edit", textureEditorTool.editorTexInput, typeof(Texture2D), false, GUILayout.Width(300), GUILayout.Height(50)) as Texture2D;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (textureEditorTool.editorTexInput != null)
|
||||
{
|
||||
textureEditorTool.Setup();
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
if (textureEditorTool.editorTex != null)
|
||||
{
|
||||
textureEditorValuesDrawer.Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Please select an Image to Edit above", EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7920383ff86b65c498c235aded8484b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/TextureEditorTabDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class URPSettingsController
|
||||
{
|
||||
public static void DisableFeature(string featureToDisable)
|
||||
{
|
||||
// Find the shader features file
|
||||
string[] guids = AssetDatabase.FindAssets("AllIn13DShader_FeaturesURP_Defines");
|
||||
if (guids.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("AllIn13DShader_FeaturesURP file not found");
|
||||
return;
|
||||
}
|
||||
|
||||
string shaderFeaturesFilePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
if (string.IsNullOrEmpty(shaderFeaturesFilePath))
|
||||
{
|
||||
Debug.LogWarning("Could not get path for AllIn13DShader_FeaturesURP file");
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the file content
|
||||
string fileContent = File.ReadAllText(shaderFeaturesFilePath);
|
||||
string[] lines = fileContent.Split("\n");
|
||||
|
||||
string correctedFile = string.Empty;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
string line = lines[i];
|
||||
if (line.StartsWith($"#define {featureToDisable}"))
|
||||
{
|
||||
line = "//" + line;
|
||||
}
|
||||
|
||||
correctedFile += line;
|
||||
}
|
||||
|
||||
File.WriteAllText(shaderFeaturesFilePath, correctedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c95b42002e9c5d24a9ee98ad07f670c9
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/URPSettingsController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class URPSettingsDrawer : AssetWindowTabDrawer
|
||||
{
|
||||
private const string TAB_NAME = "URP Settings";
|
||||
|
||||
private URPSettings urpSettings;
|
||||
private URPSettingsUserPref urpSettingsUserPref;
|
||||
|
||||
public URPSettingsDrawer(CommonStyles commonStyles, AllIn13DShaderWindow parentWindow) : base(commonStyles, parentWindow)
|
||||
{
|
||||
this.urpSettings = EditorUtils.FindAsset<URPSettings>(URPSettings.ASSET_NAME);
|
||||
this.urpSettingsUserPref = EditorUtils.FindAsset<URPSettingsUserPref>(URPSettingsUserPref.ASSET_NAME);
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
GUILayout.Label("Shader Feature Configuration", commonStyles.bigLabel);
|
||||
EditorGUILayout.HelpBox("Enable/disable shader features to optimize compilation time and editor performance. \n" +
|
||||
"Hover each feature to get a more detailed tooltip.", MessageType.Info);
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
for(int i = 0; i < urpSettings.configs.Length; i++)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
URPFeatureConfig urpFeatureConfig = urpSettings.configs[i];
|
||||
URPFeatureUserPref urpFeatureUserPref = urpSettingsUserPref.FindPreferenceByID(urpFeatureConfig.shaderDefine);
|
||||
if(urpFeatureUserPref == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
GUIContent toggleContent = new GUIContent(urpFeatureConfig.displayName, urpFeatureConfig.tooltip);
|
||||
urpFeatureUserPref.enabled = EditorGUILayout.ToggleLeft(toggleContent, urpFeatureUserPref.enabled);
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if(GUILayout.Button("Apply Changes"))
|
||||
{
|
||||
ApplyFeatureChanges();
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Reset to Defaults"))
|
||||
{
|
||||
ResetToDefaults();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(20);
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
GUILayout.Label("Configure AllIn13D to work correctly with URP", commonStyles.bigLabel);
|
||||
if (GUILayout.Button("Configure"))
|
||||
{
|
||||
#if ALLIN13DSHADER_URP
|
||||
URPConfigurator.Configure(forceConfigure: true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void EnteredPlayMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ApplyFeatureChanges()
|
||||
{
|
||||
URPDefinesFileCreator.CreateFile(urpSettings, urpSettingsUserPref);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private void ResetToDefaults()
|
||||
{
|
||||
|
||||
for(int i = 0; i < urpSettingsUserPref.preferences.Length; i++)
|
||||
{
|
||||
URPFeatureUserPref preference = urpSettingsUserPref.preferences[i];
|
||||
URPFeatureConfig urpFeatureConfig = urpSettings.FindConfigByID(preference.id);
|
||||
|
||||
urpSettingsUserPref.preferences[i].Init(urpFeatureConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetTabName()
|
||||
{
|
||||
return TAB_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 638a6d02f9a0f524386897efd05ce5c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Windows/URPSettingsDrawer.cs
|
||||
uploadId: 865720
|
||||
Reference in New Issue
Block a user