unity3d 补丁和运行“与现有文件冲突”错误统一

nkhmeac6  于 2023-11-22  发布在  其他
关注(0)|答案(1)|浏览(201)

我无法在Unity中为我的三星Galaxy A70 Android手机打补丁并运行。我收到错误:
目标路径<path>与现有文件夹冲突。请在重试操作之前删除<same path>
它只发生在一个特定的项目中。我唯一真正发现的是项目名称中的无效字符,我删除了所有这些字符,但它仍然不起作用。

64jmpszr

64jmpszr1#

1.在资源中创建“编辑器”文件夹。
1.在内部创建新脚本并将其命名为“Build255.cs”。
1.打开脚本,然后添加此代码。

using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Reporting;
using System.IO;

public class Build255 : MonoBehaviour
{
    [MenuItem("Build/Build Hafez255.ir  %b")]
    public static void MyBuild()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        //** Custom Open Window Panel to Get locationPath and productName
        //BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions(buildPlayerOptions);

        string path = Path.Join(buildPlayerOptions.locationPathName, Application.productName);
        if (File.Exists(path + "_BurstDebugInformation_DoNotShip"))
            File.Delete(path + "_BurstDebugInformation_DoNotShip");
        if (File.Exists(path+".apk"))
            File.Delete(path+".apk");

        buildPlayerOptions.locationPathName = path+".apk";
        //** Custom BuildTarget (Android, ios, Windows, Linux ,... )
        buildPlayerOptions.target = BuildTarget.Android;
        buildPlayerOptions.options = BuildOptions.None;
        buildPlayerOptions.options = BuildOptions.AutoRunPlayer;
        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
            Debug.Log("Build succeeded: " + summary.totalSize + " bytes");

        if (summary.result == BuildResult.Failed)
            Debug.Log("Build failed");
    }
}

字符串

相关问题