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>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
//grabbables having this component can no be dropped in dropzones
|
||||
public class BlockDrop : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75d17fb515e99de40bac2c0fe1804002
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/BlockDrop.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class ChangeColliderEnableStateOnDrop : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool onDropColliderState = false;
|
||||
[SerializeField] private bool onGrabColliderState = false;
|
||||
|
||||
private VR_DropZone dropZone = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
dropZone = GetComponent<VR_DropZone>();
|
||||
|
||||
dropZone.OnDrop.AddListener( OnDropStateChange );
|
||||
}
|
||||
|
||||
private void OnDropStateChange(VR_Grabbable grabbable)
|
||||
{
|
||||
SetColliderState( grabbable , onDropColliderState );
|
||||
}
|
||||
|
||||
private void OnUnDropStateChange(VR_Grabbable grabbable)
|
||||
{
|
||||
SetColliderState( grabbable , onGrabColliderState );
|
||||
}
|
||||
|
||||
private void SetColliderState(VR_Grabbable grabbble , bool state)
|
||||
{
|
||||
Collider col = grabbble.GetComponent<Collider>();
|
||||
|
||||
if (col != null)
|
||||
col.enabled = state;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be219091f40c996428468633c73769ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/ChangeColliderEnableStateOnDrop.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class CollisionInfo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<Collider> contactColliderList = new List<Collider>();
|
||||
|
||||
public List<Collider> GetCurrentContactColliders()
|
||||
{
|
||||
return contactColliderList;
|
||||
}
|
||||
|
||||
public bool IsInCollision()
|
||||
{
|
||||
return contactColliderList.Count > 0;
|
||||
}
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
contactColliderList.Add(other.collider);
|
||||
}
|
||||
|
||||
private void OnCollisionExit(Collision other)
|
||||
{
|
||||
contactColliderList.Remove( other.collider );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 735d5cae03c2e174eafb7510a7a9bab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/CollisionInfo.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,126 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
|
||||
/// this is just code for handling the demo scene logic, nothing important happens here
|
||||
public class DemoScene : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private EnemySpawner[] enemySpawnerArray = null;
|
||||
[SerializeField] private GameObject spawnPrefab = null;
|
||||
[SerializeField] private Transform spawnPoint = null;
|
||||
[SerializeField] private Animator doorAnimator = null;
|
||||
|
||||
|
||||
private bool doorState = false;
|
||||
private bool canSetTrigger = true;
|
||||
private bool desireDoorState = false;
|
||||
private float currentLeverValue = 0.0f;
|
||||
private bool isSpawningEnemies = false;
|
||||
private VR_ScreenFader gameOverScreenFader = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Player player = FindObjectOfType<Player>();
|
||||
gameOverScreenFader = player.GameOverScreenFader;
|
||||
}
|
||||
|
||||
//called when the black button gets pressed
|
||||
public void OnButtonPressed()
|
||||
{
|
||||
Instantiate(spawnPrefab , spawnPoint.position + Random.insideUnitSphere , spawnPoint.rotation);
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//if we want to spawn enemies and the door is close open it
|
||||
if (isSpawningEnemies && !desireDoorState)
|
||||
{
|
||||
doorAnimator.SetTrigger( "Open" );
|
||||
return;
|
||||
}
|
||||
|
||||
//if the lever is on the open zone
|
||||
if (currentLeverValue >= 0.9f)
|
||||
{
|
||||
if (!doorState && canSetTrigger)
|
||||
{
|
||||
canSetTrigger = false;
|
||||
desireDoorState = true;
|
||||
doorAnimator.SetTrigger( "Open" );
|
||||
}
|
||||
|
||||
}
|
||||
//if the lever is on the closed zone
|
||||
else if (currentLeverValue <= 0.1f)
|
||||
{
|
||||
if (doorState && canSetTrigger)
|
||||
{
|
||||
canSetTrigger = false;
|
||||
desireDoorState = false;
|
||||
doorAnimator.SetTrigger( "Close" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//called when the lever value change, in other words when you move the lever
|
||||
public void OnLeverValueChange(float v)
|
||||
{
|
||||
currentLeverValue = v;
|
||||
}
|
||||
|
||||
public void SetDoorState( bool state)
|
||||
{
|
||||
doorState = state;
|
||||
canSetTrigger = true;
|
||||
}
|
||||
|
||||
public void EnableEnemySpawning()
|
||||
{
|
||||
if (isSpawningEnemies)
|
||||
return;
|
||||
|
||||
StartCoroutine( EnableEnemySpawningRoutine() );
|
||||
}
|
||||
|
||||
private IEnumerator EnableEnemySpawningRoutine()
|
||||
{
|
||||
isSpawningEnemies = true;
|
||||
|
||||
//the door is open start spawning right now
|
||||
if (doorState)
|
||||
{
|
||||
EnableAllEnemySpawners();
|
||||
}
|
||||
//the door is closed let's wait for it to open
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(5.0f);
|
||||
EnableAllEnemySpawners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void EnableAllEnemySpawners()
|
||||
{
|
||||
for (int n = 0; n < enemySpawnerArray.Length; n++)
|
||||
{
|
||||
enemySpawnerArray[n].enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void GameOver()
|
||||
{
|
||||
gameOverScreenFader.FadeIn(1.5f , delegate
|
||||
{
|
||||
SceneManager.LoadScene( SceneManager.GetActiveScene().name );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c7fd652eef9ea41a21d75e5d77e1b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/DemoScene.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class Door : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float throwForce = 100.0f;
|
||||
|
||||
private VR_Grabbable grabbable = null;
|
||||
private VR_Controller grabController = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
grabbable = GetComponent<VR_Grabbable>();
|
||||
grabbable.OnGrabStateChange.AddListener(OnGrabStateChange);
|
||||
}
|
||||
|
||||
private void OnGrabStateChange(GrabState newState)
|
||||
{
|
||||
if (newState == GrabState.Grab)
|
||||
{
|
||||
grabController = grabbable.GrabController;
|
||||
}
|
||||
|
||||
if (newState == GrabState.Drop)
|
||||
{
|
||||
Debug.Log("drop");
|
||||
GetComponent<Rigidbody>().isKinematic = false;
|
||||
GetComponent<Rigidbody>().AddForceAtPosition( grabController.Velocity * throwForce, grabController.transform.position );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10162c11568b0ea45b2e2eaa8e7c294c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/Door.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class DoorAnimatorController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DemoScene demoScene = null;
|
||||
|
||||
//called by the door animation when the door open
|
||||
public void Open()
|
||||
{
|
||||
demoScene.SetDoorState(true);
|
||||
}
|
||||
|
||||
//called by the door animation when the door closes
|
||||
public void Close()
|
||||
{
|
||||
demoScene.SetDoorState(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1b3f7e24af800241beb91771dac5f8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/DoorAnimatorController.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class DropZoneInfo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 positionOffset = Vector3.zero;
|
||||
[SerializeField] private Vector3 rotationOffset = Vector3.zero;
|
||||
[SerializeField] private float scaleModifier = 0.0f;
|
||||
|
||||
public Vector3 OriginalScale { get { return originalScale; } }
|
||||
public Vector3 PositionOffset { get { return positionOffset; } }
|
||||
public Vector3 RotationOffset { get { return rotationOffset; } }
|
||||
public float ScaleModifier { get { return scaleModifier; } }
|
||||
|
||||
private Vector3 originalScale = Vector3.zero;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
originalScale = transform.localScale;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 110d3a5facabd4e4e92b0fb2fabb6db7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/DropZoneInfo.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class DropZoneOffset : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 positionOffset = Vector3.zero;
|
||||
[SerializeField] private Vector3 rotationOffset = Vector3.zero;
|
||||
|
||||
public Vector3 PositionOffset { get { return positionOffset; } }
|
||||
public Vector3 RotationOffset { get { return rotationOffset; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 951640658cf67d54eb1a018952fa3b8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/DropZoneOffset.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,69 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class EnemySpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject[] enemies = null;
|
||||
[SerializeField] private float spawnTime = 5.0f;
|
||||
[SerializeField] private float spawnRadius = 1.0f;
|
||||
[SerializeField] private int maxEnemies = 10;
|
||||
|
||||
|
||||
private float timer = 0.0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
timer = Random.Range(spawnTime / 2.0f , spawnTime);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
|
||||
if(timer <= 0.0f)
|
||||
Spawn();
|
||||
}
|
||||
|
||||
//creates a new enemy
|
||||
private void Spawn()
|
||||
{
|
||||
timer = Random.Range(spawnTime / 2.0f, spawnTime);
|
||||
|
||||
//check if dont have to many enemies already
|
||||
if (GameObject.FindGameObjectsWithTag( "Enemy" ).Length > maxEnemies)
|
||||
return;
|
||||
|
||||
GameObject enemy = enemies[Random.Range(0 , enemies.Length)];
|
||||
|
||||
if (RandomNavmeshLocation(spawnRadius, out Vector3 spawnPoint))
|
||||
{
|
||||
Instantiate(enemy, spawnPoint, transform.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//return a random point inside the navmesh radius
|
||||
private bool RandomNavmeshLocation(float radius, out Vector3 spawnPosition)
|
||||
{
|
||||
Vector3 randomDirection = Random.insideUnitSphere * radius;
|
||||
randomDirection += transform.position;
|
||||
NavMeshHit hit;
|
||||
spawnPosition = Vector3.zero;
|
||||
|
||||
if (NavMesh.SamplePosition(randomDirection, out hit, radius, 1))
|
||||
{
|
||||
spawnPosition = hit.position;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b42bc5837948964a9a74cf99fd65644
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/EnemySpawner.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class FaceCamera : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float multiplier = 1.0f;
|
||||
|
||||
private Transform mainCamera = null;
|
||||
private Transform thisTransform = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
thisTransform = transform;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (mainCamera == null)
|
||||
{
|
||||
mainCamera = GetMainCamera();
|
||||
}
|
||||
|
||||
if (mainCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
thisTransform.forward = (mainCamera.position - transform.position).normalized * multiplier;
|
||||
}
|
||||
|
||||
private Transform GetMainCamera()
|
||||
{
|
||||
Camera cam = Camera.main;
|
||||
|
||||
if (cam != null)
|
||||
{
|
||||
return cam.transform;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3408be6fcd95c83458d5b48d8ad4d179
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/FaceCamera.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
//use by the MuzzleFlashSmall so we can keep the smoke always facing the up direction
|
||||
public class FaceWorldDirection : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 direction = Vector3.zero;
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
transform.forward = direction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd73ad91b816714fbf94b9d903885f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/FaceWorldDirection.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class FollowHeight : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform objToFollow = null;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.position = objToFollow.position;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
/*
|
||||
Vector3 currentPos = transform.position;
|
||||
currentPos.y = objToFollow.position.y;
|
||||
transform.position = currentPos;*/
|
||||
transform.position = objToFollow.position;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
transform.position = objToFollow.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f83e7731e51d634db6fe64fd4bed8d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/FollowHeight.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public static class GlobalDefinitionsManager
|
||||
{
|
||||
const string DEFINES_FILE_PATH = "Assets/mcs.rsp";
|
||||
|
||||
public static void CreateAndWriteDefinition(string def)
|
||||
{
|
||||
List<string> currentDefList = GetCurrentDefinitios();
|
||||
currentDefList.Add(def);
|
||||
WriteDefinitions(currentDefList);
|
||||
}
|
||||
|
||||
public static List<string> GetCurrentDefinitios()
|
||||
{
|
||||
if (!File.Exists( DEFINES_FILE_PATH ))
|
||||
return new List<string>();
|
||||
|
||||
string[] lines = File.ReadAllLines( DEFINES_FILE_PATH );
|
||||
|
||||
for (int n = 0; n < lines.Length; n++)
|
||||
{
|
||||
if (lines[n].StartsWith( "-define:" ))
|
||||
{
|
||||
return lines[n].Replace( "-define:", "" ).Split( ';' ).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
public static void WriteDefinitions(List<string> defList)
|
||||
{
|
||||
DeleteDefinitionsFile();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append( "-define:" );
|
||||
for (int n = 0; n < defList.Count; n++)
|
||||
{
|
||||
sb.Append( defList[n] );
|
||||
|
||||
|
||||
if (n < defList.Count - 1)
|
||||
{
|
||||
sb.Append( ";" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using (StreamWriter writer = new StreamWriter( DEFINES_FILE_PATH, false ))
|
||||
{
|
||||
writer.Write( sb.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveDefinitions(params string[] definitionArray)
|
||||
{
|
||||
List<string> currentDef = GetCurrentDefinitios();
|
||||
|
||||
for (int n = 0; n < currentDef.Count; n++)
|
||||
{
|
||||
for (int j = 0; j < definitionArray.Length; j++)
|
||||
{
|
||||
if (currentDef[n] == definitionArray[j])
|
||||
{
|
||||
currentDef.RemoveAt(n);
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDef.Count <= 0)
|
||||
DeleteDefinitionsFile();
|
||||
else
|
||||
WriteDefinitions(currentDef);
|
||||
}
|
||||
|
||||
public static bool DefinitionExits(string def)
|
||||
{
|
||||
List<string> defList = GetCurrentDefinitios();
|
||||
|
||||
for (int n = 0; n < defList.Count; n++)
|
||||
{
|
||||
string currentDef = defList[n].Replace( " ", "" );
|
||||
|
||||
if (currentDef == def)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void DeleteDefinitionsFile()
|
||||
{
|
||||
//delete definitions file
|
||||
if (File.Exists( DEFINES_FILE_PATH ))
|
||||
File.Delete( DEFINES_FILE_PATH );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7126f2bc7ad9a754394e012ae92d6a01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/GlobalDefinitionsManager.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
using VRSDK.Collections;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class HistoryBuffer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int bufferSize = 10;
|
||||
|
||||
private Buffer<Vector3> velocityHistory;
|
||||
private Buffer<Vector3> angularVelocityHistory;
|
||||
private Buffer<Vector3> localPositionHistory;
|
||||
private Buffer<Vector3> positionHistory;
|
||||
private Buffer<Quaternion> rotationHistory;
|
||||
private Vector3 lastLocalPosition = Vector3.zero;
|
||||
|
||||
|
||||
public Buffer<Vector3> PositionHistory { get { return positionHistory; } }
|
||||
public Buffer<Vector3> LocalPositionHistory { get { return localPositionHistory; } }
|
||||
public Buffer<Vector3> AngularVelocityHistory { get { return angularVelocityHistory; } }
|
||||
public Buffer<Quaternion> RotationHistory { get { return rotationHistory; } }
|
||||
public Buffer<Vector3> VelocityHistory { get { return velocityHistory; } }
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
velocityHistory = new Buffer<Vector3>( bufferSize );
|
||||
angularVelocityHistory = new Buffer<Vector3>( bufferSize );
|
||||
localPositionHistory = new Buffer<Vector3>( bufferSize );
|
||||
positionHistory = new Buffer<Vector3>( bufferSize );
|
||||
rotationHistory = new Buffer<Quaternion>(bufferSize);
|
||||
|
||||
lastLocalPosition = transform.localPosition;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateVelocityHistory();
|
||||
UpdateAngularVelocityHistory();
|
||||
UpdateLocalPositionHistory();
|
||||
UpdatePositionHistory();
|
||||
UpdateRotationHistory();
|
||||
}
|
||||
|
||||
private void UpdateVelocityHistory()
|
||||
{
|
||||
velocityHistory.Add( (lastLocalPosition - transform.localPosition) / Time.deltaTime );
|
||||
lastLocalPosition = transform.localPosition;
|
||||
}
|
||||
|
||||
private void UpdateRotationHistory()
|
||||
{
|
||||
rotationHistory.Add( transform.rotation );
|
||||
}
|
||||
|
||||
private void UpdateAngularVelocityHistory()
|
||||
{
|
||||
if (rotationHistory.Count < 2)
|
||||
return;
|
||||
|
||||
float delta = Time.deltaTime;
|
||||
float angleDegrees = 0.0f;
|
||||
Vector3 unitAxis = Vector3.zero;
|
||||
Quaternion rotation = Quaternion.identity;
|
||||
|
||||
rotation = ( rotationHistory[rotationHistory.Count - 1] ) * Quaternion.Inverse( rotationHistory[rotationHistory.Count - 2] );
|
||||
|
||||
rotation.ToAngleAxis( out angleDegrees, out unitAxis );
|
||||
Vector3 angular = unitAxis * ( ( angleDegrees * Mathf.Deg2Rad ) / delta );
|
||||
|
||||
angularVelocityHistory.Add( angular);
|
||||
|
||||
}
|
||||
private void UpdateLocalPositionHistory()
|
||||
{
|
||||
localPositionHistory.Add(transform.localPosition);
|
||||
}
|
||||
|
||||
private void UpdatePositionHistory()
|
||||
{
|
||||
positionHistory.Add( transform.position );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75d8be0a85bcbb14db300f7e794ee9bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/HistoryBuffer.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class IgnoreColliderActivationFromGrabbable : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a77eaa1e32f6b8543a57fc4a628476d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/IgnoreColliderActivationFromGrabbable.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class LimbController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float lifeTime = 5.0f;
|
||||
|
||||
private VR_Grabbable grabbable = null;
|
||||
private float timer = 0.0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
grabbable = GetComponent<VR_Grabbable>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (timer > lifeTime)
|
||||
{
|
||||
Destroy( gameObject );
|
||||
}
|
||||
//dont destroy while you are grabbing this limb
|
||||
else if( grabbable.CurrentGrabState == GrabState.Grab )
|
||||
{
|
||||
timer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37d6a02dd486249488880a8d2f154d35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/LimbController.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class ParentOnDrop : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform parent = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
VR_DropZone dropzone = GetComponent<VR_DropZone>();
|
||||
|
||||
if (dropzone != null)
|
||||
{
|
||||
dropzone.OnDrop.AddListener( OnDropStateChange );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnDropStateChange(VR_Grabbable grabbable)
|
||||
{
|
||||
if(grabbable != null)
|
||||
grabbable.transform.parent = parent;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e2f081d73320694083126e65ea110b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/ParentOnDrop.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class ParticleSystemMultiplier : MonoBehaviour
|
||||
{
|
||||
|
||||
public float multiplier = 1;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var systems = GetComponentsInChildren<ParticleSystem>();
|
||||
foreach (ParticleSystem system in systems)
|
||||
{
|
||||
ParticleSystem.MainModule mainModule = system.main;
|
||||
mainModule.startSizeMultiplier *= multiplier;
|
||||
mainModule.startSpeedMultiplier *= multiplier;
|
||||
mainModule.startLifetimeMultiplier *= Mathf.Lerp(multiplier, 1, 0.5f);
|
||||
system.Clear();
|
||||
system.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039587c051912eb4ead9e58344c5f3ce
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/ParticleSystemMultiplier.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform pockectsAnchorPoint = null;
|
||||
[SerializeField] private VR_ScreenFader gameOverScreenFader = null;
|
||||
|
||||
public Transform PocketsAnchorPoint { get { return pockectsAnchorPoint; } }
|
||||
public VR_ScreenFader GameOverScreenFader { get { return gameOverScreenFader; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e040c09518033ae4dba849fce9adbf34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/Player.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
using VRSDK.Locomotion;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class PlayerPockets : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float height = -0.5f;
|
||||
[SerializeField] private float lerpSpeed = 0.0f;
|
||||
|
||||
private const float followThreshold = 0.55f;
|
||||
private VR_CharacterController characterController = null;
|
||||
|
||||
private Vector3 ThisEulerAngle { get { return transform.rotation.eulerAngles; } }
|
||||
private Transform anchorPoint = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
characterController = FindObjectOfType<VR_CharacterController>();
|
||||
|
||||
if (characterController != null)
|
||||
{
|
||||
characterController.OnPlayerRotation.AddListener( OnPlayerRotate );
|
||||
}
|
||||
|
||||
if (anchorPoint == null)
|
||||
{
|
||||
Player player = FindObjectOfType<Player>();
|
||||
anchorPoint = player.PocketsAnchorPoint;
|
||||
}
|
||||
|
||||
SetTeleportCallback();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetTeleportCallback()
|
||||
{
|
||||
VR_TeleportHandler teleportHandler = FindObjectOfType<VR_TeleportHandler>();
|
||||
|
||||
if (teleportHandler != null)
|
||||
{
|
||||
teleportHandler.OnTeleport.AddListener( delegate
|
||||
{
|
||||
Quaternion desireRotation = Quaternion.Euler( ThisEulerAngle.x, anchorPoint.rotation.eulerAngles.y, ThisEulerAngle.z );
|
||||
transform.rotation = desireRotation;
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerRotate(float angle)
|
||||
{
|
||||
Quaternion desireRotation = Quaternion.Euler( ThisEulerAngle.x, ThisEulerAngle.y + angle, ThisEulerAngle.z );
|
||||
transform.rotation = desireRotation;
|
||||
}
|
||||
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
SetPosition();
|
||||
SetRotationIfWeAreNotLookingAtThePockets();
|
||||
}
|
||||
|
||||
private void SetPosition()
|
||||
{
|
||||
transform.position = anchorPoint.transform.position + ( Vector3.up * height );
|
||||
}
|
||||
|
||||
private void SetRotationIfWeAreNotLookingAtThePockets()
|
||||
{
|
||||
if ( IsLookingAtThePockets() )
|
||||
{
|
||||
Quaternion desireRotation = CalculateDesireRotation();
|
||||
float desireLerpSpeed = CalculateDesireLerpSpeed();
|
||||
|
||||
transform.rotation = Quaternion.Slerp( transform.rotation, desireRotation, desireLerpSpeed );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Quaternion CalculateDesireRotation()
|
||||
{
|
||||
return Quaternion.Euler( ThisEulerAngle.x, anchorPoint.rotation.eulerAngles.y, ThisEulerAngle.z );
|
||||
}
|
||||
|
||||
private float CalculateDesireLerpSpeed()
|
||||
{
|
||||
Vector3 anchorForward = anchorPoint.forward;
|
||||
return Mathf.Abs( lerpSpeed * Mathf.Abs( Mathf.Abs( anchorForward.y ) - 1.0f ) ) * Time.deltaTime;
|
||||
}
|
||||
|
||||
private bool IsLookingAtThePockets()
|
||||
{
|
||||
Vector3 anchorForward = anchorPoint.forward;
|
||||
return Mathf.Abs( anchorForward.y ) < followThreshold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eed9996a6c855bc4fac9abd7219b39bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/PlayerPockets.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
public class PreserveRotation : MonoBehaviour
|
||||
{
|
||||
private Vector3 forward = Vector3.zero;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
forward = transform.forward;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
transform.forward = forward;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6a21afa11c345a4cbadf4bcbe63b744
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/PreserveRotation.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
/// <summary>
|
||||
/// Code for activate the ragdoll on this character
|
||||
/// </summary>
|
||||
public class RagdollHelper : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Has the character something like a sword? put it here
|
||||
/// </summary>
|
||||
[SerializeField] private Transform[] equipment = null;
|
||||
[SerializeField] private UnityEvent onEnableRagdoll = null;
|
||||
|
||||
public UnityEvent OnEnableRagdoll { get { return onEnableRagdoll; } }
|
||||
|
||||
protected Rigidbody[] rbArray = null;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
rbArray = GetComponentsInChildren<Rigidbody>();
|
||||
SetKinematic(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the ragdoll
|
||||
/// </summary>
|
||||
public virtual void EnableRagdoll()
|
||||
{
|
||||
onEnableRagdoll.Invoke();
|
||||
SetKinematic(false);
|
||||
|
||||
for (int n = 0 ; n < equipment.Length ; n++)
|
||||
{
|
||||
equipment[n].parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetKinematic(bool newValue)
|
||||
{
|
||||
for (int n = 0 ; n < rbArray.Length ; n++)
|
||||
{
|
||||
rbArray[n].isKinematic = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
for (int n = 0; n < equipment.Length; n++)
|
||||
{
|
||||
if (equipment[n] != null)
|
||||
{
|
||||
Destroy(equipment[n].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acfe3e19c6a26ec43992570e9d0825ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/RagdollHelper.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platinio
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Basic singleton class
|
||||
/// </summary>
|
||||
public class Singleton<T> : MonoBehaviour where T : Singleton<T>
|
||||
{
|
||||
private static T m_instance = null;
|
||||
|
||||
public static T instance
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
|
||||
if(m_instance == null)
|
||||
{
|
||||
|
||||
//get all the singletones
|
||||
T[] singletons = GameObject.FindObjectsOfType( typeof(T) ) as T[];
|
||||
|
||||
if(singletons != null)
|
||||
{
|
||||
if(singletons.Length == 1)
|
||||
{
|
||||
|
||||
m_instance = singletons[0];
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
else if(singletons.Length > 1)
|
||||
{
|
||||
Debug.LogWarning("You have more thah one " + typeof( T ).Name + " In the scene, you only need one , all the instances will be destroyed for create a new one");
|
||||
|
||||
m_instance = singletons[0];
|
||||
|
||||
for(int n = 1 ; n < singletons.Length ; n++)
|
||||
{
|
||||
Destroy( singletons[n].gameObject );
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool ApplicationIsQuitting = false;
|
||||
public static event Action<T> OnInstanceCreated = null;
|
||||
|
||||
|
||||
public static bool DestroyOnLoad
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_instance.m_destroyOnLoad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField] protected bool m_destroyOnLoad = true;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if( !ReferenceEquals( (object)instance , (object)gameObject.GetComponent<T>() ))
|
||||
{
|
||||
//destroy repeat instance
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
//get the instance
|
||||
T singleton = instance;
|
||||
|
||||
if (!DestroyOnLoad && instance.transform.parent != null)
|
||||
{
|
||||
instance.transform.parent = null;
|
||||
}
|
||||
|
||||
|
||||
if(!DestroyOnLoad)
|
||||
{
|
||||
DontDestroyOnLoad( m_instance );
|
||||
}
|
||||
|
||||
OnInstanceCreated?.Invoke(instance);
|
||||
}
|
||||
|
||||
protected virtual void OnApplicationQuit()
|
||||
{
|
||||
ApplicationIsQuitting = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdf3ac4fd6895c446bc1df28b40af248
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/Singleton.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,215 @@
|
||||
// Author: Mathias Soeholm
|
||||
// Date: 05/10/2016
|
||||
// No license, do whatever you want with this script
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class TubeRenderer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Vector3[] _positions;
|
||||
[SerializeField] int _sides;
|
||||
[SerializeField] float _radiusOne;
|
||||
[SerializeField] float _radiusTwo;
|
||||
[SerializeField] bool _useWorldSpace = true;
|
||||
[SerializeField] bool _useTwoRadii = false;
|
||||
|
||||
private Vector3[] _vertices;
|
||||
private Mesh _mesh;
|
||||
private MeshFilter _meshFilter;
|
||||
private MeshRenderer _meshRenderer;
|
||||
|
||||
public Material material
|
||||
{
|
||||
get { return _meshRenderer.material; }
|
||||
set { _meshRenderer.material = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_meshFilter = GetComponent<MeshFilter>();
|
||||
if (_meshFilter == null)
|
||||
{
|
||||
_meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||
}
|
||||
|
||||
_meshRenderer = GetComponent<MeshRenderer>();
|
||||
if (_meshRenderer == null)
|
||||
{
|
||||
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
||||
}
|
||||
|
||||
_mesh = new Mesh();
|
||||
_meshFilter.mesh = _mesh;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_meshRenderer.enabled = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_meshRenderer.enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
GenerateMesh();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
_sides = Mathf.Max( 3, _sides );
|
||||
}
|
||||
|
||||
public void SetPositions(Vector3[] positions)
|
||||
{
|
||||
_positions = positions;
|
||||
GenerateMesh();
|
||||
}
|
||||
|
||||
private void GenerateMesh()
|
||||
{
|
||||
if (_mesh == null || _positions == null || _positions.Length <= 1)
|
||||
{
|
||||
_mesh = new Mesh();
|
||||
return;
|
||||
}
|
||||
|
||||
var verticesLength = _sides * _positions.Length;
|
||||
if (_vertices == null || _vertices.Length != verticesLength)
|
||||
{
|
||||
_vertices = new Vector3[verticesLength];
|
||||
|
||||
var indices = GenerateIndices();
|
||||
var uvs = GenerateUVs();
|
||||
|
||||
if (verticesLength > _mesh.vertexCount)
|
||||
{
|
||||
_mesh.vertices = _vertices;
|
||||
_mesh.triangles = indices;
|
||||
_mesh.uv = uvs;
|
||||
}
|
||||
else
|
||||
{
|
||||
_mesh.triangles = indices;
|
||||
_mesh.vertices = _vertices;
|
||||
_mesh.uv = uvs;
|
||||
}
|
||||
}
|
||||
|
||||
var currentVertIndex = 0;
|
||||
|
||||
for (int i = 0; i < _positions.Length; i++)
|
||||
{
|
||||
var circle = CalculateCircle( i );
|
||||
foreach (var vertex in circle)
|
||||
{
|
||||
_vertices[currentVertIndex++] = _useWorldSpace ? transform.InverseTransformPoint( vertex ) : vertex;
|
||||
}
|
||||
}
|
||||
|
||||
_mesh.vertices = _vertices;
|
||||
_mesh.RecalculateNormals();
|
||||
_mesh.RecalculateBounds();
|
||||
|
||||
_meshFilter.mesh = _mesh;
|
||||
}
|
||||
|
||||
private Vector2[] GenerateUVs()
|
||||
{
|
||||
var uvs = new Vector2[_positions.Length * _sides];
|
||||
|
||||
for (int segment = 0; segment < _positions.Length; segment++)
|
||||
{
|
||||
for (int side = 0; side < _sides; side++)
|
||||
{
|
||||
var vertIndex = ( segment * _sides + side );
|
||||
var u = side / ( _sides - 1f );
|
||||
var v = segment / ( _positions.Length - 1f );
|
||||
|
||||
uvs[vertIndex] = new Vector2( u, v );
|
||||
}
|
||||
}
|
||||
|
||||
return uvs;
|
||||
}
|
||||
|
||||
private int[] GenerateIndices()
|
||||
{
|
||||
// Two triangles and 3 vertices
|
||||
var indices = new int[_positions.Length * _sides * 2 * 3];
|
||||
|
||||
var currentIndicesIndex = 0;
|
||||
for (int segment = 1; segment < _positions.Length; segment++)
|
||||
{
|
||||
for (int side = 0; side < _sides; side++)
|
||||
{
|
||||
var vertIndex = ( segment * _sides + side );
|
||||
var prevVertIndex = vertIndex - _sides;
|
||||
|
||||
// Triangle one
|
||||
indices[currentIndicesIndex++] = prevVertIndex;
|
||||
indices[currentIndicesIndex++] = ( side == _sides - 1 ) ? ( vertIndex - ( _sides - 1 ) ) : ( vertIndex + 1 );
|
||||
indices[currentIndicesIndex++] = vertIndex;
|
||||
|
||||
|
||||
// Triangle two
|
||||
indices[currentIndicesIndex++] = ( side == _sides - 1 ) ? ( prevVertIndex - ( _sides - 1 ) ) : ( prevVertIndex + 1 );
|
||||
indices[currentIndicesIndex++] = ( side == _sides - 1 ) ? ( vertIndex - ( _sides - 1 ) ) : ( vertIndex + 1 );
|
||||
indices[currentIndicesIndex++] = prevVertIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
private Vector3[] CalculateCircle(int index)
|
||||
{
|
||||
var dirCount = 0;
|
||||
var forward = Vector3.zero;
|
||||
|
||||
// If not first index
|
||||
if (index > 0)
|
||||
{
|
||||
forward += ( _positions[index] - _positions[index - 1] ).normalized;
|
||||
dirCount++;
|
||||
}
|
||||
|
||||
// If not last index
|
||||
if (index < _positions.Length - 1)
|
||||
{
|
||||
forward += ( _positions[index + 1] - _positions[index] ).normalized;
|
||||
dirCount++;
|
||||
}
|
||||
|
||||
// Forward is the average of the connecting edges directions
|
||||
forward = ( forward / dirCount ).normalized;
|
||||
var side = Vector3.Cross( forward, forward + new Vector3( .123564f, .34675f, .756892f ) ).normalized;
|
||||
var up = Vector3.Cross( forward, side ).normalized;
|
||||
|
||||
var circle = new Vector3[_sides];
|
||||
var angle = 0f;
|
||||
var angleStep = ( 2 * Mathf.PI ) / _sides;
|
||||
|
||||
var t = index / ( _positions.Length - 1f );
|
||||
var radius = _useTwoRadii ? Mathf.Lerp( _radiusOne, _radiusTwo, t ) : _radiusOne;
|
||||
|
||||
for (int i = 0; i < _sides; i++)
|
||||
{
|
||||
var x = Mathf.Cos( angle );
|
||||
var y = Mathf.Sin( angle );
|
||||
|
||||
circle[i] = _positions[index] + side * x * radius + up * y * radius;
|
||||
|
||||
angle += angleStep;
|
||||
}
|
||||
|
||||
return circle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aab5dba822d59344b8a5a1a0262a44cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/TubeRenderer.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
//this is code for the demo wall cube
|
||||
public class WallCube : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float resetTime = 1.0f;
|
||||
|
||||
private WallCubePart[] wallCubePartArray = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
wallCubePartArray = transform.GetComponentsInChildren<WallCubePart>();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
for (int n = 0; n < wallCubePartArray.Length; n++)
|
||||
{
|
||||
wallCubePartArray[n].Reset( resetTime );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b717af3d5c3f9ee4e8456b0a4d182ba9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/WallCube.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace VRSDK
|
||||
{
|
||||
//wall cube demo code
|
||||
public class WallCubePart : MonoBehaviour
|
||||
{
|
||||
private Vector3 startPosition = Vector3.zero;
|
||||
private Quaternion startRotation = Quaternion.identity;
|
||||
private Rigidbody rb = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
startPosition = transform.position;
|
||||
startRotation = transform.rotation;
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
public void Reset(float t)
|
||||
{
|
||||
rb.isKinematic = true;
|
||||
|
||||
StartCoroutine(MoveRoutine(t));
|
||||
StartCoroutine( RotateRoutine (t));
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator MoveRoutine(float t)
|
||||
{
|
||||
float currentTime = 0.0f;
|
||||
|
||||
Vector3 currentPosition = transform.position;
|
||||
|
||||
while (currentTime < t)
|
||||
{
|
||||
currentTime += Time.deltaTime;
|
||||
transform.position = Vector3.Lerp( currentPosition, startPosition, currentTime / t );
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
transform.position = startPosition;
|
||||
|
||||
yield return new WaitForSeconds( 1.0f );
|
||||
rb.isKinematic = false;
|
||||
}
|
||||
|
||||
private IEnumerator RotateRoutine(float t)
|
||||
{
|
||||
float currentTime = 0.0f;
|
||||
|
||||
Quaternion currentRotation = transform.rotation;
|
||||
|
||||
while (currentTime < t)
|
||||
{
|
||||
currentTime += Time.deltaTime;
|
||||
transform.rotation = Quaternion.Slerp(currentRotation , startRotation , currentTime / t);
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
transform.rotation = startRotation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07fdd6486a96eac428777b474f30df03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Modules/VRSDK/Other/WallCubePart.cs
|
||||
uploadId: 546658
|
||||
Reference in New Issue
Block a user