Add IsScriptingObject utility to ScriptType

This commit is contained in:
2026-07-22 11:29:07 +02:00
parent 7e48786ffc
commit d92f2a0437
7 changed files with 14 additions and 9 deletions
+2 -2
View File
@@ -643,7 +643,7 @@ namespace FlaxEditor.CustomEditors
text = text.Remove(idx, endIdx - idx);
}
}
else if (ScriptType.FlaxObject.IsAssignableFrom(Values.Type))
else if (Values.Type.IsScriptingObject)
{
// Object reference
text = JsonSerializer.GetStringID(value as FlaxEngine.Object);
@@ -691,7 +691,7 @@ namespace FlaxEditor.CustomEditors
return false;
}
}
else if (ScriptType.FlaxObject.IsAssignableFrom(Values.Type))
else if (Values.Type.IsScriptingObject)
{
// Object reference
if (text.Length != 32)
+5
View File
@@ -849,6 +849,11 @@ namespace FlaxEditor.Scripting
/// </summary>
public bool IsVoid => _managed == typeof(void);
/// <summary>
/// Gets a value indicating whether this type is <see cref="FlaxEngine.Object"/> (eg. script or actor).
/// </summary>
public bool IsScriptingObject => FlaxObject.IsAssignableFrom(this);
/// <summary>
/// Gets a value indicating whether the type is static.
/// </summary>
+1 -1
View File
@@ -1544,7 +1544,7 @@ namespace FlaxEditor.Surface.Elements
object obj;
var type = CurrentType;
if (ScriptType.FlaxObject.IsAssignableFrom(type))
if (type.IsScriptingObject)
{
// Object reference
if (text.Length != 32)
+1 -1
View File
@@ -212,7 +212,7 @@ namespace FlaxEditor.Surface
color = Colors.Enum;
else if (type.IsValueType)
color = Colors.Structures;
else if (ScriptType.FlaxObject.IsAssignableFrom(type) || type.IsInterface)
else if (type.IsScriptingObject || type.IsInterface)
color = Colors.Object;
else if (hint == ConnectionsHint.Vector)
color = Colors.Vector;
@@ -72,7 +72,7 @@ namespace FlaxEditor.Surface
// Implicit casting is supported for object reference to test whenever it is valid
var toType = to.Type;
if (supportsImplicitCastFromObjectToBoolean && toType == typeof(bool) && ScriptType.FlaxObject.IsAssignableFrom(from))
if (supportsImplicitCastFromObjectToBoolean && toType == typeof(bool) && from.IsScriptingObject)
{
return true;
}
+3 -3
View File
@@ -65,7 +65,7 @@ namespace FlaxEditor.Utilities
&& memberValue != null
&& !refStack.Contains(memberValue))
{
if (memberType.IsArray && !ScriptType.FlaxObject.IsAssignableFrom(memberType.GetElementType()))
if (memberType.IsArray && !memberType.GetElementType().IsScriptingObject)
{
// Array
var array = (Array)memberValue;
@@ -79,7 +79,7 @@ namespace FlaxEditor.Utilities
}
refStack.Pop();
}
else if (typeof(IList).IsAssignableFrom(memberType.Type) && !ScriptType.FlaxObject.IsAssignableFrom(memberType.GetElementType()))
else if (typeof(IList).IsAssignableFrom(memberType.Type) && !memberType.GetElementType().IsScriptingObject)
{
// List
var list = (IList)memberValue;
@@ -106,7 +106,7 @@ namespace FlaxEditor.Utilities
GetEntries(new MemberInfoPath.Entry(member.Member, key), membersPath, result, values, refStack, valueType, value);
}
}
else if (memberType.IsClass && !ScriptType.FlaxObject.IsAssignableFrom(memberType))
else if (memberType.IsClass && !memberType.IsScriptingObject)
{
// Object
refStack.Push(memberValue);
+1 -1
View File
@@ -81,7 +81,7 @@ namespace FlaxEngine
!type.IsAbstract &&
!type.IsArray &&
!type.IsVoid &&
(type.IsStructure || ScriptType.FlaxObject.IsAssignableFrom(type)) &&
(type.IsStructure || type.IsScriptingObject) &&
type.IsPublic &&
type.CanCreateInstance;
}