[英]unity3d import c++ dll for pass by reference method
I'd like to use c++ code in Unity3d. 我想在Unity3d中使用c ++代码。 Normally, it is ok, i can do it by importing dll.
通常情况下,可以,我可以通过导入dll来实现。 What i'm trying to learn is whether using c++ method parameters as pass by reference is possible or not?
我想学习的是,是否可以将c ++方法参数用作通过引用传递?
What i'm trying to do is getting size of uchar* array returned by c++ code. 我正在尝试做的是获取c ++代码返回的uchar *数组的大小。
What i'm trying to learn is whether using C++ method parameters as pass by reference is possible or not?
我想学习的是,是否可以将C ++方法参数用作通过引用传递?
Yes, it is possible. 对的,这是可能的。 Use
int*
on the C++ side and ref int
on the C# side. 在C ++端使用
int*
,在C#端ref int
。 You should be able to write to that parameter from C++ and it will update on the C# side. 您应该能够从C ++写入该参数,并且它将在C#端更新。
See this answer from my other post for a complete example. 见这从我的其他职位的答案一个完整的例子。
What i'm trying to do is getting size of uchar* array returned by c++ code.
我正在尝试做的是获取c ++代码返回的uchar *数组的大小。
You can with the example above. 您可以使用上面的示例。 If you care about performance, do not return array from C++.
如果您关心性能,请不要从C ++返回数组。 Create the array in C# then pass it to C++ and modify it there.
用C#创建数组,然后将其传递给C ++并在此进行修改。 See the linked answer for information.
有关信息,请参见链接的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.