#pragma once #include // Minimal subset of Unity's plugin SDK headers (from Unity's NativeRenderingPlugin sample). // Full headers available at: https://github.com/Unity-Technologies/NativeRenderingPlugin #ifndef UNITY_INTERFACE_API # if defined(_WIN32) # define UNITY_INTERFACE_API __stdcall # define UNITY_INTERFACE_EXPORT __declspec(dllexport) # else # define UNITY_INTERFACE_API # define UNITY_INTERFACE_EXPORT __attribute__((visibility("default"))) # endif #endif struct IUnityInterface {}; // Must be declared before IUnityInterfaces uses it. struct UnityInterfaceGUID { uint64_t high; uint64_t low; }; struct IUnityInterfaces { // x64 Windows ABI: a 16-byte struct is passed by pointer (caller allocates on stack, // passes rdx = &struct). Our signature must match Unity's vtable exactly — one // struct-by-value arg — so the compiler generates the correct pointer-passing call. virtual IUnityInterface* UNITY_INTERFACE_API GetInterfaceByGUID(UnityInterfaceGUID guid) = 0; template T* Get() { return static_cast(GetInterfaceByGUID(T::GUID)); } };