Unity3d请求用户授权(OSX) [英] Unity3d request user authorisation (OSX)
问题描述
因此,基本上我的Unity程序将需要在OSX上修改主机文件,并且需要管理员权限.而且我得到了以下异常:
So basically my Unity program would need to modify hosts file on OSX and that need admin privilege. And i got the following Exception:
UnauthorizedAccessException: Access to the path "/private/etc/hosts" is denied.
如何弹出"XXX要进行更改:输入密码以允许更改".窗口,就像我在下面附上的屏幕截图一样?
How do I pop a "XXX wants to make changes: Enter your password to allow this." window just like the screenshot I attached below?
我做了一些Google,但是找不到任何有用的东西.
I did some Google but i couldn't find anything useful.
任何建议将不胜感激.
Any suggestion would be appreciated.
推荐答案
进行了更多研究,我现在能想到的唯一解决方案是使用Apple的
Did some more research, the only solution I can think off right now is to write a native plugin using apple's Authorization service, and call it from Unity program.
但是,如果有更多的Unity方式可以做到这一点,请不要犹豫地将其添加为答案.
But if there's a more Unity way of doing it, please don't hesitate to add it as an answer.
EDIT_1:进度更新和对我未来的自我的记录.
EDIT_1: Progress update and a note to my future self.
后缀为.bundle的OSX是本机插件,我用C ++编写(因为官方示例是c ++),但它无法访问授权服务.而且我不知道如何为捆绑项目设置OC.现在,我正在尝试为OS X创建命令行工具应用程序并将其作为Unity3d的外部进程运行的替代方法.好消息是我现在可以用swift编写它了!
A native plugin for OSX is suffixed .bundle, I wrote it in C++(since the official example is in c++), but it dont have access to authorization service. And i don't know how to setup OC for a bundle project. Now I'm trying an alternative to create a command-line tool application for OS X and run it as an external process from Unity3d. Good news is now i can use swift to write it !
.
EDIT_2:进度更新和对我未来的自我的记录.
EDIT_2: Progress update and a note to my future self.
用OC编写的命令行工具确实起作用了.我可以简单地使用Unity3d中的Process.start(name,arguments)打开命令行工具.
The commandline tool written in OC did work. I can simply open command line tool using Process.start(name, argument) in Unity3d.
这篇关于Unity3d请求用户授权(OSX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!