Fix crash when removing Anim Event visual script that is used in opened Animation timeline

#2471
This commit is contained in:
Wojtek Figat
2024-04-22 18:11:25 +02:00
parent 32b15f90ab
commit b7dc0dd004
6 changed files with 78 additions and 11 deletions

View File

@@ -144,5 +144,11 @@ namespace FlaxEditor.Scripting
{
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
public void TrackLifetime(Action<ScriptType> disposing)
{
ElementType.TrackLifetime(disposing);
}
}
}

View File

@@ -167,6 +167,12 @@ namespace FlaxEditor.Scripting
/// <param name="bindingAttr">A bitmask comprised of one or more <see cref="T:System.Reflection.BindingFlags" /> that specify how the search is conducted.-or- Zero (<see cref="F:System.Reflection.BindingFlags.Default" />), to return an empty array.</param>
/// <returns>An array of member objects representing all methods defined for the current type that match the specified binding constraints.-or- An empty array of type member, if no methods are defined for the current type, or if none of the defined methods match the binding constraints.</returns>
ScriptMemberInfo[] GetMethods(BindingFlags bindingAttr);
/// <summary>
/// Registers delegate to be invoked upon script type disposal (except hot-reload in Editor via <see cref="ScriptsBuilder.ScriptsReload"/>). For example, can happen when user deleted Visual Script asset.
/// </summary>
/// <param name="disposing">Event to call when script type gets disposed (eg. removed asset).</param>
void TrackLifetime(Action<ScriptType> disposing);
}
/// <summary>

View File

@@ -1395,11 +1395,21 @@ namespace FlaxEditor.Scripting
}
/// <summary>
/// Basic check to see if a type could be casted to another type
/// Registers delegate to be invoked upon script type disposal (except hot-reload in Editor via <see cref="ScriptsBuilder.ScriptsReload"/>). For example, can happen when user deleted Visual Script asset.
/// </summary>
/// <param name="disposing">Event to call when script type gets disposed (eg. removed asset).</param>
public void TrackLifetime(Action<ScriptType> disposing)
{
if (_custom != null)
_custom.TrackLifetime(disposing);
}
/// <summary>
/// Basic check to see if a type could be cast to another type
/// </summary>
/// <param name="from">Source type</param>
/// <param name="to">Target type</param>
/// <returns>True if the type can be casted</returns>
/// <returns>True if the type can be cast.</returns>
public static bool CanCast(ScriptType from, ScriptType to)
{
if (from == to)
@@ -1412,10 +1422,10 @@ namespace FlaxEditor.Scripting
}
/// <summary>
/// Basic check to see if this type could be casted to another type
/// Basic check to see if this type could be cast to another type
/// </summary>
/// <param name="to">Target type</param>
/// <returns>True if the type can be casted</returns>
/// <returns>True if the type can be cast.</returns>
public bool CanCastTo(ScriptType to)
{
return CanCast(this, to);