Unity iOS 基础 Unity iOS Basics

来源:互联网 发布:c语言基本算法 编辑:程序博客网 时间:2024/05/22 15:37

This section covers the most common and important questions that come up when starting to work with iOS.

本节包括了iOS工作中最常见于最重要的问题。

Prerequisites 前提条件

I've just received iPhone Developer approval from Apple, but I've never developed for iOS before. What do I do first?
从Apple刚收到iOS开发的许可,但我之前从来没有开发过iOS,首先做什么呢?

A: Download the SDK, get up and running on the Apple developer site, and set up your team, devices, and provisioning. We've provided abasic list of steps to get you started.

:下载SDK ,启动并打开苹果开发者网站,设置你的团队、设备和配置文件。我们提供了基本的步骤列表。

Can Unity-built games run in the iPhone Simulator?
用unity创建的游戏能运行在iPhone的模拟器吗?

A: No, but Unity iOS can build to iPad Simulator if you're using the latest SDK. However the simulator itself is not very useful for Unity because it does not simulate all inputs from iOS or properly emulate the performance you get on the iPhone/iPad. You should test out gameplay directly inside Unity using the iPhone/iPad as a remote control while it is running the Unity Remote application. Then, when you are ready to test performance and optimize the game, you publish to iOS devices.

:不能,但如果使用最新的SDK,Unity iOS能编译到iPad模拟器。然而模拟器本身对于unity并不是非常有用,因为它没有模拟iOS所有的交互方式,而且它不能正确模拟在iPhone/iPad上运行的性能。应该直接在unity中测试游戏,当它运行unity remote应用时,使用iPhone/iPad将作为一个远程控制器。然后当你准备好要测试性能和优化游戏时,就将其直接发布到iOS设备中。

Unity Features (Unity功能)

How do I work with the touch screen and accelerometer?
如何使用触摸屏和加速度计?

A: In the scripting reference inside your Unity iOS installation, you will find classes that provide the hooks into the device's functionality that you will need to build your apps. Consult theInput System page for more information.

:在你Unity iOS安装的脚本参考中,会找到一些类,提供设备功能的钩子。查阅输入系统页面获取更多信息。

My existing particle systems seem to run very slowly on iOS. What should I do?
我现有的粒子系统在iOS上看起来运行很慢,应该怎么做??

A: iOS has relatively low fillrate. If your particles cover a rather large portion of the screen with multiple layers, it will kill iOS performance even with the simplest shader. We suggest baking your particle effects into a series of textures off-line. Then, at run-time, you can use 1-2 particles to display them via animated textures. You can get fairly decent looking effects with a minimum amount of overdraw this way.

: iOS拥有相对较低的填充率。如果你的粒子效果覆盖大部分的屏幕,而且带有多层,这样即使最简单的shader,也能抹杀iOS性能。我们建议把你的粒子效果烘焙成纹理序列图。然后在运行时可以用1-2个粒子,通过动画纹理来显示它们。通过这种方式你可以以最小的代价获得很好的效果。

Can I make a game that uses heavy physics?
是否可以在游戏中,使用复杂的物理系统?

A: Physics can be expensive on iOS is it requires a lot of floating point number crunching. You should completely avoid MeshColliders if at all possible, but they can be used if they are really necessary. To improve performance, use a low fixed framerate using Edit->Time->Fixed Delta Time. A framerate of 10-30 is recommended. Enable rigidbody interpolation to achieve smooth motion while using low physics frame rates. In order to achieve completely fluid framerate without oscillations, it is best to pick fixed deltaTime value based on the average framerate your game is getting on iOS. Either 1:1 or half the frame rate is recommended. For example, if you get 30 fps, you should use 15 or 30 fps for fixed frame rate (0.033 or 0.066)

:iOS运算物理仿真代价很高,需要做很多浮点数运算,如果可能你应当完全避免使用网格碰撞器(MeshCollider)。但必要时也是可用的。要提高性能,通过"Edit->Time->Fixed Delta Time"使用一个低的固定帧率。建议控制在10~30。在降低物理帧速率的同时,可以使用刚体插值以实现平滑的动作效果。为了实现完全流畅的帧率而不卡机,最好是选择Fixed deltaTime value base,使你的游戏在iOS上获得一个平均的帧率 。建议要么1:1或一半的帧速率。例如,如果你想获得30fps,应该使用15或30 fps作为固定帧速率( 0.033或0.066 )。

Can I access the gallery, music library or the native iPod player in Unity iOS?
在Unity iOS我可以访问图库、音乐库或本地的iPod播放器吗?

A: Yes - if you implement it. Unity iPhone supports the native plugin system, where you can add any feature you need -- including access to Gallery, Music library, iPod Player and any other feature that the iOS SDK exposes. Unity iOS does not provide an API for accessing the through Unity scripts.

:是的-如果你实现它。Unity iPhone支持本地插件系统,你可以添加任何你需要的功能-包括访问图库、音乐库、iPod播放器和任何其他iOS SDK公开的功能。Unity IOS不提供通过Unity脚本访问的列出功能的API。

UnityGUI Considerations
UnityGUI的注意事项

What kind of performance impact will UnityGUI make on my games?
使用UnityGUI将会对我的游戏性能产生什么影响吗?

A: UnityGUI is fairly expensive when many controls are used. It is ideal to limit your use of UnityGUI to game menus or very minimal GUI Controls while your game is running. It is important to note that every object with a script containing an OnGUI() call will require additional processor time -- even if it is an empty OnGUI() block. It is best to disable any scripts that have an OnGUI() call if the GUI Controls are not being used. You can do this by marking the script as enabled = false.

: 当有许多控件时,UnityGUI是相当消耗性能的。理想的方法是限制使用UnityGUI制作游戏菜单,或在游戏运行中尽量少用GUI控件。重要的是要注意,每个包含OnGUI()脚本的对象调用将需要更多的处理器时间,即使它是一个空OnGUI()块。如果GUI控件未被使用,最好的方法是禁止任何脚本有OnGUI()调用。可以标记脚本enabled = false这样做。

Any other tips for using UnityGUI?
使用UnityGUI的其他技巧?

A: Try using GUILayout as little as possible. If you are not using GUILayout at all from one OnGUI() call, you can disable all GUILayout rendering using MonoBehaviour.useGUILayout = false; This doubles GUI rendering performance. Finally, use as few GUI elements while rendering 3D scenes as possible.

:尽可能少尝试使用GUILayout。如果所有的GUILayout不是都从一个OnGUI()调用,可以通过使用MonoBehaviour.useGUILayout = false;禁用所有GUILayout渲染,这能两倍提高GUI渲染性能。最后,渲染3D场景要尽可能少的使用GUI元素。

0 0