diff --git a/Source/Editor/Content/Proxy/ShaderSourceProxy.cs b/Source/Editor/Content/Proxy/ShaderSourceProxy.cs index 803ff66c8..2749c8d0e 100644 --- a/Source/Editor/Content/Proxy/ShaderSourceProxy.cs +++ b/Source/Editor/Content/Proxy/ShaderSourceProxy.cs @@ -10,11 +10,9 @@ using FlaxEngine; namespace FlaxEditor.Content { /// - /// Context proxy object for shader source files (represented by ). + /// Base class for shader source files. /// - /// - [ContentContextMenu("New/Shader Source")] - public class ShaderSourceProxy : ContentProxy + public abstract class ShaderBaseProxy : ContentProxy { /// public override bool CanCreate(ContentFolder targetLocation) @@ -29,6 +27,21 @@ namespace FlaxEditor.Content return targetLocation.ShortName == "Source" && prevTargetLocation.ShortName == "Shaders"; } + /// + public override EditorWindow Open(Editor editor, ContentItem item) + { + Editor.Instance.CodeEditing.OpenFile(item.Path); + return null; + } + } + + /// + /// Context proxy object for shader source files (represented by ). + /// + /// + [ContentContextMenu("New/Shader Source (.shader)")] + public class ShaderSourceProxy : ShaderBaseProxy + { /// public override void Create(string outputPath, object arg) { @@ -44,13 +57,6 @@ namespace FlaxEditor.Content File.WriteAllText(outputPath, shaderTemplate, Encoding.UTF8); } - /// - public override EditorWindow Open(Editor editor, ContentItem item) - { - Editor.Instance.CodeEditing.OpenFile(item.Path); - return null; - } - /// public override Color AccentColor => Color.FromRGB(0x7542f5); @@ -66,4 +72,33 @@ namespace FlaxEditor.Content return item is ShaderSourceItem; } } + + /// + /// Context proxy object for shader header files. + /// + /// + [ContentContextMenu("New/Shader Header (.hlsl)")] + public class ShaderHeaderProxy : ShaderBaseProxy + { + /// + public override void Create(string outputPath, object arg) + { + File.WriteAllText(outputPath, "\n", Encoding.UTF8); + } + + /// + public override Color AccentColor => Color.FromRGB(0x2545a5); + + /// + public override string FileExtension => "hlsl"; + + /// + public override string Name => "Shader Header"; + + /// + public override bool IsProxyFor(ContentItem item) + { + return false; + } + } } diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index bd8f3c036..53e45ff25 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -1135,6 +1135,7 @@ namespace FlaxEditor.Modules Proxy.Add(new FontProxy()); Proxy.Add(new ShaderProxy()); Proxy.Add(new ShaderSourceProxy()); + Proxy.Add(new ShaderHeaderProxy()); Proxy.Add(new ParticleEmitterProxy()); Proxy.Add(new ParticleEmitterFunctionProxy()); Proxy.Add(new ParticleSystemProxy());