Fix missing default value for new Visject method parameter if method uses Vector param
#2204
This commit is contained in:
@@ -763,6 +763,17 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
public string Name;
|
||||
public ScriptType Type;
|
||||
public bool IsOut;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (IsOut)
|
||||
sb.Append("out ");
|
||||
sb.Append(Type.ToString());
|
||||
sb.Append(" ");
|
||||
sb.Append(Name);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private struct SignatureInfo
|
||||
@@ -892,7 +903,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
ref var param = ref signature.Params[i];
|
||||
ref var paramMember = ref memberParameters[i];
|
||||
if (param.Type != paramMember.Type || param.IsOut != paramMember.IsOut)
|
||||
if (!SurfaceUtils.AreScriptTypesEqual(param.Type, paramMember.Type) || param.IsOut != paramMember.IsOut)
|
||||
{
|
||||
// Special case: param.Type is serialized as just a type while paramMember.Type might be a reference for output parameters (eg. `out Int32` vs `out Int32&`)
|
||||
var paramMemberTypeName = paramMember.Type.TypeName;
|
||||
@@ -1660,7 +1671,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
SaveSignature();
|
||||
|
||||
// Check if return type has been changed
|
||||
if (_signature.ReturnType != prevReturnType)
|
||||
if (!SurfaceUtils.AreScriptTypesEqual(_signature.ReturnType, prevReturnType))
|
||||
{
|
||||
// Update all return nodes used by this function to match the new type
|
||||
var usedNodes = DepthFirstTraversal(false);
|
||||
@@ -2158,7 +2169,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
return false;
|
||||
for (int i = 0; i < _signature.Length; i++)
|
||||
{
|
||||
if (_signature[i].Type != sig.Parameters[i].Type)
|
||||
if (!SurfaceUtils.AreScriptTypesEqual(_signature[i].Type, sig.Parameters[i].Type))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -532,5 +532,24 @@ namespace FlaxEditor.Surface
|
||||
value = new Double4(i);
|
||||
return value;
|
||||
}
|
||||
|
||||
private static bool AreScriptTypesEqualInner(ScriptType left, ScriptType right)
|
||||
{
|
||||
// Special case for Vector types that use typedefs and might overlap
|
||||
if (left.Type == typeof(Vector2) && (right.Type == typeof(Float2) || right.Type == typeof(Double2)))
|
||||
return true;
|
||||
if (left.Type == typeof(Vector3) && (right.Type == typeof(Float3) || right.Type == typeof(Double3)))
|
||||
return true;
|
||||
if (left.Type == typeof(Vector4) && (right.Type == typeof(Float4) || right.Type == typeof(Double4)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool AreScriptTypesEqual(ScriptType left, ScriptType right)
|
||||
{
|
||||
if (left == right)
|
||||
return true;
|
||||
return AreScriptTypesEqualInner(left, right) || AreScriptTypesEqualInner(right, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user