diff --git a/Source/Editor/Content/Proxy/ContentProxy.cs b/Source/Editor/Content/Proxy/ContentProxy.cs index 0948ef5e8..afb5c11fb 100644 --- a/Source/Editor/Content/Proxy/ContentProxy.cs +++ b/Source/Editor/Content/Proxy/ContentProxy.cs @@ -73,6 +73,16 @@ namespace FlaxEditor.Content throw new NotImplementedException(); } + /// + /// Determines whether the specified filename is valid for this proxy. + /// + /// The filename. + /// true if the filename is valid, otherwise false. + public virtual bool IsFileNameValid(string filename) + { + return true; + } + /// /// Determines whether this proxy can create items in the specified target location. /// diff --git a/Source/Editor/Content/Proxy/ScriptProxy.cs b/Source/Editor/Content/Proxy/ScriptProxy.cs index 89a08bb4f..0c8140d1a 100644 --- a/Source/Editor/Content/Proxy/ScriptProxy.cs +++ b/Source/Editor/Content/Proxy/ScriptProxy.cs @@ -66,6 +66,15 @@ namespace FlaxEditor.Content return false; } + /// + public override bool IsFileNameValid(string filename) + { + // Scripts cannot start with digit. + if (Char.IsDigit(filename[0])) + return false; + return true; + } + /// public override void Create(string outputPath, object arg) { diff --git a/Source/Editor/Modules/ContentEditingModule.cs b/Source/Editor/Modules/ContentEditingModule.cs index 0d0e65ca9..6d0299a43 100644 --- a/Source/Editor/Modules/ContentEditingModule.cs +++ b/Source/Editor/Modules/ContentEditingModule.cs @@ -118,6 +118,25 @@ namespace FlaxEditor.Modules return false; } + // Check proxy name restrictions + if (item is NewItem ni) + { + if (!ni.Proxy.IsFileNameValid(shortName)) + { + hint = "Name does not follow " + ni.Proxy.Name + " name restrictions !"; + return false; + } + } + else + { + var proxy = Editor.ContentDatabase.GetProxy(item); + if (proxy != null && !proxy.IsFileNameValid(shortName)) + { + hint = "Name does not follow " + proxy.Name + " name restrictions !"; + return false; + } + } + // Cache data string sourcePath = item.Path; string sourceFolder = System.IO.Path.GetDirectoryName(sourcePath);