Skip to content

Commit d9094a4

Browse files
committed
built
1 parent fa206d5 commit d9094a4

29 files changed

Lines changed: 660 additions & 290 deletions

File tree

SvelteKit/BackSpace/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"unity:ci": "tsx scripts/unity-automation.js ci",
4141
"unity:logs": "tsx scripts/unity-automation.js check-logs",
4242
"unity:env": "node scripts/unity-env.js --verbose",
43-
"unity:env:shell": "node scripts/unity-env.js --shell > .unity-env && echo 'Environment saved to .unity-env'",
43+
"unity:env:shell": "node scripts/unity-env.js --shell > .unity-env",
4444
"unity:discover": "node scripts/unity-env.js --verbose",
4545
"unity:list-versions": "tsx scripts/unity-automation.js list-versions",
4646
"unity:generate-schemas": "tsx scripts/unity-automation.js generate-schemas",

SvelteKit/BackSpace/scripts/unity-automation.js

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if (!command) {
104104
await runUnityCommand('-batchmode -projectPath . -executeMethod Build.BuildWebGL_Prod -quit -logFile -', unityEnv);
105105
break;
106106
case 'test':
107-
await runUnityCommand('-batchmode -projectPath . -runTests -testResults ./test-results.xml -quit -logFile -', unityEnv);
107+
await serveWebGLBuild();
108108
break;
109109
case 'ci':
110110
// CI script likely runs unity-env itself, so just execute
@@ -380,41 +380,6 @@ exit $EXIT_CODE`;
380380
async function createUnityFiles(unityProjectPath) {
381381
// Create run-unity.sh first
382382
await createUnityExecutableScript(unityProjectPath);
383-
384-
// Create ci-build.sh for CI pipeline if needed
385-
const ciBuildScript = path.join(unityProjectPath, 'ci-build.sh');
386-
if (!fs.existsSync(ciBuildScript)) {
387-
const ciBuildContent = `#!/bin/bash
388-
# CI Build Script for Unity Project
389-
# This script is used by the CI pipeline to build the Unity project
390-
391-
# Get the directory where this script is located
392-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
393-
394-
# Source unity environment variables if available
395-
if [ -f "$SCRIPT_DIR/../SvelteKit/BackSpace/.unity-env" ]; then
396-
source "$SCRIPT_DIR/../SvelteKit/BackSpace/.unity-env"
397-
else
398-
# Set up environment variables
399-
cd "$SCRIPT_DIR/../SvelteKit/BackSpace"
400-
source <(node scripts/unity-env.js --shell)
401-
cd "$SCRIPT_DIR"
402-
fi
403-
404-
# Run Unity build
405-
echo "Running Unity build..."
406-
"$SCRIPT_DIR/run-unity.sh" -batchmode -projectPath . -executeMethod Build.BuildProd -quit
407-
408-
exit $?`;
409-
410-
try {
411-
fs.writeFileSync(ciBuildScript, ciBuildContent, { mode: 0o755 });
412-
console.log(chalk.green(`Created CI build script at: ${ciBuildScript}`));
413-
} catch (error) {
414-
console.error(chalk.red(`Error creating CI script: ${error.message}`));
415-
// Not a fatal error, just continue
416-
}
417-
}
418383
}
419384

420385
/**
@@ -446,6 +411,75 @@ async function listUnityVersions() {
446411
}
447412
}
448413

414+
/**
415+
* Starts a local HTTP server to serve the latest WebGL build for manual testing.
416+
*/
417+
async function serveWebGLBuild() {
418+
console.log(chalk.blue('Serving latest WebGL build for manual testing...'));
419+
// Correctly resolve the path from the script directory up 3 levels to project root, then down
420+
const buildDir = path.resolve(__dirname, '../../../Unity/CraftSpace/Builds/SpaceCraft');
421+
422+
if (!fs.existsSync(buildDir)) {
423+
console.error(chalk.red(`Build directory not found: ${buildDir}`));
424+
console.error(chalk.yellow('Please run a WebGL build first (e.g., npm run unity:build-webgl).'));
425+
process.exit(1);
426+
}
427+
428+
console.log(chalk.green(`Attempting to serve build from: ${buildDir}`));
429+
console.log(chalk.cyan('Starting local web server. Press Ctrl+C to stop.'));
430+
console.log(chalk.cyan('Attempting to open browser at http://localhost:8080 ...'));
431+
432+
// Use child_process to run npx http-server in the background
433+
const serverCommand = `npx http-server . -p 8080 -o`;
434+
console.log(chalk.gray(`Executing: ${serverCommand} in ${buildDir}`));
435+
436+
const serverProcess = exec(serverCommand, { cwd: buildDir }, (error, stdout, stderr) => {
437+
if (error) {
438+
console.error(chalk.red(`Server Error: ${error.message}`));
439+
if (error.message.includes('not found') || error.message.includes('npx' + ' is not recognized')) {
440+
console.error(chalk.yellow('Suggestion: Ensure Node.js and npm are installed correctly and in your PATH. You might need to install http-server globally (`npm install -g http-server`) if npx fails.'));
441+
}
442+
// Don't exit the main script here, just log the server error
443+
return;
444+
}
445+
if (stderr) {
446+
// http-server often prints startup info to stderr, filter known messages
447+
const knownMessages = ['Starting up http-server', 'Available on:'];
448+
if (!knownMessages.some(msg => stderr.includes(msg))) {
449+
console.error(chalk.red(`Server Stderr: ${stderr}`));
450+
}
451+
return;
452+
}
453+
// Log stdout only if it contains something unexpected
454+
if (stdout && stdout.trim().length > 0) {
455+
console.log(`Server Stdout: ${stdout}`);
456+
}
457+
});
458+
459+
serverProcess.on('exit', (code) => {
460+
// Only log unexpected exits
461+
if (code !== null && code !== 0) {
462+
console.log(chalk.yellow(`Server process exited unexpectedly with code ${code}`));
463+
} else {
464+
console.log(chalk.yellow(`Server process stopped.`));
465+
}
466+
// Allow the main script to exit naturally when the server stops or is killed
467+
process.exit(code ?? 0);
468+
});
469+
470+
// Graceful shutdown handling
471+
process.on('SIGINT', () => {
472+
console.log(chalk.yellow('\nCaught interrupt signal (Ctrl+C). Shutting down server...'));
473+
serverProcess.kill('SIGINT');
474+
// Allow time for server process to exit before node script exits
475+
setTimeout(() => process.exit(0), 500);
476+
});
477+
478+
// Keep the script alive until the server is killed or exits
479+
// The promise is no longer needed because process.on('SIGINT') and serverProcess.on('exit') handle termination.
480+
// await new Promise(() => {});
481+
}
482+
449483
/**
450484
* Show help information
451485
*/
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: ItemSelectionMaterial
11+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12+
m_Parent: {fileID: 0}
13+
m_ModifiedSerializedProperties: 0
14+
m_ValidKeywords:
15+
- _ALPHAPREMULTIPLY_ON
16+
m_InvalidKeywords:
17+
- _SPECULAR_SETUP
18+
- _SURFACE_TYPE_TRANSPARENT
19+
m_LightmapFlags: 4
20+
m_EnableInstancingVariants: 0
21+
m_DoubleSidedGI: 0
22+
m_CustomRenderQueue: 3000
23+
stringTagMap:
24+
RenderType: Transparent
25+
disabledShaderPasses:
26+
- MOTIONVECTORS
27+
- DepthOnly
28+
- SHADOWCASTER
29+
m_LockedProperties: _UVSec
30+
m_SavedProperties:
31+
serializedVersion: 3
32+
m_TexEnvs:
33+
- _BaseMap:
34+
m_Texture: {fileID: 0}
35+
m_Scale: {x: 1, y: 1}
36+
m_Offset: {x: 0, y: 0}
37+
- _BumpMap:
38+
m_Texture: {fileID: 0}
39+
m_Scale: {x: 1, y: 1}
40+
m_Offset: {x: 0, y: 0}
41+
- _DetailAlbedoMap:
42+
m_Texture: {fileID: 0}
43+
m_Scale: {x: 1, y: 1}
44+
m_Offset: {x: 0, y: 0}
45+
- _DetailMask:
46+
m_Texture: {fileID: 0}
47+
m_Scale: {x: 1, y: 1}
48+
m_Offset: {x: 0, y: 0}
49+
- _DetailNormalMap:
50+
m_Texture: {fileID: 0}
51+
m_Scale: {x: 1, y: 1}
52+
m_Offset: {x: 0, y: 0}
53+
- _EmissionMap:
54+
m_Texture: {fileID: 0}
55+
m_Scale: {x: 1, y: 1}
56+
m_Offset: {x: 0, y: 0}
57+
- _MainTex:
58+
m_Texture: {fileID: 0}
59+
m_Scale: {x: 1, y: 1}
60+
m_Offset: {x: 0, y: 0}
61+
- _MetallicGlossMap:
62+
m_Texture: {fileID: 0}
63+
m_Scale: {x: 1, y: 1}
64+
m_Offset: {x: 0, y: 0}
65+
- _OcclusionMap:
66+
m_Texture: {fileID: 0}
67+
m_Scale: {x: 1, y: 1}
68+
m_Offset: {x: 0, y: 0}
69+
- _ParallaxMap:
70+
m_Texture: {fileID: 0}
71+
m_Scale: {x: 1, y: 1}
72+
m_Offset: {x: 0, y: 0}
73+
- _SpecGlossMap:
74+
m_Texture: {fileID: 0}
75+
m_Scale: {x: 1, y: 1}
76+
m_Offset: {x: 0, y: 0}
77+
- unity_Lightmaps:
78+
m_Texture: {fileID: 0}
79+
m_Scale: {x: 1, y: 1}
80+
m_Offset: {x: 0, y: 0}
81+
- unity_LightmapsInd:
82+
m_Texture: {fileID: 0}
83+
m_Scale: {x: 1, y: 1}
84+
m_Offset: {x: 0, y: 0}
85+
- unity_ShadowMasks:
86+
m_Texture: {fileID: 0}
87+
m_Scale: {x: 1, y: 1}
88+
m_Offset: {x: 0, y: 0}
89+
m_Ints: []
90+
m_Floats:
91+
- _AddPrecomputedVelocity: 0
92+
- _AlphaClip: 0
93+
- _AlphaToMask: 0
94+
- _Blend: 0
95+
- _BlendModePreserveSpecular: 1
96+
- _BumpScale: 1
97+
- _ClearCoatMask: 0
98+
- _ClearCoatSmoothness: 0
99+
- _Cull: 2
100+
- _Cutoff: 0.5
101+
- _DetailAlbedoMapScale: 1
102+
- _DetailNormalMapScale: 1
103+
- _DstBlend: 10
104+
- _DstBlendAlpha: 10
105+
- _EnvironmentReflections: 1
106+
- _GlossMapScale: 1
107+
- _Glossiness: 0.5
108+
- _GlossyReflections: 1
109+
- _Metallic: 0
110+
- _Mode: 3
111+
- _OcclusionStrength: 1
112+
- _Parallax: 0.02
113+
- _QueueOffset: 0
114+
- _ReceiveShadows: 1
115+
- _Smoothness: 0.709
116+
- _SmoothnessTextureChannel: 0
117+
- _SpecularHighlights: 1
118+
- _SrcBlend: 1
119+
- _SrcBlendAlpha: 1
120+
- _Surface: 1
121+
- _UVSec: 0
122+
- _WorkflowMode: 0
123+
- _ZWrite: 0
124+
m_Colors:
125+
- _BaseColor: {r: 0.5660378, g: 0.7073696, b: 0.754717, a: 0.20392157}
126+
- _Color: {r: 0.048685256, g: 0.99215686, b: 0, a: 0.18431373}
127+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
128+
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
129+
m_BuildTextureStacks: []
130+
m_AllowLocking: 1

Unity/CraftSpace/Assets/Settings/Build Profiles/WebGLBuildProfile.asset.meta renamed to Unity/CraftSpace/Assets/Content/Materials/ItemSelectionMaterial.mat.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity/CraftSpace/Assets/Content/Prefabs/CollectionViewPrefab.prefab

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ MonoBehaviour:
4646
m_Script: {fileID: 11500000, guid: b440ce1c8df554c05a0d05dd80a45ded, type: 3}
4747
m_Name:
4848
m_EditorClassIdentifier:
49-
_model: {fileID: 0}
50-
_itemContainer: {fileID: 464012571170886491}
51-
_itemViewsContainerPrefab: {fileID: 8545906332215059116, guid: 354510ea2cae34424a027bcd990180fc, type: 3}
52-
_itemViewPrefabs: []
53-
_createItemViewsAutomatically: 1
49+
model: {fileID: 0}
50+
itemContainer: {fileID: 0}
51+
itemViewsContainerPrefab: {fileID: 8545906332215059116, guid: 354510ea2cae34424a027bcd990180fc, type: 3}
5452
--- !u!114 &4539241664711781046
5553
MonoBehaviour:
5654
m_ObjectHideFlags: 0
@@ -63,13 +61,16 @@ MonoBehaviour:
6361
m_Script: {fileID: 11500000, guid: e6fc65b3323014e13b0e9c6be3b88bc9, type: 3}
6462
m_Name:
6563
m_EditorClassIdentifier:
66-
itemViewContainerPrefab: {fileID: 8545906332215059116, guid: 354510ea2cae34424a027bcd990180fc, type: 3}
67-
itemViewPrefab: {fileID: 4331697567644932370, guid: 8df9728067b394ca6a2e8b4bddb094cb, type: 3}
68-
_cellSize: 1
69-
_spacing: 0.1
70-
_columns: 4
71-
_autoUpdateLayout: 1
72-
_centerHorizontally: 1
64+
cellSize: 1
65+
spacingHorizontal: 0.2
66+
spacingVertical: 0.8
67+
columns: 4
68+
autoUpdateLayout: 1
69+
centerHorizontally: 1
70+
itemTransforms: []
71+
collection: {fileID: 0}
72+
collectionView: {fileID: 0}
73+
initialized: 0
7374
--- !u!1 &8955703354072507967
7475
GameObject:
7576
m_ObjectHideFlags: 0

Unity/CraftSpace/Assets/Content/Prefabs/ItemViewPrefab.prefab

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,19 @@ MonoBehaviour:
4646
m_Script: {fileID: 11500000, guid: 1e979578905b44d7bb14f29d12f32717, type: 3}
4747
m_Name:
4848
m_EditorClassIdentifier:
49-
_model: {fileID: 0}
50-
_autoInitializeRenderers: 0
51-
_closeDistance: 5
52-
_mediumDistance: 20
53-
_farDistance: 200
54-
_itemLabel: {fileID: 7599011510456966153}
55-
_itemWidth: 1.2
56-
_itemHeight: 1
57-
_loadingMaterial: {fileID: 2100000, guid: 0e29a213f7529450cb3eb75e25f24c03, type: 2}
58-
_highlightMaterial: {fileID: 2100000, guid: 7e59c25f9c2ba48568b8e1c87e9e1a7b, type: 2}
59-
_highlightMarginTop: 0.7
60-
_highlightMarginBottom: 0.1
61-
_highlightMarginLeft: 0.1
62-
_highlightMarginRight: 0.1
63-
_onItemChanged:
49+
model: {fileID: 0}
50+
itemLabel: {fileID: 7599011510456966153}
51+
itemWidth: 1.4
52+
itemHeight: 1
53+
loadingMaterial: {fileID: 2100000, guid: 0e29a213f7529450cb3eb75e25f24c03, type: 2}
54+
highlightMesh: {fileID: 0}
55+
highlightMaterial: {fileID: 2100000, guid: 7e59c25f9c2ba48568b8e1c87e9e1a7b, type: 2}
56+
selectionMaterial: {fileID: 2100000, guid: 07beb7151a88444fd92397b3ee46d80f, type: 2}
57+
highlightElevation: 0.1
58+
highlightColor: {r: 1, g: 0.8, b: 0.2, a: 0.7}
59+
selectionColor: {r: 0.084590435, g: 1, b: 0, a: 0.9}
60+
collectionId:
61+
onItemChanged:
6462
m_PersistentCalls:
6563
m_Calls: []
6664
--- !u!65 &1945117689957070442

0 commit comments

Comments
 (0)