forked from Unity-Technologies/UnityRenderStreaming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Prepared template testing (Unity-Technologies#218)
* add patch file to replace "manifest.json" for testing template * add template unittest * exclude RenderStreaming test on MacOS * move the place where web application executable file * cp WebApp folder to resolve the path searching of the webserver * added method "ChangeGraphicsApi" * fixed build script to copy webserver * fixed build error * exclude macos platform from template test * test * test * add meta * test * test * remove trigger to stop template test * fixed warning * upgrade input system 1.0.0-preview.4 * fixed comment
- Loading branch information
Showing
17 changed files
with
189 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- manifest.json | ||
+++ manifest.json | ||
@@ -1,4 +1,11 @@ | ||
-{ | ||
+{ | ||
+ "scopedRegistries": [{ | ||
+ "name": "Internal registry", | ||
+ "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates", | ||
+ "scopes": [ | ||
+ "com.unity.webrtc" | ||
+ ] | ||
+ }], | ||
"dependencies": { | ||
"com.unity.2d.sprite": "1.0.0", | ||
"com.unity.2d.tilemap": "1.0.0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
Packages/com.unity.renderstreaming/Editor/WebAppDownloader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using UnityEditor; | ||
using UnityEditor.PackageManager; | ||
using UnityEditor.PackageManager.Requests; | ||
using UnityEngine; | ||
using System.Net; | ||
|
||
namespace Unity.RenderStreaming.Editor | ||
{ | ||
public static class WebAppDownloader | ||
{ | ||
const string URLRoot = "https://github.com/Unity-Technologies/UnityRenderStreaming"; | ||
const string LatestKnownVersion = "1.1.1-preview"; | ||
|
||
// TODO::fix release process of webserver runtime. | ||
const string PathWebAppForMac = "releases/download/{0}/webserver"; | ||
const string PathWebAppForLinux = "releases/download/{0}/webserver"; | ||
const string PathWebAppForWin = "releases/download/{0}/webserver.exe"; | ||
// | ||
|
||
const string PathWebAppSourceCode = "tree/release/{0}/WebApp"; | ||
const string PathWebAppDocumentation = "blob/release/{0}/Packages/com.unity.template.renderstreaming/Documentation~/en/webserver.md"; | ||
|
||
|
||
static string GetWebAppURL(string version) | ||
{ | ||
#if UNITY_EDITOR_WIN | ||
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForWin, version)); | ||
#elif UNITY_EDITOR_OSX | ||
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForMac, version)); | ||
#elif UNITY_EDITOR_LINUX | ||
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForLinux, version)); | ||
#endif | ||
return url; | ||
} | ||
|
||
public static string GetURLDocumentation(string version) | ||
{ | ||
var pattern = @"\d+.\d+.\d+"; | ||
var result = System.Text.RegularExpressions.Regex.Match(version, pattern); | ||
return System.IO.Path.Combine(URLRoot, string.Format(PathWebAppDocumentation, result.Value)); | ||
} | ||
|
||
public static string GetURLSourceCode(string version) | ||
{ | ||
var pattern = @"\d+.\d+.\d+"; | ||
var result = System.Text.RegularExpressions.Regex.Match(version, pattern); | ||
return System.IO.Path.Combine(URLRoot, string.Format(PathWebAppSourceCode, result.Value)); | ||
} | ||
|
||
public static void DownloadCurrentVersionWebApp(string dstPath) { | ||
GetPackageVersion("com.unity.renderstreaming", (version) => { | ||
DownloadWebApp(version, dstPath); | ||
}); | ||
} | ||
|
||
public static void DownloadWebApp(string version, string dstPath) | ||
{ | ||
var url = GetWebAppURL(version); | ||
var client = new WebClient(); | ||
var filename = System.IO.Path.GetFileName(url); | ||
var tmpFilePath = System.IO.Path.Combine(Application.temporaryCachePath, filename); | ||
|
||
client.DownloadFileCompleted += (sender, e) => | ||
{ | ||
EditorUtility.ClearProgressBar(); | ||
if (e.Error != null) { | ||
//Try downloading using the latest known version to work. | ||
if (version != LatestKnownVersion) { | ||
DownloadWebApp(LatestKnownVersion, dstPath); | ||
} else { | ||
Debug.LogError("Failed downloading webserver from: " + url + " . Error: " + e.Error.ToString()); | ||
} | ||
return; | ||
} | ||
|
||
if (!System.IO.File.Exists(tmpFilePath)) | ||
{ | ||
Debug.LogErrorFormat("Download failed. url:{0}", url); | ||
return; | ||
} | ||
|
||
if (string.IsNullOrEmpty(dstPath)) | ||
{ | ||
return; | ||
} | ||
dstPath = System.IO.Path.Combine(dstPath, filename); | ||
if (System.IO.File.Exists(dstPath)) | ||
{ | ||
System.IO.File.Delete(dstPath); | ||
} | ||
System.IO.File.Move(tmpFilePath, dstPath); | ||
EditorUtility.RevealInFinder(dstPath); | ||
}; | ||
client.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) => | ||
{ | ||
var progress = e.ProgressPercentage / 100f; | ||
if(EditorUtility.DisplayCancelableProgressBar("Downloading", url, progress)) | ||
{ | ||
client.CancelAsync(); | ||
} | ||
}; | ||
client.DownloadFileAsync(new System.Uri(url), tmpFilePath); | ||
|
||
} | ||
|
||
public static void GetPackageVersion(string packageName, System.Action<string> callback) | ||
{ | ||
// request package list to get package version | ||
RequestJobManager.CreateListRequest(false, true, (req) => | ||
{ | ||
var packageInfo = req.FindPackage(packageName); | ||
if (null == packageInfo) | ||
{ | ||
Debug.LogErrorFormat("Not found package \"{0}\"", packageName); | ||
return; | ||
} | ||
callback(packageInfo.version); | ||
}, null); | ||
} | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
Packages/com.unity.renderstreaming/Editor/WebAppDownloader.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.