2011-07-29 7 views
2

Unity3D에 게임을 쓰고 있는데, 업데이트를 위해 서버를 점검 할 수있는 도구가 있는지 궁금해했습니다. 그렇다면 업데이트를 다운로드하여 설치하십시오. 나는 내 자신의 글을 쓰려고했지만, "다운로드 및 설치"부분에 붙어 있습니다. 나는 비슷한이Unity 3D 게임 패치 도구?

//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; 

} 
} 

답변

2

자신의 버전이 다음 낮은 경우, 내가가 http가 내 latestversion이있는 텍스트 파일을 다운로드해야, 그들은 옵션이 있습니다

내가 가진 무엇 설치자를 다운로드하십시오

Windows에서 사용하는 경우, 외부 프로세스 (파일을 업데이트하는 간단한 C# 양식 또는 설치 프로그램을 다운로드하는 프로그램이 완료 될 때까지 기다리는 경우)를 실행할 수 있습니다 [아마 화합 안에서도 가능하지만 이것은 내게 잘 맞는다.]

(웹 브라우저에서 최신 버전에 대한 링크를 지정하면 브라우저 나 기본 파일 다운로더가 프로그램을 다운로드 할 책임이 있으며 통신 오류를 처리 할 수 ​​있습니다) 완료되면 설치된 앱을 열어야합니다.

import System.Diagnostics; 

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