简体   繁体   中英

unity3d import c++ dll for pass by reference method

I'd like to use c++ code in Unity3d. Normally, it is ok, i can do it by importing dll. What i'm trying to learn is whether using c++ method parameters as pass by reference is possible or not?

What i'm trying to do is getting size of uchar* array returned by c++ code.

What i'm trying to learn is whether using C++ method parameters as pass by reference is possible or not?

Yes, it is possible. Use int* on the C++ side and ref int on the C# side. You should be able to write to that parameter from C++ and it will update on the C# side.

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.

You can with the example above. If you care about performance, do not return array from C++. Create the array in C# then pass it to C++ and modify it there. See the linked answer for information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM