Merge branch 'script-name' of git://github.com/jb-perrier/FlaxEngine into jb-perrier-script-name
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user