Last active
February 23, 2025 07:34
-
-
Save baobao/02d100a89dc1daaded470d024df4a2d1 to your computer and use it in GitHub Desktop.
C#とC++間でint型データを送りあう方法サンプルコード https://shibuya24.info/entry/unity-cs-cpp-int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C#とC++間でint型データを送り合うC#コード | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
public class InvokeCpp : MonoBehaviour | |
{ | |
[DllImport("TestDll.dll", CallingConvention = CallingConvention.Cdecl)] | |
static extern int Additive(int a, int b); | |
void Awake() | |
{ | |
var result = Additive(10, 24); | |
Debug.Log(result); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C#とC++間でint型データを送り合うC++コード | |
#include <iostream> | |
extern "C" __declspec(dllexport) int Additive(int a, int b) | |
{ | |
return a + b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment