BuildAndroidResource() private method

private BuildAndroidResource ( ) : void
return void
Exemplo n.º 1
0
 void EndBuildAndroidResource()
 {
     //然后要build android resource
     Packager.BuildAndroidResource();
     //最后要把.vscode文件夹移回来
     MoveFolder("Assets/Editor/AutoBuild/.vscode", "Assets/LuaFramework/Lua/.vscode");
 }
Exemplo n.º 2
0
 public static void PackageOneKey()
 {
     Packager.BuildAndroidResource();
     SetAllAbName();
     PackAb();
     BuildResIndex();
     Debug.Log("一键打包资源完毕");
 }
Exemplo n.º 3
0
    static void BuildForAndroid()
    {
        //Function.DeleteFolder(Application.dataPath + "/Plugins/Android");
        Packager.BuildAndroidResource();
        if (Function.projectName == "91")
        {
            //Function.CopyDirectory(Application.dataPath + "/91", Application.dataPath + "/Plugins/Android");
            //PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "USE_SHARE");
        }
        string path = Application.dataPath + "/../" + Function.projectName + ".apk";

        BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.None);
    }
Exemplo n.º 4
0
    static void Build()
    {
        //1.先重新命名AssetBundle name
        ClearAssetBundlesName();
        Pack(sourcePath);

        //2.拷贝资源
        //todo 调用packager 代码拷贝
        Packager.BuildAndroidResource();

        //3.放置资源到android 目录
        string outputDeviceDir = Path.Combine(OUTPUT_DIR, "UnityProject");

        Debug.LogFormat("output device dir:{0}", outputDeviceDir);
        //清理输出目录
        if (Directory.Exists(outputDeviceDir))
        {
            DirectoryInfo info = new DirectoryInfo(outputDeviceDir);
            info.Delete(true);
        }

        string androidDeviceDir = Path.Combine(ANDROID_ASSETS_DIR, "assets");

        Debug.LogFormat("android assets device dir:{0}", androidDeviceDir);

        //清理Android工程下的目标目录
        if (Directory.Exists(androidDeviceDir))
        {
            DirectoryInfo info      = new DirectoryInfo(androidDeviceDir);
            var           fileInfos = info.GetFiles();
            foreach (var fileInfo in fileInfos)
            {
                fileInfo.Delete();
            }
        }

        //Build
        BuildPipeline.BuildPlayer(scenes, outputDeviceDir, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);

        //拷贝assets到Android工程
        CopyDirectory(outputDeviceDir + "/" + PlayerSettings.productName + "/assets", androidDeviceDir);
    }
Exemplo n.º 5
0
    //这里封装了一个简单的通用方法。
    public static void BulidTarget(string name, string publicer, string ver, string target, bool isDebug)
    {
        string app_name = name + ver + publicer;

        string           target_dir      = string.Empty;
        string           target_name     = app_name + ".exe";
        BuildTargetGroup targetGroup     = BuildTargetGroup.Standalone;
        BuildTarget      buildTarget     = BuildTarget.StandaloneWindows;
        string           applicationPath = Application.dataPath.Replace("/Assets", "");

        target_dir = applicationPath + "/TargetWin";
        if (target == "Android")
        {
            string x86Dir = Application.dataPath + "/Plugins/x86";
            string x64Dir = Application.dataPath + "/Plugins/x86_64";
            if (Directory.Exists(x86Dir))
            {
                Directory.Delete(x86Dir, true);
            }
            if (Directory.Exists(x64Dir))
            {
                Directory.Delete(x64Dir, true);
            }
            AssetDatabase.Refresh();
            Packager.BuildAndroidResource();
            target_dir  = applicationPath + "/TargetAndroid";
            target_name = app_name + ".apk";
            targetGroup = BuildTargetGroup.Android;
            buildTarget = BuildTarget.Android;
        }
        else if (target == "IOS")
        {
            target_dir  = applicationPath + "/TargetIOS";
            target_name = app_name;
            targetGroup = BuildTargetGroup.iOS;
            buildTarget = BuildTarget.iOS;
        }
        else
        {
            Packager.BuildWindowsResource();
        }
        //每次build删除之前的残留
        if (Directory.Exists(target_dir))
        {
            if (File.Exists(target_name))
            {
                File.Delete(target_name);
            }
        }
        else
        {
            Directory.CreateDirectory(target_dir);
        }
        // Player Setting
        //
        PlayerSettings.companyName = "HF";
        //
        PlayerSettings.productName = name;
        //
        PlayerSettings.GetIconSizesForTargetGroup(targetGroup);

        //
        //
        PlayerSettings.defaultInterfaceOrientation           = UIOrientation.LandscapeLeft;
        PlayerSettings.allowedAutorotateToLandscapeLeft      = true;
        PlayerSettings.allowedAutorotateToLandscapeRight     = true;
        PlayerSettings.allowedAutorotateToPortrait           = false;
        PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
        //
        PlayerSettings.statusBarHidden = true;

        //
        PlayerSettings.apiCompatibilityLevel = ApiCompatibilityLevel.NET_2_0_Subset;
        //
        PlayerSettings.bundleVersion = ver;
        //
        PlayerSettings.forceSingleInstance = true;
        // bug?
        //PlayerSettings.gpuSkinning = true;
        //
        PlayerSettings.renderingPath = RenderingPath.Forward;
        //
        PlayerSettings.strippingLevel = StrippingLevel.Disabled;
        //
        PlayerSettings.stripUnusedMeshComponents = true;

        string[] SCENES = FindEnabledEditorScenes();


        BuildOptions options = BuildOptions.None;

        if (isDebug)
        {
            EditorUserBuildSettings.development     = true;
            EditorUserBuildSettings.connectProfiler = true;
            options |= BuildOptions.Development;
            options |= BuildOptions.ConnectWithProfiler;
        }
        else
        {
            EditorUserBuildSettings.development     = false;
            EditorUserBuildSettings.connectProfiler = false;
        }
        //开始Build场景,等待吧~
        GenericBuild(SCENES, target_dir + "/" + target_name, buildTarget, options);
        // 反定义宏
        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "");
    }