示例#1
0
    public static bool BuildVer(GamePlatformType pt)
    {
        if (Application.dataPath.IndexOf(Exporter.PUBLISH_DIR) == -1)
        {
            EditorUtility.DisplayDialog("错误", "只有发布目录才能发布版本!", "OK");
            return(false);
        }
        string           app_name    = APP_NAME;
        string           target_dir  = ExporterTools.GetRootDir(Exporter.VERSION_DIR);
        string           target_name = app_name + RuntimeInfo.GetExt(pt);
        BuildTargetGroup targetGroup;
        BuildTarget      buildTarget;

        PlayerSettings.bundleVersion = Exporter.CLIENT_VER.Replace('_', '.');
        switch (pt)
        {
        case GamePlatformType.Android:
            targetGroup = BuildTargetGroup.Android;
            buildTarget = BuildTarget.Android;
            PlayerSettings.applicationIdentifier = "com.leduo.buyu";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "BUYU_PUBLISH");
            break;

        case GamePlatformType.IOS:
            targetGroup = BuildTargetGroup.iOS;
            buildTarget = BuildTarget.iOS;
            PlayerSettings.applicationIdentifier = "com.52leduo.buyu";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "BUYU_PUBLISH");
            break;

        case GamePlatformType.Windows:
            targetGroup = BuildTargetGroup.Standalone;
            buildTarget = BuildTarget.StandaloneWindows;
            PlayerSettings.applicationIdentifier = "com.52leduo.buyu";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "BUYU_PUBLISH");
            break;

        default:
            Debug.Log("未知的发布类型");
            return(false);
        }
        string applicationPath = target_dir + "/" + target_name;

        if (File.Exists(applicationPath))
        {
            File.Delete(applicationPath);
        }

        bool bRet = GenericBuild(FindEnabledEditorScenes(), target_dir + "/" + target_name, buildTarget, BuildOptions.None);

        if (bRet)
        {
            EditorUtility.DisplayDialog("成功", "发布成功!", "OK");
            Debug.Log("发布成功!");
            return(true);
        }
        else
        {
            EditorUtility.DisplayDialog("失败", "发布失败!", "OK");
            Debug.Log("发布失败!");
            return(false);
        }
    }