幾種方法驗證unity是否為development build


我在月初接入了uwa的性能測試SDK,需要提交一個development build的游戲安裝包給uwa進行真人真機測試,本文說下如何判斷安裝包是否為development build。

直觀上判斷

如果是development build模式打包出來的安裝包,在游戲的畫面的右下角會有development build的水印,且在切換場景也不會消失

通過libunity.so判斷

使用壓縮軟件,打開apk,查看libunity.so(在lib/armxx目錄下),如果是development build話libunity.so 會比較大,以Unity2018.4.15f1為例 development build的有46MB。而release模式只有20MB

通過代碼判斷

Unity引擎提供這樣一個接口來訪問是否 development build,原文如下:

In the Build Settings dialog there is a check box called "Development Build".

If it is checked isDebugBuild will be true. In the editor isDebugBuild always returns true. It is recommended to remove all calls to Debug.Log when deploying a game, this way you can easily deploy beta builds with debug prints and final builds without.

using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        // Log some debug information only if this is a debug build
        if (Debug.isDebugBuild)
        {
            Debug.Log("This is a debug build!");
        }
    }
}

Unity 打包設置

不管是通過Unity直接生成apk,還是導出android studio項目之后再生成apk,都需要加上BuildOptions.Development,就能保證導出的版本為development

BuildPipeline.BuildPlayer(GetScenePaths(), outPath, tag, BuildOptions.Development );


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM