From 41905f98102a3077840204ecbdb45db78fd04569 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Thu, 13 May 2021 17:54:52 +0200 Subject: [PATCH] Add name restrictions based on proxy. --- Source/Editor/Modules/ContentEditingModule.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Modules/ContentEditingModule.cs b/Source/Editor/Modules/ContentEditingModule.cs index c476328cb..a9c74d5e1 100644 --- a/Source/Editor/Modules/ContentEditingModule.cs +++ b/Source/Editor/Modules/ContentEditingModule.cs @@ -118,11 +118,22 @@ namespace FlaxEditor.Modules return false; } - // Scripts cannot start with digit. - if (Char.IsDigit(shortName[0])) + if (item is NewItem ni) { - hint = "Name cannot start with a digit."; - return false; + 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