Files
whdwo798 4dad9e5d5b feat: SongCreator 씬 완성 — Beat Sage URL 지원, info.dat 메타데이터 자동 추출
- BeatSageUploader: audio_url 지원(UploadFromUrl), PollAndDownload 공통화, ZIP 500 오류 3회 재시도
- BeatSageConverter: info.dat 파싱(SongMetadata), BPM 자동 감지 → 노트 타이밍 변환에 적용
- SongCreatorManager: title/BPM 필수 입력 제거, 난이도 4개 자동 선택, GenerateFlowFromUrl 버그 수정
- NasPublisher: audioPath null 허용(URL 흐름에서 로컬 파일 없는 경우 스킵)
- .gitignore/.gitattributes 초기 설정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 23:37:34 +09:00

185 lines
5.6 KiB
C#

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace VRBeats
{
public class VR_BeatCubeSpawneable : Spawneable
{
[SerializeField] private GameObject arrow = null;
[SerializeField] private GameObject dot = null;
[SerializeField] private Spark sparkPrefab = null;
[SerializeField] private ColorSide colorSide = ColorSide.Left;
[SerializeField] private bool useSpark = false;
public ColorSide ColorSide { get { return colorSide; } }
public Direction HitDirection { get { return hitDirection; } }
private Direction hitDirection = Direction.Center;
public override void OnSpawn()
{
base.OnSpawn();
if (useSpark)
{
if (sparkPrefab == null) return;
Color desireColor = VR_BeatManager.instance.GetColorFromColorSide(colorSide);
Spark spark = Instantiate(sparkPrefab, transform.position, Quaternion.identity);
spark.transform.parent = transform;
spark.Construct(desireColor);
}
}
public override void Construct(SpawnEventInfo info)
{
base.Construct(info);
transform.rotation = CalculateRotationFromDirection(info.hitDirection);
colorSide = info.colorSide;
useSpark = info.useSpark;
hitDirection = info.hitDirection;
//use the arrow of the center
arrow.SetActive( info.hitDirection != Direction.Center );
dot.SetActive( info.hitDirection == Direction.Center );
}
private Quaternion CalculateRotationFromDirection(Direction dir)
{
Vector3 rot = Vector3.zero;
if (dir == Direction.Up)
{
rot = new Vector3(0.0f, 0.0f, 0.0f);
}
else if (dir == Direction.UpperRight)
{
rot = new Vector3(0.0f, 0.0f, -45.0f);
}
else if (dir == Direction.Right)
{
rot = new Vector3(0.0f, 0.0f, -90.0f);
}
else if (dir == Direction.LowerRight)
{
rot = new Vector3(0.0f, 0.0f, -135.0f);
}
else if (dir == Direction.Down)
{
rot = new Vector3(0.0f, 0.0f, -180.0f);
}
else if (dir == Direction.LowerLeft)
{
rot = new Vector3(0.0f, 0.0f, -225.0f);
}
else if (dir == Direction.Left)
{
rot = new Vector3(0.0f, 0.0f, -270.0f);
}
else if (dir == Direction.UpperLeft)
{
rot = new Vector3(0.0f, 0.0f, -315.0f);
}
return Quaternion.Euler(rot);
}
#if UNITY_EDITOR
string[] textureNameArray = { "upperLeft", "up", "upperRight", "left", "center", "right", "lowerLeft", "down", "lowerRight" };
Texture[] texArray = null;
private bool updateHitDir = false;
private bool updateUseSpark = false;
private bool updateColorSide = false;
private void LoadArrowTextures()
{
texArray = new Texture[textureNameArray.Length];
for (int n = 0; n < texArray.Length; n++)
{
texArray[n] = Resources.Load("Editor/Arrow/" + textureNameArray[n]) as Texture;
}
}
public override void CustomInspector(SpawnEventInfo info , Object[] targets)
{
EditorGUI.BeginChangeCheck();
LoadArrowTextures();
EditorGUI.BeginChangeCheck();
info.hitDirection = DrawArrowGridInspector("" , info.hitDirection);
if (EditorGUI.EndChangeCheck())
{
updateHitDir = true;
}
base.CustomInspector(info , targets);
EditorGUI.BeginChangeCheck();
info.useSpark = EditorGUILayout.Toggle("Use Spark" , info.useSpark);
if (EditorGUI.EndChangeCheck())
{
updateUseSpark = true;
}
EditorGUI.BeginChangeCheck();
info.colorSide = (ColorSide) EditorGUILayout.EnumPopup("Color Side" , info.colorSide);
if (EditorGUI.EndChangeCheck())
{
updateColorSide = true;
}
/*manual assignment here, remember to check that the selected objects
are in fact of the appropriate type.*/
foreach (Object obj in targets)
{
if (obj is VR_BeatSpawnMarker spawnMarker)
{
if (updateHitDir)
spawnMarker.spawInfo.hitDirection = info.hitDirection;
else if (updateUseSpark)
spawnMarker.spawInfo.useSpark = info.useSpark;
else if (updateColorSide)
spawnMarker.spawInfo.colorSide = info.colorSide;
}
}
updateHitDir = false;
updateColorSide = false;
updateUseSpark = false;
}
private Direction DrawArrowGridInspector(string label, Direction dir)
{
EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
GUILayout.BeginVertical("Box");
dir = (Direction)GUILayout.SelectionGrid((int)dir, texArray, 3, GUILayout.ExpandWidth(false), GUILayout.MaxHeight(150f), GUILayout.MaxWidth(150f));
GUILayout.EndVertical();
return dir;
}
#endif
}
}