C# Как импортировать C++ dll который возвращает класс Vector2
C# Как импортировать Dll который возвращает класс Vector2.
C++
namespace ExtremeEngineEditor
{
class Vector2
{
public:
float X, Y;
Vector2(float x, float y)
{
X = x;
Y = y;
}
};
extern "C" GUILAYOUT_API Vector2 GetDisplaySize();
}
C#
#if ExtremeEngineEditor
using ExtremeEngine.Math;
using System.Runtime.InteropServices;
namespace ExtremeEngineEditor
{
/// <summary>
/// GUILayout made to draw editor gui.
/// GUILayout works on Dear ImGui.
/// </summary>
public static class GUILayout
{
[DllImport("ExtremeEngine")]
public static extern Vector2 GetDisplaySize();
}
}
#endif
И мой Vector2 класс в С#.
namespace ExtremeEngine
{
namespace Math
{
public class Vector2
{
public float X = 0, Y = 0;
public Vector2()
{
}
public Vector2(int x)
{
X = x;
}
public Vector2(int x, int y)
{
X = x; Y = y;
}
public static readonly Vector2 Zero = new(0, 0);
public static readonly Vector2 One = new(1, 1);
public static readonly Vector2 OneMinus = new(-1, -1);
public static readonly Vector2 Left = new(-1, 0);
public static readonly Vector2 Up = new(0, 1);
public static readonly Vector2 Right = new(1, 0);
public static readonly Vector2 Down = new(0, -1);
}
}
}