Merge branch 'script-name' of git://github.com/jb-perrier/FlaxEngine into jb-perrier-script-name

This commit is contained in:
Wojtek Figat
2021-05-14 10:42:28 +02:00
3 changed files with 38 additions and 0 deletions

View File

@@ -73,6 +73,16 @@ namespace FlaxEditor.Content
throw new NotImplementedException();
}
/// <summary>
/// Determines whether the specified filename is valid for this proxy.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns><c>true</c> if the filename is valid, otherwise <c>false</c>.</returns>
public virtual bool IsFileNameValid(string filename)
{
return true;
}
/// <summary>
/// Determines whether this proxy can create items in the specified target location.
/// </summary>

View File

@@ -66,6 +66,15 @@ namespace FlaxEditor.Content
return false;
}
/// <inheritdoc />
public override bool IsFileNameValid(string filename)
{
// Scripts cannot start with digit.
if (Char.IsDigit(filename[0]))
return false;
return true;
}
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{

View File

@@ -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);