Skip to content

Commit d09d21f

Browse files
author
davidkline-ms
committed
add support for importing scenesystem scenes, fix minor error
1 parent 93d8d1c commit d09d21f

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

Assets/MRTK/packagetemplate.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"Providers*",
3232
"SDK*",
3333
"Services*",
34-
"package.json.meta"
35-
]
34+
"package.json.meta",
35+
"Samples~"
36+
],
37+
%samples%
3638
}

scripts/packaging/createupmpackages.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ foreach ($entry in $packages.GetEnumerator()) {
112112

113113
$samplesFolder = "$packagePath/Samples~"
114114

115-
if ($packageName -eq "examples") {
115+
if ($packageName -eq "foundation") {
116+
# The foundation package contains files that are requried to be copied into the Assets folder to be used.
117+
# In order to perform the necessary preparaton, without overly complicating this script, we will use a
118+
# helper script to prepare the folder.
119+
Start-Process -FilePath "$PSHOME/powershell.exe" -ArgumentList "$scriptPath/extensionsfolderpreupm.ps1 -PackageRoot $packagePath" -NoNewWindow -Wait
120+
}
121+
elseif ($packageName -eq "examples") {
116122
# The examples folder is a collection of sample projects. In order to perform the necessary
117123
# preparaton, without overly complicating this script, we will use a helper script to prepare
118124
# the folder.
@@ -127,7 +133,7 @@ foreach ($entry in $packages.GetEnumerator()) {
127133
else {
128134
# Some other folders have localized examples that need to be prepared. Intentionally skip the foundation as those samples
129135
$exampleFolder = "$packagePath/Examples"
130-
if (($PackageName -ne "foundation") -and ($PackageName -ne "foundation.xr2018") -and (Test-Path -Path $exampleFolder)) {
136+
if (($PackageName -ne "foundation") -and (Test-Path -Path $exampleFolder)) {
131137
# Ensure the required samples exists
132138
if (-not (Test-Path -Path $samplesFolder)) {
133139
New-Item $samplesFolder -ItemType Directory | Out-Null

scripts/packaging/extensionsfolderpreupm.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.DESCRIPTION
55
Prepares the MRTK\Extensions folder for UPM packaging.
66
.PARAMETER PackageRoot
7-
The root folder containing the examples package contents. If not specified, the current folder is presumed.
7+
The root folder containing the extensions package contents. If not specified, the current folder is presumed.
88
#>
99
param(
1010
[string]$PackageRoot
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<#
2+
.SYNOPSIS
3+
Prepares the MRTK foundation for UPM packaging.
4+
.DESCRIPTION
5+
Prepares the MRTK foundation for UPM packaging.
6+
.PARAMETER PackageRoot
7+
The root folder containing the foundation package contents. If not specified, the current folder is presumed.
8+
#>
9+
param(
10+
[string]$PackageRoot
11+
)
12+
13+
if (-not $PackageRoot) {
14+
throw "Missing required parameter: -PackageRoot."
15+
}
16+
17+
# Ensure the required folder exists
18+
$samplesFolder = "$PackageRoot\Samples~"
19+
if (-not (Test-Path -Path $samplesFolder)) {
20+
New-Item $samplesFolder -ItemType Directory | Out-Null
21+
}
22+
23+
# Copy the scene system's default scenes to Samples~/SceneSystemScenes
24+
Copy-Item -Path "$PackageRoot/Services/SceneSystem/Scenes" -Destination "$samplesFolder/SceneSystemScenes" -Recurse -Force
25+
26+
# Create the samples data for the package.json file
27+
$samples = "`"samples`": ["
28+
$samples = $samples + "`n {`n"
29+
$samples = $samples + " `"displayName`": `"$Scene System Default Scenes`",`n"
30+
$samples = $samples + " `"description`": `"Default scenes used by the MRTK Scene System`",`n"
31+
$samples = $samples + " `"path`": `"Samples~/SceneSystemScenes`"`n"
32+
$samples = $samples + " }"
33+
$samples = $samples + "`n ]"
34+
35+
# Update the project.json file to specify the samples contanined in the package
36+
$packageJsonPath = "$PackageRoot/package.json"
37+
$packageJson = [System.IO.File]::ReadAllText($packageJsonPath)
38+
$packageJson = ($packageJson -replace "%samples%", $samples)
39+
[System.IO.File]::WriteAllText($packageJsonPath, $packageJson)

0 commit comments

Comments
 (0)