【原】unity这些函数你知道吗?


1、网络检测函数(注意:需要在真机上实验,我原来在Imac上 断了网络检测不到

网络检测
if(Application.internetReachability==NetworkReachability.NotReachable)//无网络
{ 

}
else//if(Application.internetReachability==NetworkReachability.ReachableViaLocalAreaNetwork||Application.internetReachability==NetworkReachability.ReachableViaCarrierDataNetwork)
 {

 }

2、设备类型检测

或者采用Screen.width=(480、960、1024、2048)来判断

3、游戏暂停
Time.timeScale=0f 暂停游戏   Time.timeScale=1f 恢复正常  介于0到1之间 可以做慢动作

 

4、        Screen.orientation=ScreenOrientation.Portrait;  解决华为设备横竖屏旋转

5、静态批处理 降低DC好办法   同时需要注意 Static batching only supports objects in the scene, you can't apply it to run-time instantiated items.

6.static function Combine(staticBatchRoot: GameObject): void; 手动静态批处理

7.unity在android设备上路径总结

Application.dataPath :/data/app/xxx.apk;

Application.persistentDataPath:/storage/sdcard0/Android/data/包名(例如:com.example.test)/files

Application.streamingAssetsPath:jar:file:///data/app/xxx.apk!/assets

8 unity3d 连接profiler

adb forward tcp:54999 localabstract:Unity-包名   前提是打包的时候勾选Autoconnect profiler


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM