游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2149|回复: 0

?????????????????iOS??????

[复制链接]

5万

主题

5万

帖子

8万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
89829
发表于 2019-12-19 13:54:35 | 显示全部楼层 |阅读模式
???iOS????????????????????????Devlin?????????????????????

????

????????????????????????????iOS????????????????XCode???????UnityInternalProfile?????Mono????????

??????

??XCode????????UnityInternalProfile???????XCode??????????????????????????????????????????????????????????????

????UnityInternalProfile???????mach_base_task_info??resident_size?????????

????_20191219134640.jpg

?????????????????????????????xcode??????resident_size?

????_20191219134648.jpg

??????????????

resident_size??????????????????????????????????????????MacOS????????????????iOS??task_vm_info ???????????compress???

????_20191219134650.jpg

????compress????????????!

????_20191219134653.jpg

??????????????resident_size????????????compress???????

????

????????????? = resident + compress???????iOS??????????????

?????????????????????????????????????memorywarning??????60%???Q?App?

????

?????????task_vm_info??resident ? compress ?????App?????????????Unity??????????Native?C#??,?????????????????

?XCodePostProcess::OnPostProcessBuild()??????????Unity???XCode????????Native???
  XClass AppRender = new XClass(pathToBuiltProject + "/Classes/UnityAppController+Rendering.mm");
        if( AppRender != null)
        {
            string TCode = "";
            TCode +=   "#include <mach/mach_time.h>\n";
            TCode +=   "#include <mach/mach.h>\n";
            TCode +=   "#include <mach/mach_host.h>\n";
            TCode +=   "#include <mach/task_info.h>\n";
            TCode +=   "#include <mach/task.h>\n";
            TCode +=   "static float GetTotalPhysicsMemory( )\n";
            TCode +=   "{\n";
            TCode +=   "    kern_return_t kr;\n";
            TCode +=   "    mach_msg_type_number_t info_count = TASK_VM_INFO_COUNT;\n";
            TCode +=   "    task_vm_info_data_t vm_info;\n";
            TCode +=   "    kr = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)&vm_info, &info_count);\n";
            TCode +=   "    if (kr == KERN_SUCCESS) return (float)(vm_info.compressed  + vm_info.resident_size) / 1024.0 / 1024.0;\n";
            TCode +=   "    return 0;\n";
            TCode +=   "}\n";
            TCode +=   "extern \"C\" float _Get_Profiler_TotalPhysicMemory(){return _fLockStepPhysicMemory;}\n";
            TCode +=   "extern \"C\" void UnityRepaint()";

            AppRender.Replace("extern \"C\" void UnityRepaint()",TCode );
        }



?UnityC#???????????? Get_Profiler_TotalPhysicMemory??????????????

  #if ( UNITY_IPHONE && !UNITY_EDITOR )

    [DllImport("__Internal")]
    static extern float _Get_Profiler_TotalPhysicMemory( );

    public static float Get_Profiler_TotalPhysicMemory( )
    {
        return _Get_Profiler_TotalPhysicMemory( );
    }
#endif

????

????????????????1???????????????????16k????????????????????????????????XCode??????????????????????????

???????????

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????

https://gwb.tencent.com/cn/tutor

?/ Devlin
?????GWB????
???https://mp.weixin.qq.com/s/s4tXl7KnjrDSnftbQSeiDg

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-17 20:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表