Unity3d C#中如何调用c++中返回值是结构体或者枚举的函数

i75580 2016-03-30 11:05:33
我想实现Unity3d中调用C++的动态库
C++中的函数:

typedef enum {
E_OK, /** Okay to go */
E_NOT_READY, /** RpsInitialize invoked before ? */
E_BUSY, /** Not used */
E_TIMEOUT, /** Not used */
E_NO_RESOURCE, /** resources requried not available */
E_BAD_PARA, /** bad parameters */
E_MULTI_SOURCE, /** Not used */
E_INVALID_VERSION /** Not used */
} RpsError;

RpsAPI RpsError RpsInitialize(const char *conf);

Unity中的调用:

enum RpsError{
E_OK,
E_NOT_READY,
E_BUSY,
E_TIMEOUT,
E_NO_RESOURCE,
E_BAD_PARA,
E_MULTI_SOURCE,
E_INVALID_VERSION
};

public class NewBehaviourScript : MonoBehaviour {
[DllImport("RPSDataManager.dll")]
unsafe ublic extern static RpsError RpsInitialize(string conf);

// Use this for initialization
unsafe void Start () {
RpsError err = RpsInitialize("RpsDataManager.API.txt");
if (err != 0) {
print("RpsInit failed!");
}
}
}


运行报错:
error CS0050:Inconsistent accessibility : return type 'RpsError' is less accessible than method 'NewBehaviourScript.RpsInitialize(string)'

请教一下我应该怎么处理呢?



...全文
315 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Saleayas 2016-03-30
  • 打赏
  • 举报
回复
public enum

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧