在Unity中将Unity生成的代码与Objective-C混合使用?

时间:2022-09-07 07:41:36

Is it possible to mix iOS code and interface elements with Unity generated iOS code?

是否可以将iOS代码和界面元素与Unity生成的iOS代码混合使用?

For example if I am working with a game developer who is developing a game in Unity, could I take his xCode project (generated by Unity), and add interface elements which I code myself using Objective-C & Interface Builder etc?

例如,如果我正在与在Unity中开发游戏的游戏开发人员合作,我可以使用他的xCode项目(由Unity生成),并添加我使用Objective-C和Interface Builder等编写自己的界面元素吗?

From what I can see this isn't possible as everything is created via Unity.... but hopefully I am wrong...

从我所看到的,这是不可能的,因为一切都是通过Unity创造的......但希望我错了......

Thanks!

6 个解决方案

#1


6  

You can even use 3rd party libraries in XCode and integrate them in the build process. After fiddling around with the right settings I wrote a blog entry about this:

您甚至可以在XCode中使用第三方库,并将它们集成到构建过程中。在摆弄正确的设置后,我写了一篇关于此的博客文章:

iPhone & Unity3D: Integrating 3rd Party Static Libraries in Unity3D Generated XCode Projects

iPhone和Unity3D:在Unity3D生成的XCode项目中集成第三方静态库

#2


2  

You should be able to generate Native plug ins to interact with the Unity code. You would need to write a wrapper though. Read more at: http://unity3d.com/support/documentation/Manual/Plugins.html

您应该能够生成Native插件以与Unity代码进行交互。你需要编写一个包装器。欲了解更多信息,请访问:http://unity3d.com/support/documentation/Manual/Plugins.html

Read the part at iOS :)

在iOS阅读部分:)

#3


2  

I came across this general guide to working with Unity native plugins in OSX which was useful and is probably where you need to be looking for your answer, as Zophiel said

我遇到了这个在OSX中使用Unity本机插件的一般指南,这很有用,可能就是你需要寻找答案的地方,正如Zophiel所说的那样

https://blog.reigndesign.com/blog/unity-native-plugins-os-x

#4


1  

You can just design a view and button to trigger the unity to run or stop, but models in unity can't be controlled using Obj-C, although unity has import to Xcode, it only import the start code, game scripts depending on the link libraries which couldn't be modified.

您可以设计一个视图和按钮来触发统一运行或停止,但是使用Obj-C无法控制统一模型,虽然Unity已导入Xcode,它只导入起始代码,游戏脚本取决于链接库无法修改。

#5


0  

I think you can do it as the same way I probably has been working with Objective-C without any changes. For Unity's code generator preserves the native codes under Classes.

我认为你可以这样做,就像我可能在没有任何改变的情况下使用Objective-C一样。对于Unity的代码生成器,在Classes下保留本机代码。

And furthermore there is an another way to do this which is called "Plug-in".

此外,还有另一种方法可以做到这一点,称为“插件”。

But I hope the developers in Unity find a better way seamlessly combined with Xcode as staffs in Apple usually does.

但是我希望Unity中的开发人员能够找到一种更好的方式与Xcode无缝结合,因为Apple的员工通常会这样做。

Combining IB and Unity's integrated editor would be better and more welcomed in future.

结合IB和Unity的集成编辑器将会更好,并且将来会受到更多欢迎。

#6


0  

Possible yes. Advisable for beginner or intermediate level Devs? Probably not. The Unity project is generated and regenerated every time you push a build. Now I believe that if you use Append when you do builds that it should keep existing changes to the Xcode project... but 'should' is the operative word there. You may need to implement some sort of build system like Jeeves to keep the headaches to a minimum if you are trying to do this on a large project in which you for see a constant stream of updates from both the Unity side and the Xcode side.

可能是的。建议初学者还是中级Devs?可能不会。每次推送构建时都会生成并重新生成Unity项目。现在我相信,如果你在构建时使用Append,它应该保留对Xcode项目的现有更改......但是'should'是那里的操作词。您可能需要实现某种类型的构建系统(如Jeeves),以便在大型项目中尝试执行此操作时将头痛降至最低,在该项目中,您可以从Unity端和Xcode端查看持续的更新流。

Now if you're integrating code that is in it's own files and doesn't overlap or rewrite the code Unity has generated, then the Append feature is really going to work for you, but if you're deleting, altering, or adding code to any of the files that Unity generated then definitely use SVN or some other form of source control and snap shot before and after every new Unity recompile / Xcode generation.

现在,如果您正在集成其自身文件中的代码并且不重叠或重写Unity生成的代码,那么Append功能确实适用于您,但是如果您要删除,更改或添加代码对于Unity生成的任何文件,然后在每次新的Unity重新编译/ Xcode生成之前和之后肯定使用SVN或其他形式的源代码控制和快照。

Also, take a look in the Unity Asset store. Whatever functionality you are trying to home brew in Xcode can definitely be written in C# on Unity. Someone else may have already conquered the problem you're trying to solve and placed it in the asset store for $5.

另外,请查看Unity Asset商店。无论你想在Xcode中尝试家庭酿造什么功能,绝对可以在Unity上使用C#编写。其他人可能已经征服了您尝试解决的问题并将其放入资产商店5美元。

Hope that helps.

希望有所帮助。

#1


6  

You can even use 3rd party libraries in XCode and integrate them in the build process. After fiddling around with the right settings I wrote a blog entry about this:

您甚至可以在XCode中使用第三方库,并将它们集成到构建过程中。在摆弄正确的设置后,我写了一篇关于此的博客文章:

iPhone & Unity3D: Integrating 3rd Party Static Libraries in Unity3D Generated XCode Projects

iPhone和Unity3D:在Unity3D生成的XCode项目中集成第三方静态库

#2


2  

You should be able to generate Native plug ins to interact with the Unity code. You would need to write a wrapper though. Read more at: http://unity3d.com/support/documentation/Manual/Plugins.html

您应该能够生成Native插件以与Unity代码进行交互。你需要编写一个包装器。欲了解更多信息,请访问:http://unity3d.com/support/documentation/Manual/Plugins.html

Read the part at iOS :)

在iOS阅读部分:)

#3


2  

I came across this general guide to working with Unity native plugins in OSX which was useful and is probably where you need to be looking for your answer, as Zophiel said

我遇到了这个在OSX中使用Unity本机插件的一般指南,这很有用,可能就是你需要寻找答案的地方,正如Zophiel所说的那样

https://blog.reigndesign.com/blog/unity-native-plugins-os-x

#4


1  

You can just design a view and button to trigger the unity to run or stop, but models in unity can't be controlled using Obj-C, although unity has import to Xcode, it only import the start code, game scripts depending on the link libraries which couldn't be modified.

您可以设计一个视图和按钮来触发统一运行或停止,但是使用Obj-C无法控制统一模型,虽然Unity已导入Xcode,它只导入起始代码,游戏脚本取决于链接库无法修改。

#5


0  

I think you can do it as the same way I probably has been working with Objective-C without any changes. For Unity's code generator preserves the native codes under Classes.

我认为你可以这样做,就像我可能在没有任何改变的情况下使用Objective-C一样。对于Unity的代码生成器,在Classes下保留本机代码。

And furthermore there is an another way to do this which is called "Plug-in".

此外,还有另一种方法可以做到这一点,称为“插件”。

But I hope the developers in Unity find a better way seamlessly combined with Xcode as staffs in Apple usually does.

但是我希望Unity中的开发人员能够找到一种更好的方式与Xcode无缝结合,因为Apple的员工通常会这样做。

Combining IB and Unity's integrated editor would be better and more welcomed in future.

结合IB和Unity的集成编辑器将会更好,并且将来会受到更多欢迎。

#6


0  

Possible yes. Advisable for beginner or intermediate level Devs? Probably not. The Unity project is generated and regenerated every time you push a build. Now I believe that if you use Append when you do builds that it should keep existing changes to the Xcode project... but 'should' is the operative word there. You may need to implement some sort of build system like Jeeves to keep the headaches to a minimum if you are trying to do this on a large project in which you for see a constant stream of updates from both the Unity side and the Xcode side.

可能是的。建议初学者还是中级Devs?可能不会。每次推送构建时都会生成并重新生成Unity项目。现在我相信,如果你在构建时使用Append,它应该保留对Xcode项目的现有更改......但是'should'是那里的操作词。您可能需要实现某种类型的构建系统(如Jeeves),以便在大型项目中尝试执行此操作时将头痛降至最低,在该项目中,您可以从Unity端和Xcode端查看持续的更新流。

Now if you're integrating code that is in it's own files and doesn't overlap or rewrite the code Unity has generated, then the Append feature is really going to work for you, but if you're deleting, altering, or adding code to any of the files that Unity generated then definitely use SVN or some other form of source control and snap shot before and after every new Unity recompile / Xcode generation.

现在,如果您正在集成其自身文件中的代码并且不重叠或重写Unity生成的代码,那么Append功能确实适用于您,但是如果您要删除,更改或添加代码对于Unity生成的任何文件,然后在每次新的Unity重新编译/ Xcode生成之前和之后肯定使用SVN或其他形式的源代码控制和快照。

Also, take a look in the Unity Asset store. Whatever functionality you are trying to home brew in Xcode can definitely be written in C# on Unity. Someone else may have already conquered the problem you're trying to solve and placed it in the asset store for $5.

另外,请查看Unity Asset商店。无论你想在Xcode中尝试家庭酿造什么功能,绝对可以在Unity上使用C#编写。其他人可能已经征服了您尝试解决的问题并将其放入资产商店5美元。

Hope that helps.

希望有所帮助。