feat: Game scene — SongController bridges custom map to VRBeatsKit
- SongController: loads MP3 + Beat Saber JSON map, runs countdown (3→2→1→GO), spawns cubes via VR_BeatManager.Spawn() synced to audioSource.time - NoteData → SpawnEventInfo mapping: position/lineLayer → x/y, colorType → ColorSide, cutDirection → Direction enum - travelTimeOverride on SpawnEventInfo: each cube's travel time is back-calculated from remaining time at spawn moment, so simultaneous notes arrive at hit zone together regardless of frame-level spawn delay - AudioManager: add PlayClip(AudioClip) and CurrentTime property - VR_BeatManager: respect travelTimeOverride when non-zero - Settings.asset: targetTravelTime 0.5 → 1.8 for natural Beat Saber approach feel - SceneBuilder ④: auto-builds Game.unity from SaberStyle, wires SongController refs, registers in Build Settings - LiberationSans SDF fallback updated with NanumGothic for Korean text support - Remove unused SampleScene Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,11 +3,98 @@ using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using VRBeats;
|
||||
using VRBeats.ScriptableEvents;
|
||||
|
||||
public static class VRBeatSaberSceneBuilder
|
||||
{
|
||||
private const string MenuScene = "Assets/VRBeatsKit/Scenes/Menu.unity";
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// ④ Build Game Scene
|
||||
// SaberStyle 복제 → Game.unity 생성
|
||||
// PlayableManager 제거, SongController + 카운트다운 캔버스 추가
|
||||
// ─────────────────────────────────────────────
|
||||
[MenuItem("Tools/VRBeatSaber/④ Build Game Scene")]
|
||||
public static void BuildGameScene()
|
||||
{
|
||||
const string saberStylePath = "Assets/VRBeatsKit/Scenes/SaberStyle.unity";
|
||||
const string gamePath = "Assets/Scenes/Game.unity";
|
||||
|
||||
// SaberStyle → Game.unity 복제 (이미 있으면 그냥 열기)
|
||||
if (!AssetDatabase.LoadAssetAtPath<Object>(gamePath))
|
||||
{
|
||||
if (!AssetDatabase.CopyAsset(saberStylePath, gamePath))
|
||||
{
|
||||
Debug.LogError("[SceneBuilder] SaberStyle.unity 복제 실패");
|
||||
return;
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
var scene = EditorSceneManager.OpenScene(gamePath, OpenSceneMode.Single);
|
||||
|
||||
// PlayableManager 제거 (PlayableDirector는 유지)
|
||||
var pm = Object.FindObjectOfType<PlayableManager>();
|
||||
if (pm != null)
|
||||
Object.DestroyImmediate(pm);
|
||||
|
||||
// SongController GO 생성
|
||||
var scGO = new GameObject("SongController");
|
||||
var songController = scGO.AddComponent<SongController>();
|
||||
|
||||
var cubePrefab = AssetDatabase.LoadAssetAtPath<Spawneable>(
|
||||
"Assets/VRBeatsKit/Prefabs/Spawneable/VR_BeatCube.prefab");
|
||||
var onLevelComplete = AssetDatabase.LoadAssetAtPath<GameEvent>(
|
||||
"Assets/VRBeatsKit/GameEvents/OnLevelComplete.asset");
|
||||
|
||||
// 카운트다운 캔버스 생성
|
||||
var canvasGO = new GameObject("CountdownCanvas");
|
||||
var canvas = canvasGO.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
canvas.sortingOrder = 100;
|
||||
canvasGO.AddComponent<CanvasScaler>();
|
||||
canvasGO.AddComponent<GraphicRaycaster>();
|
||||
|
||||
var countdownGO = new GameObject("CountdownText");
|
||||
countdownGO.transform.SetParent(canvasGO.transform, false);
|
||||
var cRect = countdownGO.AddComponent<RectTransform>();
|
||||
cRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
cRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
cRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
cRect.anchoredPosition = Vector2.zero;
|
||||
cRect.sizeDelta = new Vector2(400f, 200f);
|
||||
var cTmp = countdownGO.AddComponent<TextMeshProUGUI>();
|
||||
cTmp.text = "";
|
||||
cTmp.fontSize = 120f;
|
||||
cTmp.color = Color.white;
|
||||
cTmp.alignment = TextAlignmentOptions.Center;
|
||||
cTmp.fontStyle = FontStyles.Bold;
|
||||
countdownGO.SetActive(false);
|
||||
|
||||
// SongController 필드 연결
|
||||
var scSO = new SerializedObject(songController);
|
||||
scSO.FindProperty("cubePrefab") .objectReferenceValue = cubePrefab;
|
||||
scSO.FindProperty("onLevelComplete") .objectReferenceValue = onLevelComplete;
|
||||
scSO.FindProperty("countdownText") .objectReferenceValue = cTmp;
|
||||
scSO.ApplyModifiedPropertiesWithoutUndo();
|
||||
|
||||
// Build Settings 에 Game.unity 추가
|
||||
var scenes = EditorBuildSettings.scenes;
|
||||
bool exists = System.Array.Exists(scenes, s => s.path == gamePath);
|
||||
if (!exists)
|
||||
{
|
||||
var newList = new EditorBuildSettingsScene[scenes.Length + 1];
|
||||
System.Array.Copy(scenes, newList, scenes.Length);
|
||||
newList[scenes.Length] = new EditorBuildSettingsScene(gamePath, true);
|
||||
EditorBuildSettings.scenes = newList;
|
||||
}
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(scene);
|
||||
EditorSceneManager.SaveScene(scene);
|
||||
Debug.Log("[SceneBuilder] ✓ Game.unity 생성 완료");
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// ③ Menu — Rebuild SongSelect Panel
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99c9720ab356a0642a771bea13969a05
|
||||
guid: dab0572fcafe87d4b80a838fd874234b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -1,432 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 10
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &330585543
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 330585546}
|
||||
- component: {fileID: 330585545}
|
||||
- component: {fileID: 330585544}
|
||||
- component: {fileID: 330585547}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &330585544
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 330585543}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &330585545
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 330585543}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &330585546
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 330585543}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &330585547
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 330585543}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RenderShadows: 1
|
||||
m_RequiresDepthTextureOption: 2
|
||||
m_RequiresOpaqueTextureOption: 2
|
||||
m_CameraType: 0
|
||||
m_Cameras: []
|
||||
m_RendererIndex: -1
|
||||
m_VolumeLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
m_VolumeTrigger: {fileID: 0}
|
||||
m_VolumeFrameworkUpdateModeOption: 2
|
||||
m_RenderPostProcessing: 1
|
||||
m_Antialiasing: 0
|
||||
m_AntialiasingQuality: 2
|
||||
m_StopNaN: 0
|
||||
m_Dithering: 0
|
||||
m_ClearDepth: 1
|
||||
m_AllowXRRendering: 1
|
||||
m_AllowHDROutput: 1
|
||||
m_UseScreenCoordOverride: 0
|
||||
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
quality: 3
|
||||
frameInfluence: 0.1
|
||||
jitterScale: 1
|
||||
mipBias: 0
|
||||
varianceClampScale: 0.9
|
||||
contrastAdaptiveSharpening: 0
|
||||
--- !u!1 &410087039
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 410087041}
|
||||
- component: {fileID: 410087040}
|
||||
- component: {fileID: 410087042}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &410087040
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410087039}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 11
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 2
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 5000
|
||||
m_UseColorTemperature: 1
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ForceVisible: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &410087041
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410087039}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!114 &410087042
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410087039}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Version: 3
|
||||
m_UsePipelineSettings: 1
|
||||
m_AdditionalLightsShadowResolutionTier: 2
|
||||
m_LightLayerMask: 1
|
||||
m_RenderingLayers: 1
|
||||
m_CustomShadowLayers: 0
|
||||
m_ShadowLayerMask: 1
|
||||
m_ShadowRenderingLayers: 1
|
||||
m_LightCookieSize: {x: 1, y: 1}
|
||||
m_LightCookieOffset: {x: 0, y: 0}
|
||||
m_SoftShadowQuality: 1
|
||||
--- !u!1 &832575517
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 832575519}
|
||||
- component: {fileID: 832575518}
|
||||
m_Layer: 0
|
||||
m_Name: Global Volume
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &832575518
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 832575517}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IsGlobal: 1
|
||||
priority: 0
|
||||
blendDistance: 0
|
||||
weight: 1
|
||||
sharedProfile: {fileID: 11400000, guid: 10fc4df2da32a41aaa32d77bc913491c, type: 2}
|
||||
--- !u!4 &832575519
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 832575517}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 330585546}
|
||||
- {fileID: 410087041}
|
||||
- {fileID: 832575519}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using VRBeats;
|
||||
using VRBeats.ScriptableEvents;
|
||||
|
||||
public class SongController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Spawneable cubePrefab;
|
||||
[SerializeField] private GameEvent onLevelComplete;
|
||||
[SerializeField] private TMP_Text countdownText;
|
||||
|
||||
private AudioManager _audio;
|
||||
|
||||
private static string CacheRoot =>
|
||||
Path.Combine(Application.temporaryCachePath, "beatsaber");
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_audio = FindObjectOfType<AudioManager>();
|
||||
StartCoroutine(LoadAndPlay());
|
||||
}
|
||||
|
||||
private IEnumerator LoadAndPlay()
|
||||
{
|
||||
SongInfo song = GameSession.SelectedSong;
|
||||
string diff = GameSession.SelectedDifficulty;
|
||||
|
||||
if (song == null || string.IsNullOrEmpty(diff))
|
||||
{
|
||||
Debug.LogError("[SongController] No song/difficulty selected");
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Load audio clip from local cache
|
||||
string audioPath = Path.Combine(CacheRoot, song.id, song.id + ".mp3");
|
||||
AudioClip clip;
|
||||
using (var req = UnityWebRequestMultimedia.GetAudioClip("file://" + audioPath, AudioType.MPEG))
|
||||
{
|
||||
yield return req.SendWebRequest();
|
||||
if (req.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError($"[SongController] Audio load failed: {req.error}");
|
||||
yield break;
|
||||
}
|
||||
clip = DownloadHandlerAudioClip.GetContent(req);
|
||||
}
|
||||
|
||||
// Load and parse map
|
||||
DifficultyInfo diffInfo = song.difficulties.Get(diff);
|
||||
if (diffInfo == null)
|
||||
{
|
||||
Debug.LogError($"[SongController] Difficulty '{diff}' not found");
|
||||
yield break;
|
||||
}
|
||||
string mapPath = Path.Combine(CacheRoot, song.id, Path.GetFileName(diffInfo.mapFile));
|
||||
if (!File.Exists(mapPath))
|
||||
{
|
||||
Debug.LogError($"[SongController] Map file missing: {mapPath}");
|
||||
yield break;
|
||||
}
|
||||
MapData map = JsonUtility.FromJson<MapData>(File.ReadAllText(mapPath));
|
||||
if (map?.target == null)
|
||||
{
|
||||
Debug.LogError("[SongController] Map parse failed");
|
||||
yield break;
|
||||
}
|
||||
map.target.Sort((a, b) => a.time.CompareTo(b.time));
|
||||
|
||||
yield return StartCoroutine(Countdown());
|
||||
|
||||
_audio.PlayClip(clip);
|
||||
|
||||
StartCoroutine(SpawnRoutine(map.target));
|
||||
yield return StartCoroutine(WaitForCompletion(clip.length));
|
||||
}
|
||||
|
||||
private IEnumerator Countdown()
|
||||
{
|
||||
if (countdownText == null) yield break;
|
||||
countdownText.gameObject.SetActive(true);
|
||||
|
||||
string[] labels = { "3", "2", "1", "GO!" };
|
||||
float[] durations = { 1f, 1f, 1f, 0.6f };
|
||||
|
||||
for (int i = 0; i < labels.Length; i++)
|
||||
{
|
||||
countdownText.text = labels[i];
|
||||
yield return new WaitForSeconds(durations[i]);
|
||||
}
|
||||
|
||||
countdownText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private IEnumerator SpawnRoutine(List<NoteData> notes)
|
||||
{
|
||||
float travelTime = VR_BeatManager.instance.GameSettings.TargetTravelTime;
|
||||
|
||||
foreach (NoteData note in notes)
|
||||
{
|
||||
float spawnAt = Mathf.Max(0f, note.time - travelTime);
|
||||
yield return new WaitUntil(() => _audio.CurrentTime >= spawnAt);
|
||||
SpawnNote(note);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnNote(NoteData note)
|
||||
{
|
||||
float x = -0.375f + note.position * 0.25f;
|
||||
float y = -0.333f + note.lineLayer * 0.333f;
|
||||
|
||||
// 스폰 시점의 실제 남은 시간으로 역산 → 동시 노트가 프레임 차이 나도 같은 타이밍에 도착
|
||||
float remaining = note.time - _audio.CurrentTime;
|
||||
float travelTime = Mathf.Max(0.05f, remaining);
|
||||
|
||||
var info = new SpawnEventInfo
|
||||
{
|
||||
position = new Vector3(x, y, 0f),
|
||||
colorSide = note.colorType == 0 ? ColorSide.Left : ColorSide.Right,
|
||||
hitDirection = MapCutDirection(note.cutDirection),
|
||||
useSpark = true,
|
||||
speed = 2f,
|
||||
travelTimeOverride = travelTime,
|
||||
};
|
||||
|
||||
VR_BeatManager.instance.Spawn(cubePrefab, info);
|
||||
}
|
||||
|
||||
// Beat Saber cutDirection → VRBeats Direction
|
||||
// BS: 0=Up 1=Down 2=Left 3=Right 4=UpperLeft 5=UpperRight 6=LowerLeft 7=LowerRight 8=Any
|
||||
private static readonly Direction[] CutDirMap =
|
||||
{
|
||||
Direction.Up,
|
||||
Direction.Down,
|
||||
Direction.Left,
|
||||
Direction.Right,
|
||||
Direction.UpperLeft,
|
||||
Direction.UpperRight,
|
||||
Direction.LowerLeft,
|
||||
Direction.LowerRight,
|
||||
Direction.Center,
|
||||
};
|
||||
|
||||
private static Direction MapCutDirection(int cut)
|
||||
=> (cut >= 0 && cut < CutDirMap.Length) ? CutDirMap[cut] : Direction.Center;
|
||||
|
||||
private IEnumerator WaitForCompletion(float clipLength)
|
||||
{
|
||||
yield return new WaitUntil(() => _audio.CurrentTime >= clipLength - 0.5f);
|
||||
onLevelComplete?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca3b401467e927148b0face4c03b0062
|
||||
+36
-9
File diff suppressed because one or more lines are too long
@@ -41,6 +41,14 @@ namespace VRBeats
|
||||
audioSource.outputAudioMixerGroup.audioMixer.SetFloat("Pitch", value);
|
||||
}
|
||||
|
||||
public void PlayClip(AudioClip clip)
|
||||
{
|
||||
audioSource.clip = clip;
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
public float CurrentTime => audioSource != null ? audioSource.time : 0f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,18 +69,19 @@ namespace VRBeats
|
||||
Spawneable clone = Instantiate( spawneable , spawnPosition , Quaternion.Euler( info.rotation ) );
|
||||
SetSpeedRelativeToPlayZone(info);
|
||||
clone.Construct(info);
|
||||
|
||||
|
||||
Vector3 finalScale = clone.transform.localScale;
|
||||
clone.transform.localScale = Vector3.zero;
|
||||
|
||||
|
||||
clone.transform.Move(finalPosition, settings.TargetTravelTime).SetEase(settings.TargetTravelEase).SetOnComplete(delegate
|
||||
float travelTime = info.travelTimeOverride > 0f ? info.travelTimeOverride : settings.TargetTravelTime;
|
||||
|
||||
clone.transform.Move(finalPosition, travelTime).SetEase(settings.TargetTravelEase).SetOnComplete(delegate
|
||||
{
|
||||
clone.OnSpawn();
|
||||
}).SetUpdateMode(Platinio.TweenEngine.UpdateMode.Update);
|
||||
}).SetUpdateMode(Platinio.TweenEngine.UpdateMode.Update);
|
||||
|
||||
|
||||
clone.transform.ScaleTween(finalScale, settings.TargetTravelTime).SetEase(settings.TargetTravelEase);
|
||||
|
||||
clone.transform.ScaleTween(finalScale, travelTime).SetEase(settings.TargetTravelEase);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,5 +32,7 @@ namespace VRBeats
|
||||
public Vector3 rotation = Vector3.zero;
|
||||
public float speed = 2.0f;
|
||||
public int speedMultiplier = 1;
|
||||
// 0 이면 Settings.TargetTravelTime 사용, 양수면 해당 시간으로 이동
|
||||
public float travelTimeOverride = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7aabf7bc54d695644952b5c737f1c915, type: 3}
|
||||
m_Name: Settings
|
||||
m_EditorClassIdentifier:
|
||||
rightColor: {r: 0, g: 0.6002884, b: 1, a: 1}
|
||||
leftColor: {r: 1, g: 0, b: 0, a: 1}
|
||||
glowIntensity: 100
|
||||
targetTravelDistance: 40
|
||||
targetTravelTime: 0.5
|
||||
targetTravelEase: 19
|
||||
errorLimit: 7
|
||||
scorePerHit: 50
|
||||
maxMultiplier: 8
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7aabf7bc54d695644952b5c737f1c915, type: 3}
|
||||
m_Name: Settings
|
||||
m_EditorClassIdentifier:
|
||||
rightColor: {r: 0, g: 0.6002884, b: 1, a: 1}
|
||||
leftColor: {r: 1, g: 0, b: 0, a: 1}
|
||||
glowIntensity: 100
|
||||
targetTravelDistance: 40
|
||||
targetTravelTime: 1.8
|
||||
targetTravelEase: 19
|
||||
errorLimit: 7
|
||||
scorePerHit: 50
|
||||
maxMultiplier: 8
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e2b6321d0fb6bc42829561179a3d7ae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,6 +17,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/VRBeatsKit/Scenes/SaberStyle.unity
|
||||
guid: bb4ee84e66cce254e9cbf1fdfc136c08
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Game.unity
|
||||
guid: dab0572fcafe87d4b80a838fd874234b
|
||||
m_configObjects:
|
||||
Unity.XR.Oculus.Settings: {fileID: 11400000, guid: c872ebb38c96a954ca6549564e1aa398,
|
||||
type: 2}
|
||||
|
||||
Reference in New Issue
Block a user