Add Float2/Float3/Float4 replication in C#

This commit is contained in:
Wojciech Figat
2022-11-03 14:33:39 +01:00
parent 0c9001e3d1
commit 007a5cb5ca
3 changed files with 69 additions and 3 deletions

View File

@@ -58,6 +58,9 @@ namespace Flax.Build.Plugins
{ "FlaxEngine.Vector2", new InBuildSerializer("WriteVector2", "ReadVector2") },
{ "FlaxEngine.Vector3", new InBuildSerializer("WriteVector3", "ReadVector3") },
{ "FlaxEngine.Vector4", new InBuildSerializer("WriteVector4", "ReadVector4") },
{ "FlaxEngine.Float2", new InBuildSerializer("WriteFloat2", "ReadFloat2") },
{ "FlaxEngine.Float3", new InBuildSerializer("WriteFloat3", "ReadFloat3") },
{ "FlaxEngine.Float4", new InBuildSerializer("WriteFloat4", "ReadFloat4") },
{ "FlaxEngine.Quaternion", new InBuildSerializer("WriteQuaternion", "ReadQuaternion") },
};

View File

@@ -33,17 +33,26 @@ namespace Flax.Build
public static MethodDefinition GetMethod(this TypeDefinition type, string name)
{
return type.Methods.First(x => x.Name == name);
var result = type.Methods.FirstOrDefault(x => x.Name == name);
if (result == null)
throw new Exception($"Failed to find method '{name}' in '{type.FullName}'.");
return result;
}
public static MethodDefinition GetMethod(this TypeDefinition type, string name, int argCount)
{
return type.Methods.First(x => x.Name == name && x.Parameters.Count == argCount);
var result = type.Methods.First(x => x.Name == name && x.Parameters.Count == argCount);
if (result == null)
throw new Exception($"Failed to find method '{name}' (args={argCount}) in '{type.FullName}'.");
return result;
}
public static FieldDefinition GetField(this TypeDefinition type, string name)
{
return type.Fields.First(x => x.Name == name);
var result = type.Fields.First(x => x.Name == name);
if (result == null)
throw new Exception($"Failed to find field '{name}' in '{type.FullName}'.");
return result;
}
public static bool IsScriptingObject(this TypeDefinition type)