Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity 3D游戏修补工具?_C#_Unity3d - Fatal编程技术网

C# Unity 3D游戏修补工具?

C# Unity 3D游戏修补工具?,c#,unity3d,C#,Unity3d,我正在用Unity3D编写一个游戏,我想知道是否有任何工具可用于检查服务器的更新,如果有,请下载并安装更新。 我一直试图写我自己的,但我被困在“下载和安装”部分 这就是我所拥有的: //Unity3D Patching Tool v0.1 using UnityEngine; using System.Collections; public class Patcher : MonoBehaviour { public const string VERSION = "1.0"; // The

我正在用Unity3D编写一个游戏,我想知道是否有任何工具可用于检查服务器的更新,如果有,请下载并安装更新。 我一直试图写我自己的,但我被困在“下载和安装”部分

这就是我所拥有的:

//Unity3D Patching Tool v0.1

using UnityEngine;
using System.Collections;

public class Patcher : MonoBehaviour {

public const string VERSION = "1.0"; // The version of the program that is running

private string patchUrl = "http://yoursite.com/patchversion.html"; //a website with the current build number

//a template to find the current build for windows
private const string UPDATE_WINDOWS_URL_TEMPLATE = "http://yoursite.com/release/build[[[BUILD_NUMBER]]].exe"; 

//a template to find the current build for mac
private const string UPDATE_MAC_URL_TEMPLATE = "http://yoursite.com/release/build[[[BUILD_NUMBER]]].app";  


IEnumerator Start() {

    /*
     * Check for patch
     */

    WWW patchwww = new WWW(patchUrl); //create new web connection to the build number site
    yield return patchwww;     // wait for download to finish
    if (patchwww.text == VERSION){    //check version
        Debug.Log("Up To Date");
    }
    else {
        Debug.Log("Download New Update");
        WWW downloadwww = new WWW(DownloadUpdate(patchwww.text));  // generates link to current build and downloads
        yield return downloadwww;
    }

}

private string DownloadUpdate(string version){
    string versionNumber = version.Replace(".", "");  //remove periods in version number
    string buildToDownload = "";

    /*
     * Check Platform and Set URL
     */
    switch (Application.platform){
    case RuntimePlatform.WindowsEditor:
    case RuntimePlatform.WindowsPlayer:
        Debug.Log("Windows " + Application.platform);
        buildToDownload = UPDATE_WINDOWS_URL_TEMPLATE.Replace("[[[BUILD_NUMBER]]]", versionNumber);
        break;
    case RuntimePlatform.OSXEditor:
    case RuntimePlatform.OSXPlayer:
        Debug.Log("Mac " + Application.platform);
        buildToDownload = UPDATE_MAC_URL_TEMPLATE.Replace("[[[BUILD_NUMBER]]]", versionNumber);
        break;
    }

    Debug.Log(buildToDownload);
    return buildToDownload;

}
}

我有类似的东西,我让http下载一个文本文件,其中包含最新版本,如果他们的版本低于这个,他们可以选择下载安装程序

如果你在windows上使用这个,你可以让unity运行一个外部进程(一个简单的c#表单,更新你的文件,或者下载一个安装程序,等待它完成,然后执行它)[可能在unity内部也可以,但这对我来说很好]

(您也可以将过程指向web浏览器,并链接到最新版本,这样浏览器或其默认文件下载程序将负责下载程序并处理通信错误)这样,他们将知道一旦安装完成,他们需要打开已安装的应用程序

import System.Diagnostics;

var path:String = "somewhere";
var foo:Process = new Process();
function Start() 
{   
    foo.StartInfo.FileName = "someprogram";
    foo.StartInfo.Arguments = path;
    foo.Start();
}