Skip to content

Commit 428044c

Browse files
authored
refactor: Prepared template testing (#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
1 parent 4001722 commit 428044c

File tree

17 files changed

+189
-118
lines changed

17 files changed

+189
-118
lines changed

.editorconfig

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ indent_style = space
1313

1414
# Code files
1515
[*.{cs,csx,cpp,h,ts}]
16-
end_of_line = crlf
16+
end_of_line = lf
1717
indent_size = 4
18-
indent_style = space
1918
insert_final_newline = true
20-
charset = utf-8-bom
19+
charset = utf-8
2120
trim_trailing_whitespace = true
2221

2322
###############################

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ MigrationBackup/
341341
[Oo]bj/
342342
[Bb]uild/
343343

344-
# Exclude Documentation folder
344+
# Exclude folder
345345
!Documentation~
346+
!BuildScripts~
346347

347348
# Exclude webrtc source
348349
Plugin/webrtc

.yamato/upm-ci-publish-github-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ publish_github_release:
1414
- npm install github-release-cli -g
1515
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "upm-ci~/packages/com.unity.renderstreaming-%GIT_TAG%.tgz"
1616
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "upm-ci~/packages/com.unity.template.renderstreaming-%GIT_TAG%.tgz"
17-
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "Assets/bin~/webserver"
18-
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "Assets/bin~/webserver.exe"
17+
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "WebApp/bin~/webserver"
18+
- github-release upload -o "Unity-Technologies" -r "UnityRenderStreaming" -t "%GIT_TAG%" -n "%GIT_TAG%" "WebApp/bin~/webserver.exe"
1919
triggers:
2020
tags:
2121
only:

.yamato/upm-ci-template.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ test_{{ platform.name }}_{{ editor.version }}:
3434
image: {{ platform.image }}
3535
flavor: {{ platform.flavor}}
3636
commands:
37+
- patch -u Packages/manifest.json < BuildScripts~/add_internal_registry_manifest.patch
38+
{% if platform.name == "win" %}
39+
- mkdir upm-ci~\templates\ProjectData~\WebApp
40+
- xcopy WebApp upm-ci~\templates\ProjectData~\WebApp /s/e/i
41+
{% else %}
42+
- cp -r WebApp upm-ci~/templates/ProjectData~/
43+
{% endif %}
3744
- npm install upm-ci-utils -g --registry https://api.bintray.com/npm/unity/unity-npm
3845
- upm-ci template test -u {{ editor.version }}
39-
# TODO:: `upm-ci template test` is failed using the package on the internal registry.
46+
# TODO:: `upm-ci template test` is failed using the package on the internal registry.
4047
# triggers:
4148
# branches:
4249
# only:
@@ -49,6 +56,8 @@ test_{{ platform.name }}_{{ editor.version }}:
4956
- "upm-ci~/test-results/**/*"
5057
dependencies:
5158
- .yamato/upm-ci-template.yml#pack
59+
- .yamato/upm-ci-webapp.yml#pack_{{ platform.name }}
60+
- .yamato/upm-ci-webapp.yml#test_{{ platform.name }}
5261
{% endfor %}
5362
{% endfor %}
5463

.yamato/upm-ci-webapp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pack_{{ platform.name }}:
3333
artifacts:
3434
packages:
3535
paths:
36-
- "Assets/bin~/**/*"
36+
- "WebApp/bin~/**/*"
3737
{% endfor %}
3838

3939
{% for platform in platforms %}

Assets/RenderPipeline/HDRP/Scripts/HDRPRenderTextureBlitter.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using UnityEngine;
22

33
#if UNITY_2019_1 || UNITY_2019_2 //HDRP 5.x, 6.x
4-
using UnityEngine.Experimental.Rendering.HDPipeline;
4+
using UnityEngine.Experimental.Rendering.HDPipeline;
55
#else //HDRP 7.x and above
66
using UnityEngine.Rendering.HighDefinition;
77
#endif
88

9-
[RequireComponent(typeof(Camera)), RequireComponent(typeof(HDAdditionalCameraData))]
9+
[RequireComponent(typeof(Camera), typeof(HDAdditionalCameraData))]
1010
public class HDRPRenderTextureBlitter : MonoBehaviour
1111
{
1212
[SerializeField] Camera m_rtCamera = null;
@@ -18,9 +18,9 @@ private void OnEnable() {
1818
m_cam = GetComponent<Camera>();
1919
m_hdData = GetComponent<HDAdditionalCameraData>();
2020

21-
//Render nothing
21+
//Render nothing
2222
m_cam.clearFlags = CameraClearFlags.Nothing;
23-
m_cam.cullingMask = 0;
23+
m_cam.cullingMask = 0;
2424
m_hdData.fullscreenPassthrough = true;
2525
m_hdData.customRender += BlitRenderStreamingRT;
2626
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- manifest.json
2+
+++ manifest.json
3+
@@ -1,4 +1,11 @@
4+
-{
5+
+{
6+
+ "scopedRegistries": [{
7+
+ "name": "Internal registry",
8+
+ "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates",
9+
+ "scopes": [
10+
+ "com.unity.webrtc"
11+
+ ]
12+
+ }],
13+
"dependencies": {
14+
"com.unity.2d.sprite": "1.0.0",
15+
"com.unity.2d.tilemap": "1.0.0",

Packages/com.unity.renderstreaming/Editor/RenderStreamingMenu.cs

+10-97
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEditor;
1+
using UnityEditor;
22
using UnityEditor.PackageManager;
33
using UnityEditor.PackageManager.Requests;
44
using UnityEngine;
@@ -8,115 +8,28 @@ namespace Unity.RenderStreaming.Editor
88
{
99
public static class RenderStreamingMenu
1010
{
11-
const string URLRoot = "https://github.com/Unity-Technologies/UnityRenderStreaming";
12-
const string LatestKnownVersion = "1.1.1-preview";
13-
14-
// TODO::fix release process of webserver runtime.
15-
const string PathWebAppForMac = "releases/download/{0}/webserver";
16-
const string PathWebAppForLinux = "releases/download/{0}/webserver";
17-
const string PathWebAppForWin = "releases/download/{0}/webserver.exe";
18-
//
19-
20-
const string PathWebAppSourceCode = "tree/release/{0}/WebApp";
21-
const string PathWebAppDocumentation = "blob/release/{0}/Packages/com.unity.template.renderstreaming/Documentation~/en/webserver.md";
22-
2311
[MenuItem("Edit/Render Streaming/Download web app")]
24-
static void DownloadWebApp() {
25-
RequestPackageVersion("com.unity.renderstreaming", (version) => { DownloadWebApp(version); });
26-
}
27-
28-
static void DownloadWebApp(string version)
29-
30-
{
31-
#if UNITY_EDITOR_WIN
32-
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForWin, version));
33-
#elif UNITY_EDITOR_OSX
34-
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForMac, version));
35-
#elif UNITY_EDITOR_LINUX
36-
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForLinux, version));
37-
#endif
38-
var client = new WebClient();
39-
var filename = System.IO.Path.GetFileName(url);
40-
var tmpFilePath = System.IO.Path.Combine(Application.temporaryCachePath, filename);
41-
42-
client.DownloadFileCompleted += (object sender, System.ComponentModel.AsyncCompletedEventArgs e) =>
43-
{
44-
EditorUtility.ClearProgressBar();
45-
if (e.Error != null) {
46-
//Try downloading using the latest known version to work.
47-
if (version != LatestKnownVersion) {
48-
DownloadWebApp(LatestKnownVersion);
49-
} else {
50-
Debug.LogError("Failed downloading webserver from: " + url + " . Error: " + e.Error.ToString());
51-
}
52-
return;
53-
}
54-
55-
if (!System.IO.File.Exists(tmpFilePath))
56-
{
57-
Debug.LogErrorFormat("Download failed. url:{0}", url);
58-
return;
59-
}
60-
12+
static void DownloadWebAppFromMenu() {
13+
WebAppDownloader.GetPackageVersion("com.unity.renderstreaming", (version) => {
6114
var dstPath = EditorUtility.OpenFolderPanel("Select download folder", "", "");
62-
if (string.IsNullOrEmpty(dstPath))
63-
{
64-
return;
65-
}
66-
dstPath = System.IO.Path.Combine(dstPath, filename);
67-
if (System.IO.File.Exists(dstPath))
68-
{
69-
System.IO.File.Delete(dstPath);
70-
}
71-
System.IO.File.Move(tmpFilePath, dstPath);
72-
EditorUtility.RevealInFinder(dstPath);
73-
};
74-
client.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
75-
{
76-
var progress = e.ProgressPercentage / 100f;
77-
if(EditorUtility.DisplayCancelableProgressBar("Downloading", url, progress))
78-
{
79-
client.CancelAsync();
80-
}
81-
};
82-
client.DownloadFileAsync(new System.Uri(url), tmpFilePath);
83-
84-
}
85-
86-
static void RequestPackageVersion(string packageName, System.Action<string> callback)
87-
{
88-
// request package list to get package version
89-
RequestJobManager.CreateListRequest(false, true, (req) =>
90-
{
91-
var packageInfo = req.FindPackage(packageName);
92-
if (null == packageInfo)
93-
{
94-
Debug.LogErrorFormat("Not found package \"{0}\"", packageName);
95-
return;
96-
}
97-
callback(packageInfo.version);
98-
}, null);
15+
WebAppDownloader.DownloadWebApp(version, dstPath);
16+
});
9917
}
10018

10119
[MenuItem("Edit/Render Streaming/Show web app documentation")]
10220
static void ShowWepAppDocumentation()
10321
{
104-
RequestPackageVersion("com.unity.renderstreaming", (version) =>
105-
{
106-
var pattern = @"\d+.\d+.\d+";
107-
var result = System.Text.RegularExpressions.Regex.Match(version, pattern);
108-
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppDocumentation, result.Value));
22+
WebAppDownloader.GetPackageVersion("com.unity.renderstreaming", (version) => {
23+
var url = WebAppDownloader.GetURLDocumentation(version);
10924
Application.OpenURL(url);
11025
});
11126
}
27+
11228
[MenuItem("Edit/Render Streaming/Show web app source code")]
11329
static void ShowWepAppSourceCode()
11430
{
115-
RequestPackageVersion("com.unity.renderstreaming", (version) =>
116-
{
117-
var pattern = @"\d+.\d+.\d+";
118-
var result = System.Text.RegularExpressions.Regex.Match(version, pattern);
119-
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppSourceCode, result.Value));
31+
WebAppDownloader.GetPackageVersion("com.unity.renderstreaming", (version) => {
32+
var url = WebAppDownloader.GetURLSourceCode(version);
12033
Application.OpenURL(url);
12134
});
12235
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using UnityEditor;
2+
using UnityEditor.PackageManager;
3+
using UnityEditor.PackageManager.Requests;
4+
using UnityEngine;
5+
using System.Net;
6+
7+
namespace Unity.RenderStreaming.Editor
8+
{
9+
public static class WebAppDownloader
10+
{
11+
const string URLRoot = "https://github.com/Unity-Technologies/UnityRenderStreaming";
12+
const string LatestKnownVersion = "1.1.1-preview";
13+
14+
// TODO::fix release process of webserver runtime.
15+
const string PathWebAppForMac = "releases/download/{0}/webserver";
16+
const string PathWebAppForLinux = "releases/download/{0}/webserver";
17+
const string PathWebAppForWin = "releases/download/{0}/webserver.exe";
18+
//
19+
20+
const string PathWebAppSourceCode = "tree/release/{0}/WebApp";
21+
const string PathWebAppDocumentation = "blob/release/{0}/Packages/com.unity.template.renderstreaming/Documentation~/en/webserver.md";
22+
23+
24+
static string GetWebAppURL(string version)
25+
{
26+
#if UNITY_EDITOR_WIN
27+
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForWin, version));
28+
#elif UNITY_EDITOR_OSX
29+
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForMac, version));
30+
#elif UNITY_EDITOR_LINUX
31+
var url = System.IO.Path.Combine(URLRoot, string.Format(PathWebAppForLinux, version));
32+
#endif
33+
return url;
34+
}
35+
36+
public static string GetURLDocumentation(string version)
37+
{
38+
var pattern = @"\d+.\d+.\d+";
39+
var result = System.Text.RegularExpressions.Regex.Match(version, pattern);
40+
return System.IO.Path.Combine(URLRoot, string.Format(PathWebAppDocumentation, result.Value));
41+
}
42+
43+
public static string GetURLSourceCode(string version)
44+
{
45+
var pattern = @"\d+.\d+.\d+";
46+
var result = System.Text.RegularExpressions.Regex.Match(version, pattern);
47+
return System.IO.Path.Combine(URLRoot, string.Format(PathWebAppSourceCode, result.Value));
48+
}
49+
50+
public static void DownloadCurrentVersionWebApp(string dstPath) {
51+
GetPackageVersion("com.unity.renderstreaming", (version) => {
52+
DownloadWebApp(version, dstPath);
53+
});
54+
}
55+
56+
public static void DownloadWebApp(string version, string dstPath)
57+
{
58+
var url = GetWebAppURL(version);
59+
var client = new WebClient();
60+
var filename = System.IO.Path.GetFileName(url);
61+
var tmpFilePath = System.IO.Path.Combine(Application.temporaryCachePath, filename);
62+
63+
client.DownloadFileCompleted += (sender, e) =>
64+
{
65+
EditorUtility.ClearProgressBar();
66+
if (e.Error != null) {
67+
//Try downloading using the latest known version to work.
68+
if (version != LatestKnownVersion) {
69+
DownloadWebApp(LatestKnownVersion, dstPath);
70+
} else {
71+
Debug.LogError("Failed downloading webserver from: " + url + " . Error: " + e.Error.ToString());
72+
}
73+
return;
74+
}
75+
76+
if (!System.IO.File.Exists(tmpFilePath))
77+
{
78+
Debug.LogErrorFormat("Download failed. url:{0}", url);
79+
return;
80+
}
81+
82+
if (string.IsNullOrEmpty(dstPath))
83+
{
84+
return;
85+
}
86+
dstPath = System.IO.Path.Combine(dstPath, filename);
87+
if (System.IO.File.Exists(dstPath))
88+
{
89+
System.IO.File.Delete(dstPath);
90+
}
91+
System.IO.File.Move(tmpFilePath, dstPath);
92+
EditorUtility.RevealInFinder(dstPath);
93+
};
94+
client.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
95+
{
96+
var progress = e.ProgressPercentage / 100f;
97+
if(EditorUtility.DisplayCancelableProgressBar("Downloading", url, progress))
98+
{
99+
client.CancelAsync();
100+
}
101+
};
102+
client.DownloadFileAsync(new System.Uri(url), tmpFilePath);
103+
104+
}
105+
106+
public static void GetPackageVersion(string packageName, System.Action<string> callback)
107+
{
108+
// request package list to get package version
109+
RequestJobManager.CreateListRequest(false, true, (req) =>
110+
{
111+
var packageInfo = req.FindPackage(packageName);
112+
if (null == packageInfo)
113+
{
114+
Debug.LogErrorFormat("Not found package \"{0}\"", packageName);
115+
return;
116+
}
117+
callback(packageInfo.version);
118+
}, null);
119+
}
120+
}
121+
}
122+

Packages/com.unity.renderstreaming/Editor/WebAppDownloader.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.renderstreaming/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "This is HDRP sample scene project integrated with Unity Render Streaming technology.\n\nAlong with its signaling web server, you could play around the scene in any webrtc supported web browser.",
77
"dependencies": {
88
"com.unity.webrtc": "1.1.0-preview.2",
9-
"com.unity.inputsystem": "0.9.6-preview"
9+
"com.unity.inputsystem": "1.0.0-preview.4"
1010
},
1111
"samples": [ {
1212
"displayName": "HDRP",

Packages/com.unity.template.renderstreaming/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.unity.template.renderstreaming",
3-
"displayName": "Unity Render Streaming Template",
3+
"displayName": "Render Streaming Template",
44
"version": "1.1.1-preview",
55
"type": "template",
66
"unity": "2019.3",

0 commit comments

Comments
 (0)