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:
2026-05-21 23:37:34 +09:00
commit 4dad9e5d5b
1068 changed files with 175146 additions and 0 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eed2b109de0df7a48a51e4b964c56fa2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor.Animations;
#endif
namespace VRSDK
{
/// <summary>
/// This scripts helps handling the Animator
/// </summary>
public class AnimatorHelper : MonoBehaviour
{
[SerializeField] private List<LayerInfo> animatorControllerInfo = null;
[SerializeField] private float layerTransitionTime = 0.15f;
private Animator animator = null;
private Coroutine changeLayerValueCoroutine = null;
private void Awake()
{
animator = GetComponent<Animator>();
}
/// <summary>
/// Do smooth layer transition
/// </summary>
public void EnableLayer(int layer)
{
if (changeLayerValueCoroutine != null)
StopCoroutine( changeLayerValueCoroutine );
changeLayerValueCoroutine = StartCoroutine( ChangeLayerValueRoutine( layer, 1.0f, layerTransitionTime ) );
}
/// <summary>
/// Do smooth layer transition
/// </summary>
public void DisableLayer(int layer)
{
if (changeLayerValueCoroutine != null)
StopCoroutine( changeLayerValueCoroutine );
changeLayerValueCoroutine = StartCoroutine( ChangeLayerValueRoutine( layer, 0.0f, layerTransitionTime ) );
}
private IEnumerator ChangeLayerValueRoutine(int layer, float v, float t)
{
float timer = 0.0f;
while (timer < t)
{
float layerWeight = animator.GetLayerWeight( layer );
animator.SetLayerWeight( layer, Mathf.Lerp( layerWeight, v, timer / t ) );
timer += Time.deltaTime;
yield return new WaitForSeconds( Time.deltaTime );
}
animator.SetLayerWeight( layer, v );
}
/// <summary>
/// This method is really helpfull, you can know whethever the animator is playing certain state or trasition to it
/// </summary>
public bool IsPlayingOrTransitionToState(int layer , string stateName)
{
return IsPlayingState( layer, stateName ) || IsTransitionToState(layer , stateName);
}
/// <summary>
/// is the state name in layer being played?
/// </summary>
public bool IsPlayingState(int layer , string stateName)
{
return animator.GetCurrentAnimatorStateInfo( layer ).IsName( stateName );
}
/// <summary>
/// Is animator trasition to current state in layer
/// </summary>
public bool IsTransitionToState(int layer , string stateName)
{
List<string> states = animatorControllerInfo[layer].animatorStates;
for (int n = 0; n < states.Count; n++)
{
if (animator.GetAnimatorTransitionInfo( layer ).IsName( states[n] + " -> " + stateName ))
return true;
}
return false;
}
#if UNITY_EDITOR
/// in order to know if the animator is trasition to another state we need to know all state names before hand
/// but we can only know them using using UnityEditor.Animations namespace, so we ned to build this information in Editor
/// and serialized it so we can access it later in running time, this method is called in I_AnimatorHelperInspector.cs in the Awake
public void ConstructAnimatorControllerInfo()
{
animatorControllerInfo = new List<LayerInfo>();
AnimatorController ac = GetComponent<Animator>().runtimeAnimatorController as AnimatorController;
AnimatorControllerLayer[] layerArray = ac.layers;
for (int n = 0; n < layerArray.Length; n++)
{
LayerInfo info = new LayerInfo();
info.animatorStates = GetStatesFromLayer( layerArray[n] ); ;
animatorControllerInfo.Add(info);
}
}
private List<string> GetStatesFromLayer(AnimatorControllerLayer layer)
{
List<string> states = new List<string>();
for (int n = 0; n < layer.stateMachine.states.Length; n++)
{
states.Add( layer.stateMachine.states[n].state.name );
}
return states;
}
#endif
}
/// <summary>
/// serialize class for storing animator state names
/// </summary>
[System.Serializable]
public class LayerInfo
{
public List<string> animatorStates = new List<string>();
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ed793d0597bff0a4f8289e720b57ad82
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/Animator/AnimatorHelper.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b164a25599b2e8c4fad4c82186058ceb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,92 @@
using UnityEngine;
namespace VRSDK.Climbing
{
public class ClimbPoint : VR_Grabbable
{
[SerializeField] private ClimbingTarget target = null;
[SerializeField] private float dropRange = 0.2f;
private Vector3 startGrabPos = Vector3.zero;
private Vector3 startLocalPos = Vector3.zero;
public bool isActive = false;
protected override void Start()
{
base.Start();
target = FindObjectOfType<ClimbingTarget>();
onGrabStateChange.AddListener( OnGrabStateChangeClimb );
}
private void LateUpdate()
{
if ( IsActiveOrGrabbed() )
return;
if (ShouldDropClimbPoint())
{
ForceDrop();
}
}
private float CalculateDistanceToHand()
{
return Vector3.Distance(GetCurrentHandInteractSettings().interactPoint.position, GrabController.OriginalParent.position);
}
private bool IsActiveOrGrabbed()
{
return isActive || currentGrabState != GrabState.Grab;
}
private bool ShouldDropClimbPoint()
{
float d = CalculateDistanceToHand();
return d > dropRange;
}
private void OnGrabStateChangeClimb(GrabState state)
{
if (state == GrabState.Grab)
{
transform.SetParent(null);
Destroy(GrabController.GrabPoint.GetComponent<Joint>());
GrabController.UseRotationOffset = false;
GrabController.SetPositionControlMode(MotionControlMode.Free);
GrabController.transform.SetParent(null);
GrabController.transform.position = GetCurrentHandInteractSettings().interactPoint.position;
GrabController.transform.rotation = Quaternion.Euler( GetCurrentHandInteractSettings().rotationOffset ) * GrabController.RotationOffset;
rb.isKinematic = true;
target.AddActiveClimbPoint(this);
}
else if (state == GrabState.Drop)
{
isActive = false;
}
}
public void SetClimbingPosition()
{
if (currentGrabState == GrabState.Grab)
{
Vector3 positionDiff = GrabController.OriginalParent.localPosition - startLocalPos;
positionDiff *= -1;
Vector3 worldPos = VR_Manager.instance.Player.TrackingSpace.rotation * positionDiff;
target.transform.position = (startGrabPos + worldPos);
}
}
public void OnClimbPointActive()
{
startLocalPos = GrabController.OriginalParent.localPosition;
startGrabPos = target.transform.position;
isActive = true;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3804073d29ca83f41b35dbf7c5862e62
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/Climbing/ClimbPoint.cs
uploadId: 546658
@@ -0,0 +1,85 @@
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Events;
namespace VRSDK.Climbing
{
/// <summary>
/// Use this script in the GameObject being affected by climbing in our case the Player gameObject
/// </summary>
public class ClimbingTarget : MonoBehaviour
{
[SerializeField] private UnityEvent onClimbStart = null;
[SerializeField] private UnityEvent onClimbEnd = null;
private List<ClimbPoint> climbPointList = new List<ClimbPoint>();
private ClimbPoint activeClimbPoint = null;
public UnityEvent OnClimbStart { get { return onClimbStart; } }
public UnityEvent OnClimbEnd { get { return onClimbEnd; } }
private void Update()
{
if (activeClimbPoint != null)
{
activeClimbPoint.SetClimbingPosition();
}
}
private void OnClimbPointReleased(ClimbPoint climbPoint)
{
climbPointList.Remove(climbPoint);
if (activeClimbPoint == climbPoint)
{
activeClimbPoint = GetActiveClimbPoint();
if (activeClimbPoint != null)
{
activeClimbPoint.OnClimbPointActive();
}
else
{
onClimbEnd.Invoke();
}
}
}
public void AddActiveClimbPoint(ClimbPoint climbPoint)
{
climbPointList.Add(climbPoint);
climbPoint.OnGrabStateChange.AddListener( delegate(GrabState state)
{
if (state == GrabState.Drop)
{
OnClimbPointReleased(climbPoint);
}
} );
if (activeClimbPoint == null)
{
activeClimbPoint = GetActiveClimbPoint();
if (activeClimbPoint != null)
{
activeClimbPoint.OnClimbPointActive();
onClimbStart.Invoke();
}
}
}
private ClimbPoint GetActiveClimbPoint()
{
if (climbPointList.Count == 0)
return null;
return climbPointList[0];
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e1ec8244b089c744abb68d250d178409
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/Climbing/ClimbingTarget.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9402bac8225d89d439f21f61c0fe8022
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,56 @@
using System.Collections.Generic;
namespace VRSDK.Collections
{
public class Buffer<T>
{
private List<T> elements;
private int size;
public T this[int index]
{
get
{
return elements[index];
}
set
{
elements[index] = value;
}
}
public int Count { get { return elements.Count; } }
public Buffer(int size)
{
this.size = size;
elements = new List<T>( size );
}
public void Add(T item)
{
elements.Add( item );
if (elements.Count > size)
{
elements.RemoveAt( 0 );
}
}
public void Remove(T item)
{
elements.Remove( item );
}
public List<T> Sample(int size)
{
if (size > elements.Count)
return elements;
return elements.GetRange(elements.Count - size , size);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 770e28f01d6a3e14b86b7d8bf383c36c
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/Collections/Buffer.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e8b879dbf2779f40848174be4f7de4b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
using UnityEditor;
namespace VRSDK.EditorCode
{
[CustomEditor(typeof(AnimatorHelper))]
public class I_AnimatorHelperInspector : Editor
{
private void Awake()
{
( target as AnimatorHelper ).ConstructAnimatorControllerInfo();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 59b3f90f5357c9448901878af57a2c30
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/Editor/I_AnimatorHelperInspector.cs
uploadId: 546658
@@ -0,0 +1,13 @@
using UnityEditor;
using VRSDK.Climbing;
namespace VRSDK.EditorCode
{
[CustomEditor(typeof(ClimbPoint))]
public class I_VR_ClimbPointInspector : I_VR_GrabbableInspector
{
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fcc59dacb29a235469e8fb0f08d7dee7
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/Editor/I_VR_ClimbPointInspector.cs
uploadId: 546658
@@ -0,0 +1,65 @@
using Platinio.SDK.EditorTools;
using UnityEditor;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor(typeof(VR_DistanceGrab))]
public class I_VR_DistanceGrabInspector : Editor
{
private SerializedProperty pointerTransform = null;
private SerializedProperty grabDistance = null;
private SerializedProperty grabRadius = null;
private SerializedProperty checkForObstruction = null;
private SerializedProperty guideLineAlwaysVisible = null;
private SerializedProperty canTriggerLineRender = null;
private SerializedProperty lineTriggerInput = null;
private SerializedProperty lineRender = null;
private SerializedProperty layerMask = null;
private void OnEnable()
{
pointerTransform = serializedObject.FindProperty( "pointerTransform" );
grabDistance = serializedObject.FindProperty( "grabDistance" );
grabRadius = serializedObject.FindProperty( "grabRadius" );
checkForObstruction = serializedObject.FindProperty( "checkForObstruction" );
guideLineAlwaysVisible = serializedObject.FindProperty( "guideLineAlwaysVisible" );
canTriggerLineRender = serializedObject.FindProperty( "canTriggerLineRender" );
lineTriggerInput = serializedObject.FindProperty( "lineTriggerInput" );
lineRender = serializedObject.FindProperty( "lineRender" );
layerMask = serializedObject.FindProperty( "layerMask" );
}
public override void OnInspectorGUI()
{
PlatinioEditorGUILayout.PropertyField(pointerTransform);
PlatinioEditorGUILayout.PropertyField(grabDistance);
PlatinioEditorGUILayout.PropertyField(grabRadius);
PlatinioEditorGUILayout.PropertyField(checkForObstruction);
PlatinioEditorGUILayout.PropertyField(guideLineAlwaysVisible);
if (!guideLineAlwaysVisible.boolValue)
{
PlatinioEditorGUILayout.PropertyField( canTriggerLineRender );
if (canTriggerLineRender.boolValue)
PlatinioEditorGUILayout.PropertyField( lineTriggerInput );
}
else
{
canTriggerLineRender.boolValue = false;
}
PlatinioEditorGUILayout.PropertyField(lineRender);
PlatinioEditorGUILayout.PropertyField(layerMask);
serializedObject.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2d02b46e6b5ee3849ba0e2f03d444026
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/Editor/I_VR_DistanceGrabInspector.cs
uploadId: 546658
@@ -0,0 +1,120 @@
using Platinio.SDK.EditorTools;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor( typeof( VR_DropZone ) )]
public class I_VR_DropZoneInspector : Editor
{
private VR_DropZone targetScript = null;
private SerializedProperty dropZoneMode = null;
private SerializedProperty dropPoint = null;
private SerializedProperty dropZoneColliderArray = null;
private SerializedProperty startingDrop = null;
private SerializedProperty shouldFly = null;
private SerializedProperty flyTime = null;
private SerializedProperty syncronizePosition = null;
private SerializedProperty syncronizeRot = null;
private SerializedProperty dropRadius = null;
private SerializedProperty usePreview = null;
private SerializedProperty onDropStateChange = null;
private SerializedProperty disableCollidersOnDrop = null;
private SerializedProperty canStack = null;
private void OnEnable()
{
targetScript = (VR_DropZone) target;
dropZoneMode = serializedObject.FindProperty( "dropZoneMode" );
dropPoint = serializedObject.FindProperty( "dropPoint" );
dropZoneColliderArray = serializedObject.FindProperty( "dropZoneColliderArray" );
startingDrop = serializedObject.FindProperty( "startingDrop" );
shouldFly = serializedObject.FindProperty( "shouldFly" );
flyTime = serializedObject.FindProperty( "flyTime" );
syncronizePosition = serializedObject.FindProperty( "syncronizePosition" );
syncronizeRot = serializedObject.FindProperty( "syncronizeRot" );
dropRadius = serializedObject.FindProperty( "dropRadius" );
usePreview = serializedObject.FindProperty( "usePreview" );
onDropStateChange = serializedObject.FindProperty( "onDrop" );
disableCollidersOnDrop = serializedObject.FindProperty( "disableCollidersOnDrop" );
canStack = serializedObject.FindProperty( "canStack" );
}
public override void OnInspectorGUI()
{
PlatinioEditorGUILayout.PropertyField( dropZoneMode );
PlatinioEditorGUILayout.PropertyField( dropPoint );
PlatinioEditorGUILayout.PropertyField( startingDrop );
if ((DropZoneMode) dropZoneMode.enumValueIndex == DropZoneMode.Collider)
{
PlatinioEditorGUILayout.PropertyField( dropZoneColliderArray, true );
}
else
{
PlatinioEditorGUILayout.PropertyField( dropRadius );
}
PlatinioEditorGUILayout.PropertyField( shouldFly );
if (shouldFly.boolValue)
{
PlatinioEditorGUILayout.PropertyField( flyTime );
}
PlatinioEditorGUILayout.PropertyField( syncronizePosition );
PlatinioEditorGUILayout.PropertyField( syncronizeRot );
PlatinioEditorGUILayout.PropertyField( usePreview );
PlatinioEditorGUILayout.PropertyField(canStack);
PlatinioEditorGUILayout.PropertyField(disableCollidersOnDrop);
PlatinioEditorGUILayout.PropertyField( onDropStateChange );
serializedObject.ApplyModifiedProperties();
}
public void OnSceneGUI()
{
if (targetScript == null)
OnEnable();
if (targetScript.DropPoint == null)
return;
if (targetScript.DropPoint == null || (DropZoneMode) dropZoneMode.enumValueIndex == DropZoneMode.Collider)
return;
//handler for dropzone range
EditorGUI.BeginChangeCheck();
Handles.color = Color.blue;
float r = Handles.RadiusHandle( Quaternion.identity, targetScript.DropPoint.position, dropRadius.floatValue );
if (GUI.changed)
{
targetScript.SetDropRadiusViaInspector( r );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject( target, "Changed Drop Distance" );
targetScript.SetDropRadiusViaInspector(r);
EditorUtility.SetDirty(targetScript);
EditorSceneManager.MarkAllScenesDirty();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a5869d5d67f00664c83d4a9c0b2d1095
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/Editor/I_VR_DropZoneInspector.cs
uploadId: 546658
@@ -0,0 +1,586 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using System;
using System.Collections.Generic;
using Platinio.SDK.EditorTools;
using UnityEditor.EditorTools;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor(typeof(VR_Grabbable))]
public class I_VR_GrabbableInspector : Editor
{
private SerializedProperty onGrabStateChange = null;
private SerializedProperty perfectGrab = null;
private SerializedProperty grabDistance = null;
private SerializedProperty grabFlyTime = null;
private SerializedProperty shouldFly = null;
private SerializedProperty startOnRightController = null;
private SerializedProperty startOnLeftController = null;
private SerializedProperty autoGrab = null;
private SerializedProperty grabButton = null;
private SerializedProperty grabLayer = null;
private SerializedProperty unGrabLayer = null;
private SerializedProperty enableColliderOnGrab = null;
private SerializedProperty shareHandInteractSettings = null;
private SerializedProperty shareHandAnimationSettings = null;
private SerializedProperty leftHandSettings = null;
private SerializedProperty handSettings = null;
private SerializedProperty rightHandSettings = null;
private SerializedProperty preserveKinematicState = null;
private SerializedProperty useDistanceGrab = null;
private SerializedProperty ignoreColliderList = null;
private SerializedProperty toggleGrab = null;
private SerializedProperty grabbableCollider = null;
private SerializedProperty interactableType = null;
private Texture handIcon = null;
private Texture playIcon = null;
private Texture eventIcon = null;
private Texture settingsIcon = null;
protected VR_Grabbable grabbable = null;
protected VR_GrabbableEditorPart editorPart = null;
protected List<ConsoleMessage> consoleList = null;
protected virtual void OnEnable()
{
GetSerializeProperties();
LoadIcons();
grabbable = (VR_Grabbable) target;
editorPart = grabbable.EditorPart;
}
private void GetSerializeProperties()
{
onGrabStateChange = serializedObject.FindProperty("onGrabStateChange");
perfectGrab = serializedObject.FindProperty("perfectGrab");
grabDistance = serializedObject.FindProperty("interactDistance");
grabFlyTime = serializedObject.FindProperty("grabFlyTime");
shouldFly = serializedObject.FindProperty("shouldFly");
startOnRightController = serializedObject.FindProperty("startOnRightController");
startOnLeftController = serializedObject.FindProperty("startOnLeftController");
autoGrab = serializedObject.FindProperty("autoGrab");
grabButton = serializedObject.FindProperty("interactButton");
grabLayer = serializedObject.FindProperty("grabLayer");
unGrabLayer = serializedObject.FindProperty("unGrabLayer");
enableColliderOnGrab = serializedObject.FindProperty("enableColliderOnGrab");
shareHandInteractSettings = serializedObject.FindProperty("shareHandInteractionSettings");
shareHandAnimationSettings = serializedObject.FindProperty("shareHandAnimationSettings");
rightHandSettings = serializedObject.FindProperty("rightHandSettings");
leftHandSettings = serializedObject.FindProperty("leftHandSettings");
handSettings = serializedObject.FindProperty("handSettings");
preserveKinematicState = serializedObject.FindProperty("preserveKinematicState");
useDistanceGrab = serializedObject.FindProperty("useDistanceGrab");
ignoreColliderList = serializedObject.FindProperty("ignoreColliderList");
toggleGrab = serializedObject.FindProperty("toggleGrab");
interactableType = serializedObject.FindProperty("interactableType");
grabbableCollider = serializedObject.FindProperty("grabCollider");
}
private void LoadIcons()
{
handIcon = PlatinioEditorGUILayout.LoadIcon("hand");
playIcon = PlatinioEditorGUILayout.LoadIcon("play");
eventIcon = PlatinioEditorGUILayout.LoadIcon("calendar");
settingsIcon = PlatinioEditorGUILayout.LoadIcon("settings");
}
public override void OnInspectorGUI()
{
EditorGUILayout.Space(10);
consoleList = new List<ConsoleMessage>();
editorPart.selectedMenu = (GrabSelectionMenu) PlatinioEditorGUILayout.DrawGridButtons( (int) editorPart.selectedMenu, 2 ,
new GUIContent(" Animation" , playIcon),
new GUIContent(" Grab Settings", handIcon),
new GUIContent(" Other", settingsIcon),
new GUIContent(" Events", eventIcon)
);
EditorGUILayout.Space(30);
if (editorPart.selectedMenu == GrabSelectionMenu.Animation)
{
DrawGrabbableAnimationSettings();
}
else if (editorPart.selectedMenu == GrabSelectionMenu.GrabSettings)
{
DrawGrabSettings();
}
else if (editorPart.selectedMenu == GrabSelectionMenu.Other)
{
DrawOtherSettings();
}
else if (editorPart.selectedMenu == GrabSelectionMenu.Events)
{
DrawEventSettings();
}
ConsoleUpdate();
EditorGUILayout.Space(20);
GUIContent content = new GUIContent("Console (" + consoleList.Count + ")", "");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutConsole , delegate { DrawConsole(); });
EditorGUILayout.Space(10);
serializedObject.ApplyModifiedProperties();
}
private void DrawConsole()
{
PlatinioEditorGUILayout.DrawConsole(consoleList);
}
private void ConsoleUpdate()
{
AnimationSettingsConsoleUpdate();
GrabSettingsConsoleUpdate();
}
private void DrawGrabbableAnimationSettings()
{
DrawGrabbableAnimationSettingsHeader();
EditorGUILayout.Space(20);
DrawGrabbableAnimationSettingsBody();
}
protected virtual void DrawGrabbableAnimationSettingsHeader()
{
PlatinioEditorGUILayout.DrawTooltipBox(playIcon, "Animation Settings",
"You can define diferent grab animations for each hand, and you can leave it empty if you don't wanna play any animation," +
" some people prefer to hide the hand while grabbing something too.");
}
protected virtual void DrawGrabbableAnimationSettingsBody()
{
SerializedProperty rightHand = serializedObject.FindProperty("rightHandAnimationSettings");
SerializedProperty leftHand = serializedObject.FindProperty("leftHandAnimationSettings");
SerializedProperty share = serializedObject.FindProperty("handAnimationSettings");
GUIContent content = new GUIContent("Share Settings?", "Use the same settings for the left and right hand?");
shareHandAnimationSettings.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, shareHandAnimationSettings.boolValue);
if (shareHandAnimationSettings.boolValue)
{
content = new GUIContent("Both Hands", "Share settings for both hands");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutShareHandAnimationSettings, delegate { DrawHandAnimationSettings(share); });
}
else
{
content = new GUIContent("Left Hand", "Left hand animation settings");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutRightHandAnimationSettings, delegate { DrawHandAnimationSettings(leftHand); });
EditorGUILayout.Space();
content = new GUIContent("Right Hand", "Right hand animation settings");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutLeftHandAnimationSettings, delegate { DrawHandAnimationSettings(rightHand); });
}
}
private void AnimationSettingsConsoleUpdate()
{
VR_HandAnimationSettings leftHand = grabbable.LeftHandAnimationSettings;
VR_HandAnimationSettings rightHand = grabbable.RightHandAnimationSettings;
VR_HandAnimationSettings share = grabbable.HandAnimationSettings;
ConsoleMessage animationEmptyLog = new ConsoleMessage("You have missing grab animations, default grab animation will be use", MessageType.Warning);
if (shareHandAnimationSettings.boolValue)
{
if (!share.hideHandOnGrab && share.animation == null)
consoleList.Add(animationEmptyLog);
}
else
{
if (!leftHand.hideHandOnGrab && leftHand.animation == null)
consoleList.Add(animationEmptyLog);
else if (!rightHand.hideHandOnGrab && rightHand.animation == null)
consoleList.Add(animationEmptyLog);
}
}
private void GrabSettingsConsoleUpdate()
{
VR_HandInteractSettings leftHand = grabbable.LeftHandSettings;
VR_HandInteractSettings rightHand = grabbable.RightHandSettings;
VR_HandInteractSettings share = grabbable.HandSettings;
ConsoleMessage grabPointMissing = new ConsoleMessage("You forget to assign a grab point in GrabSettings", MessageType.Error);
ConsoleMessage highlightPointMissing = new ConsoleMessage("You forget to assign a higlight point in GrabSettings", MessageType.Warning);
if (!shareHandInteractSettings.boolValue)
{
if ( editorPart.IsMissingGrabPoint( rightHand ) || editorPart.IsMissingGrabPoint(leftHand ))
consoleList.Add(grabPointMissing);
if ( editorPart.IsMissinHiglightPoint(rightHand) || editorPart.IsMissinHiglightPoint(leftHand) )
consoleList.Add(highlightPointMissing);
}
else
{
Debug.Log("share hand interact settings value " + shareHandAnimationSettings.boolValue);
if ( editorPart.IsMissingGrabPoint(share) )
consoleList.Add(grabPointMissing);
if (editorPart.IsMissinHiglightPoint(share))
consoleList.Add(highlightPointMissing);
}
}
private void DrawHandAnimationSettings(SerializedProperty property)
{
SerializedProperty hideOnGrab = property.FindPropertyRelative("hideHandOnGrab");
SerializedProperty animation = property.FindPropertyRelative("animation");
EditorGUILayout.BeginVertical("Box");
GUIContent content = new GUIContent("Hide Hand?", "Should this hand hide while grabbing the object?");
hideOnGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , hideOnGrab.boolValue);
if (!hideOnGrab.boolValue)
{
content = new GUIContent("Grab Animation", "The animation use while grabbing the object");
EditorGUILayout.PropertyField(animation , content);
}
EditorGUILayout.EndVertical();
}
private void DrawGrabSettings()
{
DrawGrabSettingsHeader();
PlatinioEditorGUILayout.Space(3);
DrawGrabSettingsBody();
}
protected virtual void DrawGrabSettingsHeader()
{
PlatinioEditorGUILayout.DrawTooltipBox(handIcon, "Grab Settings",
"In this section you can define the behavior of the grabbable object, for example should this object move to the hand position? use " +
"toggle or use auto grab feature");
}
protected virtual void DrawGrabSettingsBody()
{
GUIContent content = new GUIContent("Basic", "Grabbable basic settings");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutBasic, DrawGrabBasicSettings);
PlatinioEditorGUILayout.Space(2);
content = new GUIContent("Interaction", "Grabbable interaction settings");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutInteraction, DrawHandInteractionSettings);
PlatinioEditorGUILayout.Space(2);
content = new GUIContent("Input", "Grabbable input settings");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutInput, DrawGrabInput);
content = new GUIContent("Editor Tools", "");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutEditorTools, DrawEditorTools);
}
private void DrawEditorTools()
{
EditorGUILayout.BeginVertical("Box");
if (GUILayout.Button("Update Grab Position Offset"))
{
grabbable.UpdateGrabPositionOffset();
}
EditorGUILayout.EndVertical();
}
protected virtual void DrawGrabInput()
{
EditorGUILayout.BeginVertical("Box");
GUIContent content = new GUIContent("Use Auto Grab", "Button use in controller for grabbing");
autoGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , autoGrab.boolValue);
if (!autoGrab.boolValue)
{
grabbable.SetStartOnLeftHand(false);
grabbable.SetStartOnRightHand(false);
content = new GUIContent("Grab Button", "Button use in controller for grabbing");
grabButton.enumValueIndex = (int)(VR_InputButton)EditorGUILayout.EnumPopup(content, (VR_InputButton) grabButton.enumValueIndex);
content = new GUIContent("Use Toggle", "Button use in controller for grabbing");
toggleGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , toggleGrab.boolValue);
}
else
{
int newSelection = startOnLeftController.boolValue ? 1 : 0;
newSelection = PlatinioEditorGUILayout.DrawGridButtons(newSelection, 2,
new GUIContent(" Right Hand"),
new GUIContent(" Left Hand")
);
startOnLeftController.boolValue = newSelection == 1;
startOnRightController.boolValue = newSelection == 0;
editorPart.handSelected = newSelection;
}
EditorGUILayout.EndVertical();
}
protected virtual void DrawGrabBasicSettings()
{
EditorGUILayout.BeginVertical("Box");
GUIContent content = new GUIContent("Use Distance Grab?", "Enable this object to be grabbed by the user very far away " +
"by just pointing the hand to the object and pressing the grab button");
useDistanceGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, useDistanceGrab.boolValue);
content = new GUIContent("Grab Distance", "How far the hand can be it order to grab the object");
grabDistance.floatValue = EditorGUILayout.FloatField(content, grabDistance.floatValue);
content = new GUIContent("Update Grab Point?", "If in use the object grab point will be update base on the hand position");
perfectGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , perfectGrab.boolValue);
if (!perfectGrab.boolValue)
{
content = new GUIContent("Use Fly?", "Should this object fly to the hand?");
shouldFly.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , shouldFly.boolValue);
if (shouldFly.boolValue)
{
content = new GUIContent("Fly Time", "time in seconds use in order to fly to the hand");
grabFlyTime.floatValue = EditorGUILayout.FloatField(content, grabFlyTime.floatValue);
}
}
content = new GUIContent("Interactable Type", "The type of interactable type (Recommended Distance)");
interactableType.enumValueIndex = (int)(InteractableType)EditorGUILayout.EnumPopup(content, (InteractableType) interactableType.enumValueIndex);
if (interactableType.enumValueIndex == (int) InteractableType.Collider)
{
content = new GUIContent("Grabbable Collider", "Collider use to detect interactions");
grabbableCollider.objectReferenceValue = EditorGUILayout.ObjectField(content, grabbableCollider.objectReferenceValue, typeof(Collider), true);
if (grabbableCollider.objectReferenceValue == null)
{
ConsoleMessage colliderMissing = new ConsoleMessage("You forget to assign an interact collider in Grab Settings", MessageType.Error);
consoleList.Add(colliderMissing);
}
}
EditorGUILayout.EndVertical();
}
protected virtual void DrawHandInteractionSettings()
{
EditorGUILayout.BeginVertical("Box");
SerializedProperty share = serializedObject.FindProperty("handSettings");
SerializedProperty leftHand = serializedObject.FindProperty("leftHandSettings");
SerializedProperty rightHand = serializedObject.FindProperty("rightHandSettings");
GUIContent content = new GUIContent("Share Settings?", "Use the same settings for the left and right hand?");
shareHandInteractSettings.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , shareHandInteractSettings.boolValue);
if (shareHandInteractSettings.boolValue)
{
content = new GUIContent("Both Hands", "Share settings for both hands");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutShareHandInteractSettings, 1, delegate { DrawHandInteractionInspector(share); });
}
else
{
content = new GUIContent("Right Hand", "Settings apply just to the right hand");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutRightHandInteractSettings, 1, delegate { DrawHandInteractionInspector(rightHand); });
content = new GUIContent("Left Hand", "Settings apply just to the left hand");
PlatinioEditorGUILayout.FoldoutInspector(content, ref editorPart.foldoutLeftHandInteractSettings, 1, delegate { DrawHandInteractionInspector(leftHand); });
}
EditorGUILayout.EndVertical();
}
private void DrawHandInteractionInspector(SerializedProperty property)
{
GUIContent content;
Rect rect;
SerializedProperty canInteract = property.FindPropertyRelative("canInteract");
SerializedProperty interactPoint = property.FindPropertyRelative("interactPoint");
SerializedProperty higlightPoint = property.FindPropertyRelative("highlightPoint");
SerializedProperty rotationOffset = property.FindPropertyRelative("rotationOffset");
if (!shareHandInteractSettings.boolValue)
{
content = new GUIContent("Can Grab?", "Can this hand grab the object?");
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
rect.width -= 25;
rect.x += 25;
canInteract.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content , rect , canInteract.boolValue);
EditorGUILayout.Space(3);
}
else
{
property.FindPropertyRelative("canInteract").boolValue = true;
}
if (canInteract.boolValue)
{
content = new GUIContent("Grab Point", "The point from where this object can be grabbed");
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
rect.width -= 25;
rect.x += 25;
EditorGUI.PropertyField(rect, interactPoint, content);
EditorGUILayout.Space(3);
content = new GUIContent("Highlight Point", "The point from where this object start the higlight");
rect = GUILayoutUtility.GetRect(40f, 60f, 16f, 16f);
rect.width -= 25;
rect.x += 25;
EditorGUI.PropertyField(rect, higlightPoint, content);
content = new GUIContent("Rotation offset", "The rotation offset used while the object is being grab");
rect = GUILayoutUtility.GetRect(80f, 80f, 45f, 45f);
rect.width -= 25;
rect.x += 25;
EditorGUI.PropertyField(rect , rotationOffset , content);
}
}
private void DrawOtherSettings()
{
DrawOtherSettingsHeader();
EditorGUILayout.Space(10);
EditorGUILayout.BeginVertical("Box");
DrawOtherSettingsBody();
EditorGUILayout.EndVertical();
}
protected virtual void DrawOtherSettingsHeader()
{
PlatinioEditorGUILayout.DrawTooltipBox(settingsIcon, "Other Settings",
"In this section you have no so common settings but still useful in some cases");
}
protected virtual void DrawOtherSettingsBody()
{
GUIContent content = new GUIContent("Preserve Kinematic? ", "The normal behaviour in a grabbable item is override the kinematic state " +
"of the object so I can respond to physics once it is dropped, use this if you wanna to preserve the kinematic state of an object once it is dropped");
preserveKinematicState.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, preserveKinematicState.boolValue);
content = new GUIContent("Use Collider? ", "Use collider while grabbing?");
enableColliderOnGrab.boolValue = PlatinioEditorGUILayout.DrawBoolEnum(content, enableColliderOnGrab.boolValue);
content = new GUIContent("Grab Layer ", "Collision layer used while this object is in grab state");
grabLayer.intValue = EditorGUILayout.LayerField(content, grabLayer.intValue);
content = new GUIContent("UnGrab Layer ", "Collision layer used while this object is ungrab state");
unGrabLayer.intValue = EditorGUILayout.LayerField(content, unGrabLayer.intValue);
PlatinioEditorGUILayout.PropertyField(ignoreColliderList, true);
}
private void DrawEventSettings()
{
DrawEventSettingsHeader();
EditorGUILayout.Space(10);
DrawEventSettingsBody();
}
protected virtual void DrawEventSettingsHeader()
{
PlatinioEditorGUILayout.DrawTooltipBox(eventIcon, "Events",
"You can control the logic from your grabbables in your game mostly by using this event, it sends an enum called" +
"GrabState, and every value define a diferent action made by the user.\n\n" +
"<b>Grab:</b> called the first frame when the player try to grab this object.\n" +
"<b>Drop:</b> called the first frame when the player drops this object.\n" +
"<b>UnGrab:</b> called inmediatly after drop, and stay in UnGrab state until grab event is raise again\n");
}
protected virtual void DrawEventSettingsBody()
{
EditorGUILayout.BeginVertical("Box");
PlatinioEditorGUILayout.PropertyField(onGrabStateChange);
EditorGUILayout.EndVertical();
}
public void OnSceneGUI()
{
float newGrabDistance = grabbable.GrabDistance;
Transform center = null;
if (shareHandInteractSettings.boolValue)
{
center = grabbable.HandSettings.interactPoint;
}
else
{
center = grabbable.RightHandSettings.interactPoint == null ? grabbable.LeftHandSettings.interactPoint : grabbable.RightHandSettings.interactPoint;
}
if (center == null)
center = grabbable.transform;
newGrabDistance = DrawDiscRadiusHandler(center.position, newGrabDistance);
grabbable.SetInteractDistanceViaInspector(newGrabDistance);
EditorUtility.SetDirty(grabbable);
}
private float DrawDiscRadiusHandler(Vector3 center , float radius)
{
if (Camera.current == null)
return radius;
Handles.color = Color.blue;
Handles.color = new Color(0.0f, 0.0f, 1.0f, 0.125f);
Handles.DrawSolidDisc(center, Camera.current.transform.forward, radius);
Handles.color = new Color(0.0f, 0.0f, 1.0f, 1.0f);
return Handles.RadiusHandle(Quaternion.LookRotation(Camera.current.transform.forward * -1.0f), center, radius, true);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 328f8501609a35d45b2cf5a39771103e
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/Editor/I_VR_GrabbableInspector.cs
uploadId: 546658
@@ -0,0 +1,101 @@
using Platinio.SDK.EditorTools;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor( typeof( VR_GrabbableZone ) )]
public class I_VR_GrabbableZoneInspector : Editor
{
private SerializedProperty interactDistance = null;
private SerializedProperty interactButton = null;
private SerializedProperty usePerHandSettings = null;
private SerializedProperty leftHandSettings = null;
private SerializedProperty handSettings = null;
private SerializedProperty rightHandSettings = null;
private SerializedProperty grabbable = null;
private VR_GrabbableZone targetScript = null;
private void OnEnable()
{
interactDistance = serializedObject.FindProperty( "interactDistance" );
interactButton = serializedObject.FindProperty( "interactButton" );
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
handSettings = serializedObject.FindProperty( "handSettings" );
grabbable = serializedObject.FindProperty("grabbable");
targetScript = (VR_GrabbableZone) target;
}
public override void OnInspectorGUI()
{
PlatinioEditorGUILayout.PropertyField( grabbable );
PlatinioEditorGUILayout.PropertyField( interactDistance );
serializedObject.ApplyModifiedProperties();
}
private void DrawHandSettings(SerializedProperty settings)
{
EditorGUILayout.PropertyField( settings, true );
}
public void OnSceneGUI()
{/*
if (targetScript == null)
OnEnable();
EditorGUI.BeginChangeCheck();
Handles.color = Color.blue;
if (usePerHandSettings.boolValue)
{
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, interactDistance.floatValue );
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, interactDistance.floatValue );
UpdateGrabDistanceValue( rightValue, leftValue );
}
else
{
if (targetScript.HighlightPointHandSettings == null)
return;
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, interactDistance.floatValue );
targetScript.Grabbable.SetInteractDistanceViaInspector( value);
EditorUtility.SetDirty( targetScript );
//EditorSceneManager.MarkAllScenesDirty();
}
*/
}
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
{
if (interactDistance.floatValue != rightValue)
{
targetScript.Grabbable.SetInteractDistanceViaInspector( rightValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
else if (interactDistance.floatValue != leftValue)
{
targetScript.Grabbable.SetInteractDistanceViaInspector( leftValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 62671d04d4f0c154baa3afa01f4c2444
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/Editor/I_VR_GrabbableZoneInspector.cs
uploadId: 546658
@@ -0,0 +1,112 @@
using Platinio.SDK.EditorTools;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor(typeof(VR_Interactable))]
public class I_VR_InteractableInspector : Editor
{
private SerializedProperty interactDistance = null;
private SerializedProperty interactButton = null;
private SerializedProperty usePerHandSettings = null;
private SerializedProperty leftHandSettings = null;
private SerializedProperty handSettings = null;
private SerializedProperty rightHandSettings = null;
private SerializedProperty onInteractEvent = null;
private VR_Interactable targetScript = null;
private void OnEnable()
{
interactDistance = serializedObject.FindProperty("interactDistance");
interactButton = serializedObject.FindProperty("interactButton");
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
handSettings = serializedObject.FindProperty( "handSettings" );
onInteractEvent = serializedObject.FindProperty( "onInteractEvent" );
targetScript = (VR_Interactable) target;
}
public override void OnInspectorGUI()
{
PlatinioEditorGUILayout.PropertyField( interactDistance );
PlatinioEditorGUILayout.PropertyField( usePerHandSettings );
if (usePerHandSettings.boolValue)
{
EditorGUILayout.PropertyField( rightHandSettings, true );
EditorGUILayout.PropertyField( leftHandSettings, true );
}
else
{
EditorGUILayout.PropertyField( handSettings, true );
}
PlatinioEditorGUILayout.PropertyField( interactButton );
PlatinioEditorGUILayout.PropertyField( onInteractEvent );
serializedObject.ApplyModifiedProperties();
}
private void DrawHandSettings(SerializedProperty settings)
{
EditorGUILayout.PropertyField( settings, true );
}
public void OnSceneGUI()
{
if (targetScript == null)
OnEnable();
//handler for interact distance
EditorGUI.BeginChangeCheck();
Handles.color = Color.blue;
if (usePerHandSettings.boolValue)
{
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, interactDistance.floatValue );
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, interactDistance.floatValue );
UpdateGrabDistanceValue( rightValue, leftValue );
}
else
{
if (targetScript.HighlightPointHandSettings == null)
return;
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, interactDistance.floatValue );
interactDistance.floatValue = value;
}
serializedObject.ApplyModifiedProperties();
}
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
{
if (interactDistance.floatValue != rightValue)
{
targetScript.SetInteractDistanceViaInspector( rightValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
else if (interactDistance.floatValue != leftValue)
{
targetScript.SetInteractDistanceViaInspector( leftValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 53ae1dabd110fdd45b91d120cec21153
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/Editor/I_VR_InteractableInspector.cs
uploadId: 546658
@@ -0,0 +1,139 @@
using Platinio.SDK.EditorTools;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor(typeof(VR_Lever))]
public class I_VR_LeverInspector : Editor
{
private SerializedProperty grabButton = null;
private SerializedProperty grabDistance = null;
private SerializedProperty transformBase = null;
private SerializedProperty solverIterations = null;
private SerializedProperty shouldBackToStartingPosition = null;
private SerializedProperty onGrabStateChange = null;
private SerializedProperty onValueChange = null;
private SerializedProperty backForce = null;
private SerializedProperty usePerHandSettings = null;
private SerializedProperty leftHandSettings = null;
private SerializedProperty handSettings = null;
private SerializedProperty rightHandSettings = null;
private SerializedProperty unGrabLayer = null;
private SerializedProperty grabLayer = null;
private VR_Lever targetScript = null;
private void OnEnable()
{
transformBase = serializedObject.FindProperty( "transformBase" );
solverIterations = serializedObject.FindProperty( "solverIterations" );
shouldBackToStartingPosition = serializedObject.FindProperty( "shouldBackToStartingPosition" );
onValueChange = serializedObject.FindProperty( "onValueChange" );
backForce = serializedObject.FindProperty( "backForce" );
onGrabStateChange = serializedObject.FindProperty( "onGrabStateChange" );
grabDistance = serializedObject.FindProperty( "interactDistance" );
grabButton = serializedObject.FindProperty( "interactButton" );
usePerHandSettings = serializedObject.FindProperty( "usePerHandSettings" );
rightHandSettings = serializedObject.FindProperty( "rightHandSettings" );
leftHandSettings = serializedObject.FindProperty( "leftHandSettings" );
handSettings = serializedObject.FindProperty( "handSettings" );
unGrabLayer = serializedObject.FindProperty("unGrabLayer");
grabLayer = serializedObject.FindProperty("grabLayer");
targetScript = (VR_Lever) target;
}
public override void OnInspectorGUI()
{
PlatinioEditorGUILayout.PropertyField( grabDistance );
PlatinioEditorGUILayout.PropertyField(usePerHandSettings);
if (usePerHandSettings.boolValue)
{
EditorGUILayout.PropertyField( rightHandSettings, true );
EditorGUILayout.PropertyField( leftHandSettings, true );
}
else
{
EditorGUILayout.PropertyField( handSettings, true );
}
PlatinioEditorGUILayout.PropertyField( grabButton );
PlatinioEditorGUILayout.PropertyField(transformBase);
PlatinioEditorGUILayout.PropertyField(solverIterations);
PlatinioEditorGUILayout.PropertyField(shouldBackToStartingPosition);
PlatinioEditorGUILayout.PropertyField(backForce);
grabLayer.intValue = EditorGUILayout.LayerField( "Grab Layer", grabLayer.intValue );
unGrabLayer.intValue = EditorGUILayout.LayerField( "UnGrab Layer", unGrabLayer.intValue );
PlatinioEditorGUILayout.PropertyField(onValueChange);
PlatinioEditorGUILayout.PropertyField( onGrabStateChange );
//layer = EditorGUILayout.LayerField(layer);
serializedObject.ApplyModifiedProperties();
}
private void DrawHandSettings(SerializedProperty settings)
{
EditorGUILayout.PropertyField( settings, true );
}
public void OnSceneGUI()
{
if (targetScript == null)
OnEnable();
EditorGUI.BeginChangeCheck();
Handles.color = Color.blue;
if (usePerHandSettings.boolValue)
{
float rightValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, grabDistance.floatValue );
float leftValue = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, grabDistance.floatValue );
UpdateGrabDistanceValue( rightValue, leftValue );
}
else
{
if (targetScript.HighlightPointHandSettings == null)
return;
float value = Handles.RadiusHandle( Quaternion.identity, targetScript.HighlightPointHandSettings.position, grabDistance.floatValue );
targetScript.SetInteractDistanceViaInspector( value );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
}
private void UpdateGrabDistanceValue(float rightValue, float leftValue)
{
if (grabDistance.floatValue != rightValue)
{
targetScript.SetInteractDistanceViaInspector( rightValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
else if (grabDistance.floatValue != leftValue)
{
targetScript.SetInteractDistanceViaInspector( leftValue );
EditorUtility.SetDirty( targetScript );
EditorSceneManager.MarkAllScenesDirty();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 077beb8dc16639a40beef61bb0855821
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/Editor/I_VR_LeverInspector.cs
uploadId: 546658
@@ -0,0 +1,221 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Platinio.SDK.EditorTools;
namespace VRSDK.EditorCode
{
[CustomEditor( typeof( VR_Manager ) )]
public class I_VR_ManagerInspector : Editor
{
private SerializedProperty currentSDK = null;
private SerializedProperty gestureConfig = null;
const string DEFINES_FILE_PATH = "Assets/mcs.rsp";
const string STEAM_VR_DEFINITION = "SDK_STEAM_VR";
const string OCULUS_VR_DEFINITION = "SDK_OCULUS";
const string UNITY_XR_DEFINITION = "UNITY_XR";
const string VR_MANAGER_FILE_PATH = "VRLAB/Scripts/VR/VR_Manager.cs";
private int startSDKIndex = 0;
private static VR_Manager targetScript = null;
private void Awake()
{
currentSDK = serializedObject.FindProperty( "currentSDK" );
gestureConfig = serializedObject.FindProperty( "gestureConfig" );
targetScript = target as VR_Manager;
targetScript.SetCurrentSDKViaEditor( GetCurrentEnableSDK() );
startSDKIndex = (int) targetScript.CurrentSDK;
}
private VR_SDK GetCurrentEnableSDK()
{
List<string> defList = GlobalDefinitionsManager.GetCurrentDefinitios();
for (int n = 0; n < defList.Count; n++)
{
string def = defList[n].Replace( " ", "" );
if (def == STEAM_VR_DEFINITION)
{
return VR_SDK.Steam_VR;
}
else if (def == OCULUS_VR_DEFINITION)
{
return VR_SDK.Oculus;
}
else if (def == UNITY_XR_DEFINITION)
{
return VR_SDK.UnityXR;
}
}
return VR_SDK.None;
}
public override void OnInspectorGUI()
{
if (currentSDK == null)
return;
PlatinioEditorGUILayout.PropertyField( currentSDK );
EditorGUILayout.PropertyField( gestureConfig , true );
serializedObject.ApplyModifiedProperties();
if ((int) targetScript.CurrentSDK != startSDKIndex)
{
if (GUILayout.Button( "Update SDK" ))
{
UpdateDefinitions(targetScript.CurrentSDK);
}
}
#if SDK_STEAM_VR
if (GUILayout.Button( "Create Input Bindings" ))
{
if (EditorUtility.DisplayDialog( "Create Input Bindings", "Are you sure you want to overwrite your current SteamVR Input Bindings", "Overwrite", "Cancel" ))
{
CreateSteamVRInputBindings();
}
}
#endif
}
private void CreateSteamVRInputBindings()
{
Directory.CreateDirectory(Application.dataPath + "/StreamingAssets/SteamVR" );
CopyFilesFromTo( Application.dataPath + "/VRShooterKit/SteamVR_Default_Input" , Application.dataPath + "/StreamingAssets/SteamVR" );
AssetDatabase.Refresh();
}
private void CopyFilesFromTo(string from , string to)
{
if (System.IO.Directory.Exists( from ))
{
string[] files = System.IO.Directory.GetFiles( from );
// Copy the files and overwrite destination files if they already exist.
foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
string fileName = Path.GetFileName( s );
string destFile = Path.Combine( to, fileName );
File.Copy( s, destFile, true );
}
}
}
private void UpdateDefinitions(VR_SDK targetSDK)
{
targetScript.SetCurrentSDKViaEditor( targetSDK );
startSDKIndex = (int) targetScript.CurrentSDK;
if (targetSDK == VR_SDK.None)
{
GlobalDefinitionsManager.RemoveDefinitions(OCULUS_VR_DEFINITION , STEAM_VR_DEFINITION , UNITY_XR_DEFINITION);
OnUpdateDefinitions(targetSDK);
return;
}
string defString = GetDefString( targetSDK );
if (GlobalDefinitionsManager.DefinitionExits( OCULUS_VR_DEFINITION ) || GlobalDefinitionsManager.DefinitionExits( STEAM_VR_DEFINITION ) || GlobalDefinitionsManager.DefinitionExits(UNITY_XR_DEFINITION))
{
List<string> defList = GlobalDefinitionsManager.GetCurrentDefinitios();
for (int n = 0; n < defList.Count; n++)
{
string def = defList[n].Replace( " ", "" );
//remove all sdk defines
if (def == STEAM_VR_DEFINITION || def == OCULUS_VR_DEFINITION || def == UNITY_XR_DEFINITION)
{
defList.RemoveAt( n );
n--;
}
}
defList.Add( defString );
GlobalDefinitionsManager.WriteDefinitions( defList );
}
else
{
GlobalDefinitionsManager.CreateAndWriteDefinition( defString );
}
OnUpdateDefinitions( targetSDK );
}
private string GetDefString(VR_SDK sdk)
{
if (sdk == VR_SDK.Oculus)
{
return OCULUS_VR_DEFINITION;
}
else if (sdk == VR_SDK.Steam_VR)
{
return STEAM_VR_DEFINITION;
}
else if (sdk == VR_SDK.UnityXR)
{
return UNITY_XR_DEFINITION;
}
return "";
}
private void OnUpdateDefinitions(VR_SDK targetSDK)
{
ForceRebuild();
AssetDatabase.Refresh();
AssetDatabase.ImportAsset( VR_MANAGER_FILE_PATH, ImportAssetOptions.ForceUpdate );
AssetDatabase.ImportAsset( DEFINES_FILE_PATH, ImportAssetOptions.ForceUpdate );
targetScript.SetCurrentSDKViaEditor( targetSDK );
}
public static void ForceRebuild()
{
string[] rebuildSymbols = { "RebuildToggle1", "RebuildToggle2" };
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup );
var definesStringTemp = definesString;
if (definesStringTemp.Contains( rebuildSymbols[0] ))
{
definesStringTemp = definesStringTemp.Replace( rebuildSymbols[0], rebuildSymbols[1] );
}
else if (definesStringTemp.Contains( rebuildSymbols[1] ))
{
definesStringTemp = definesStringTemp.Replace( rebuildSymbols[1], rebuildSymbols[0] );
}
else
{
definesStringTemp += ";" + rebuildSymbols[0];
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup,
definesStringTemp );
PlayerSettings.SetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup,
definesString );
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2f812e13ecf0972468b516b22cf65566
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/Editor/I_VR_ManagerInspector.cs
uploadId: 546658
@@ -0,0 +1,48 @@
using Platinio.SDK.EditorTools;
using UnityEngine;
using UnityEditor;
namespace VRSDK.EditorCode
{
[CanEditMultipleObjects]
[CustomEditor(typeof(VR_Slider))]
public class I_VR_SliderInspector : I_VR_GrabbableInspector
{
private SerializedProperty slideAxis = null;
private SerializedProperty slideStartMarker = null;
private SerializedProperty slideEndMarker = null;
private SerializedProperty onValueChange = null;
protected override void OnEnable()
{
slideAxis = serializedObject.FindProperty("slideAxis");
slideStartMarker = serializedObject.FindProperty("slideStartMarker");
slideEndMarker = serializedObject.FindProperty("slideEndMarker");
onValueChange = serializedObject.FindProperty("onValueChange");
base.OnEnable();
}
protected override void DrawOtherSettingsBody()
{
GUIContent content = new GUIContent("Slide Axis", "The axis use by this object in local space in order to slide");
slideAxis.enumValueIndex = (int)(Axis)EditorGUILayout.EnumPopup(content, (Axis)slideAxis.enumValueIndex);
content = new GUIContent("Slider Start Marker", "");
slideStartMarker.objectReferenceValue = EditorGUILayout.ObjectField(content, slideStartMarker.objectReferenceValue, typeof(Transform), true);
content = new GUIContent("Slider End Marker", "");
slideEndMarker.objectReferenceValue = EditorGUILayout.ObjectField(content, slideEndMarker.objectReferenceValue, typeof(Transform), true);
PlatinioEditorGUILayout.PropertyField(onValueChange);
base.DrawOtherSettingsBody();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a197059cd5ced63438ddf98eeffbf8cb
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/Editor/I_VR_SliderInspector.cs
uploadId: 546658
@@ -0,0 +1,243 @@
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace VRSDK.EditorCode
{
//this script os a little especial and usefull can help you create dinamyc Enum using scriptable objects
//it creates a small script containing the VR_Tag enum that gest update every time the scritable object changes
//this VR_Tag is curretly in use in the DropZone, so it can know what objects can be dropped
[CustomEditor( typeof( VR_TagsManager ) )]
public class I_VR_TagsManager : Editor
{
private VR_TagsManager targetScript = null;
private string[] previusTagList = null;
private const string FileName = "VR_TagEnum";
private const string FileExtension = ".cs";
private void Awake()
{
targetScript = (VR_TagsManager) target;
previusTagList = new string[targetScript.TagList.Count];
targetScript.TagList.CopyTo( previusTagList );
}
public override void OnInspectorGUI()
{
if (targetScript.TagList == null)
targetScript.TagList = new List<string>();
EditorGUILayout.LabelField( "Tags", EditorStyles.boldLabel );
for (int n = 0; n < targetScript.TagList.Count; n++)
{
targetScript.TagList[n] = EditorGUILayout.TextArea( targetScript.TagList[n] );
if (GUILayout.Button( "-", GUILayout.Width( 20 ) ))
targetScript.TagList.RemoveAt( n );
}
if (GUILayout.Button( "+", GUILayout.Width( 20 ) ))
targetScript.TagList.Add( "" );
}
/// <summary>
/// Find a path for our enum holder script
/// </summary>
/// <returns></returns>
private string GetPath()
{
//find is there is a file with the same name already
string[] files = Directory.GetFiles( Application.dataPath, "*" + FileExtension, SearchOption.AllDirectories );
for (int n = 0; n < files.Length; n++)
{
//there is already a script with that name lest replace it
if (files[n].Contains( FileName ))
{
//we need to use paths relative to the assets folder
string globalPath = files[n].Replace( '\\', '/' );
int startIndex = globalPath.IndexOf( "Assets", 0 );
string relativePath = globalPath.Substring( startIndex, globalPath.Length - ( startIndex ) );
return relativePath;
}
}
//find the VRShooterKit folder
string[] directoryArray = Directory.GetDirectories( Application.dataPath );
for (int n = 0; n < directoryArray.Length; n++)
{
if (directoryArray[n].Contains( "VRShooterKit" ))
{
string path = directoryArray[n];
path = path.Replace( '\\', '/' );
return path + "/" + FileName + FileExtension;
}
}
//create the VRShooterKit folder
return Application.dataPath + "/VRShooterKit/" + FileName + FileExtension;
}
/// <summary>
/// update the enum script
/// </summary>
private void UpdateEnumScript()
{
string script = "namespace VRShooterKit" +
"{ " +
"public enum VR_TagsEnum" +
"{";
if (targetScript.TagList.Count > 0)
{
for (int n = 0; n < targetScript.TagList.Count; n++)
{
script += targetScript.TagList[n];
if (n != targetScript.TagList.Count - 1)
script += ",";
}
}
else
{
script += "Empty";
}
script += "}";
script += "}";
string path = GetPath();
File.WriteAllText( path, script );
//rebuild
AssetDatabase.Refresh();
AssetDatabase.ImportAsset( path, ImportAssetOptions.ForceUpdate );
//save
EditorUtility.SetDirty( targetScript );
}
/// <summary>
/// the content of the list is valid?
/// </summary>
private bool IsValid()
{
for (int n = 0; n < targetScript.TagList.Count; n++)
{
//find empty
if (targetScript.TagList[n].Length == 0)
{
Debug.LogWarning( "TagManager found empty Tag reverting changes!" );
return false;
}
//the tag start with a number
if (char.IsDigit( targetScript.TagList[n][0] ))
{
Debug.LogWarning( "TagManager found invalid Tag name reverting changes!" );
return false;
}
//find invalid characters
for (int j = 0; j < targetScript.TagList[n].Length; j++)
{
if (!IsCharValid(targetScript.TagList[n][j]))
{
Debug.LogWarning( "TagManager found invalid Tag name reverting changes!" );
return false;
}
}
}
List<string> duplicateList = targetScript.TagList.GroupBy( x => x )
.Where( group => group.Count() > 1 )
.Select( group => group.Key ).ToList();
if (duplicateList.Count > 0)
{
Debug.LogWarning( "TagManager found repeat Tag reverting changes!" );
return false;
}
return true;
}
private bool IsCharValid(char c)
{
c = char.ToLower(c);
return char.IsDigit(c) || (c >= 'a' && c <= 'z' ) || c == '_';
}
/// <summary>
/// remove white spaces from all names
/// </summary>
private void RemoveWhiteSpaces()
{
for (int n = 0; n < targetScript.TagList.Count; n++)
{
targetScript.TagList[n] = targetScript.TagList[n].Replace( " ", string.Empty );
}
}
private void RevertChanges()
{
targetScript.TagList = previusTagList.ToList();
}
private bool NeedRebuild()
{
if (previusTagList.Length != targetScript.TagList.Count)
{
return true;
}
for (int n = 0; n < targetScript.TagList.Count; n++)
{
if (previusTagList[n] != targetScript.TagList[n])
return true;
}
return false;
}
public void OnDestroy()
{
//remove white spaces
RemoveWhiteSpaces();
if (!IsValid())
{
RevertChanges();
return;
}
if (NeedRebuild())
{
UpdateEnumScript();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 12be308ec92d1de4783a5a833257d161
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/Editor/I_VR_TagsManager.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0c38cf0aea354c740a16d81a6393b426
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,50 @@
namespace VRSDK
{
public enum GrabSelectionMenu
{
Animation = 0,
GrabSettings = 1,
Other = 2,
Events = 3
}
public enum BoolEnum
{
Yes,
No
}
[System.Serializable]
public class VR_GrabbableEditorPart
{
public GrabSelectionMenu selectedMenu = GrabSelectionMenu.Animation;
public bool foldoutInput = false;
public bool foldoutConsole = false;
public bool foldoutBaseInspector = false;
public bool foldoutBasic = false;
public bool foldoutInteraction = false;
public bool foldoutShareHandInteractSettings = false;
public bool foldoutRightHandInteractSettings = false;
public bool foldoutLeftHandInteractSettings = false;
public bool foldoutShareHandAnimationSettings = false;
public bool foldoutRightHandAnimationSettings = false;
public bool foldoutLeftHandAnimationSettings = false;
public bool foldoutEditorTools = false;
public int handSelected = 0;
public bool IsMissingGrabPoint(VR_HandInteractSettings settings)
{
return settings.canInteract && settings.interactPoint == null;
}
public bool IsMissinHiglightPoint(VR_HandInteractSettings settings)
{
return settings.canInteract && settings.highlightPoint == null;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cb21e8b4bda1835478a8330c86f3ae1a
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/EditorPart/VR_GrabbableEditorPart.cs
uploadId: 546658
@@ -0,0 +1,23 @@
using UnityEngine;
namespace VRSDK
{
public enum WeaponSelectionMenu
{
Reload = 0,
Shoot,
Damage,
Recoil
}
[System.Serializable]
public class VR_WeaponEditorPart
{
public WeaponSelectionMenu selectedMenu = WeaponSelectionMenu.Reload;
public bool foldoutBasicShootSettings = false;
public bool foldoutOptionalShootSettings = false;
public bool foldoutEffectsShootSettings = false;
public bool foldoutSpreadDamageSettings = false;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cfede03425cdfea4c8c93fa780e146c8
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/EditorPart/VR_WeaponEditorPart.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dfaca4bdf5387ff40838c936e511fa71
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ef6512a42f273a46bb07b2e3a3c072c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,231 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Platinio.SDK.EditorTools
{
public static class PlatinioEditorGUILayout
{
/// <summary>
/// Create a property field from a SerializedProperty
/// </summary>
public static void PropertyField(SerializedProperty property, string label = null, bool showChildren = false)
{
EditorGUILayout.PropertyField(property, new GUIContent( label == null ? property.displayName : label ), showChildren);
}
/// <summary>
/// Create a property field from a SerializedProperty
/// </summary>
public static void PropertyField(SerializedProperty property, bool showChildren)
{
PropertyField(property, null, showChildren);
}
/// <summary>
/// Create a float slider in the inspector
/// </summary>
/// <param name="min">Min slider value</param>
/// <param name="max">Max slider value</param>
/// <param name="minLimit">Min slider limit</param>
/// <param name="maxLimit">Max slider limit</param>
public static void MinMaxFloatSlider(SerializedProperty min, SerializedProperty max, float minLimit, float maxLimit)
{
PropertyField(min);
PropertyField(max);
float minValue = min.floatValue;
float maxValue = max.floatValue;
EditorGUILayout.MinMaxSlider(ref minValue, ref maxValue, minLimit, maxLimit);
min.floatValue = minValue;
max.floatValue = maxValue;
}
/// <summary>
/// Creates a foldout style label with indent value
/// </summary>
/// <returns>Current foldout value</returns>
public static bool Foldout(bool foldout, GUIContent content, int indent)
{
GUIStyle style = new GUIStyle(EditorStyles.foldout);
style.fontStyle = FontStyle.Bold;
style.fontSize = 12;
style.active.textColor = Color.black;
style.focused.textColor = Color.black;
style.onHover.textColor = Color.black;
style.normal.textColor = Color.black;
style.onNormal.textColor = Color.black;
style.onActive.textColor = Color.black;
style.onFocused.textColor = Color.black;
Rect rect = GUILayoutUtility.GetRect(40f, 40f, 16f, 16f);
rect.x += indent * 20;
return EditorGUI.Foldout(rect, foldout, content , style);
}
/// <summary>
/// Creates a foldout style label with indent value
/// </summary>
/// <param name="title">Title</param>
/// <param name="foldout">Foldout value</param>
/// <param name="indent">Indent level</param>
/// <param name="drawCallback">Callback called when it is foldout</param>
public static void Foldout(GUIContent title, ref bool foldout, int indent , Action drawCallback)
{
foldout = Foldout(foldout, title , indent);
if (foldout)
{
drawCallback();
}
}
/// <summary>
/// Creates a foldout style label with indent value
/// </summary>
/// <param name="title">Title</param>
/// <param name="foldout">Foldout value</param>
/// <param name="drawCallback">Callback called when it is foldout</param>
public static void Foldout(GUIContent title, ref bool foldout, Action drawCallback)
{
Foldout(title, ref foldout, 0, drawCallback);
}
/// <summary>
/// Add space in the inspector
/// </summary>
public static void Space(int height)
{
for (int n = 0; n < height; n++) EditorGUILayout.Space();
}
/// <summary>
/// Draws a title label
/// </summary>
public static void DrawTittle(string text)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField( text, EditorStyles.boldLabel );
EditorGUILayout.Space();
}
/// <summary>
/// Draws a grid of buttons in the inspector
/// </summary>
/// <returns>Current selected button index</returns>
public static int DrawGridButtons(int selection, int xSize, params GUIContent[] labels)
{
EditorGUIUtility.SetIconSize( new Vector2(20.0f , 20.0f));
GUIStyle SelectionGridStyle = new GUIStyle(EditorStyles.miniButton);
SelectionGridStyle.fixedHeight = 35;
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
int newSelection = GUILayout.SelectionGrid(selection, labels, xSize, SelectionGridStyle, GUILayout.Height(68), GUILayout.Width(85 * Screen.width / Screen.dpi));
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
return newSelection;
}
/// <summary>
/// Draws a tooltip box in the inspector
/// </summary>
public static void DrawTooltipBox(Texture icon , string title , string text)
{
EditorGUILayout.BeginVertical("Box");
var style = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleCenter };
EditorGUILayout.LabelField(new GUIContent(icon), style, GUILayout.ExpandWidth(true), GUILayout.Height(32));
EditorGUILayout.LabelField(title, style, GUILayout.ExpandWidth(true));
style = EditorStyles.helpBox;
style.richText = true;
style.fontSize = 11;
EditorGUILayout.LabelField(text , style );
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
}
public static void DrawTooltipBox(MessageType messageType, string title, string text)
{
DrawTooltipBox(LoadIcon(messageType.ToString()), title, text);
}
/// <summary>
/// Loads editor icons from "Editor/Icons/"
/// </summary>
public static Texture LoadIcon(string iconName)
{
return Resources.Load("Editor/Icons/" + iconName) as Texture;
}
/// <summary>
/// Draws a console in the inspector
/// </summary>
/// <param name="consoleMessageList">messages for the user</param>
public static void DrawConsole(List<ConsoleMessage> consoleMessageList)
{
for (int n = 0; n < consoleMessageList.Count; n++)
{
EditorGUILayout.HelpBox( consoleMessageList[n].text , consoleMessageList[n].messageType );
}
}
/// <summary>
/// Sometimes is better to use a enum dropdown Yes/No instead of a checkbox
/// </summary>
public static bool DrawBoolEnum(GUIContent content, bool value)
{
return ((BoolEnum)EditorGUILayout.EnumPopup(content, value? BoolEnum.Yes : BoolEnum.No)) == BoolEnum.Yes;
}
/// <summary>
/// Sometimes is better to use a enum dropdown Yes/No instead of a checkbox
/// </summary>
public static bool DrawBoolEnum(GUIContent content, Rect rect , bool value)
{
return ((BoolEnum)EditorGUI.EnumPopup(rect , content, value ? BoolEnum.Yes : BoolEnum.No )) == BoolEnum.Yes;
}
public static void FoldoutInspector(GUIContent title, ref bool foldout, int indent , Action drawCallback)
{
foldout = Foldout(foldout, title , indent);
if (foldout)
{
drawCallback();
}
}
public static void FoldoutInspector(GUIContent title, ref bool foldout, Action drawCallback)
{
FoldoutInspector(title, ref foldout, 0, drawCallback);
}
}
public class ConsoleMessage
{
public string text;
public MessageType messageType;
public ConsoleMessage(string text , MessageType messageType)
{
this.text = text;
this.messageType = messageType;
}
}
public enum BoolEnum
{
Yes,
No
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 75a81db9430ee15498ae2cb154238a5e
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/EditorTools/Editor/PlatinioEditorGUILayout.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26ba6e5dedc35cc46926b6bf0a5e30ef
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine.Events;
namespace VRSDK.Events
{
/// <summary>
/// Event that gets called when a is dropped inside a DropZone, we extend from UnityEvent<GrabState> so we can see this onn the inspector and add some listeners by hand if we want
/// </summary>
[System.Serializable]
public class OnDropStateChangeEvent : UnityEvent<VR_Grabbable> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 64983187cabf2b94483dfd88a068b3d5
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/Events/OnDropStateChangeEvent.cs
uploadId: 546658
@@ -0,0 +1,12 @@
using UnityEngine.Events;
namespace VRSDK.Events
{
/// <summary>
/// Event that gets called when the grab state change, we extend from UnityEvent<GrabState> so we can see this onn the inspector and add some listeners by hand if we want
/// </summary>
[System.Serializable]
public class OnGrabStateChangeEvent : UnityEvent<GrabState> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5ab1d6f3a50c5b24ca7ca0b8572cb516
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/Events/OnGrabStateChangeEvent.cs
uploadId: 546658
@@ -0,0 +1,11 @@
using UnityEngine.Events;
namespace VRSDK.Events
{
/// <summary>
/// Event that gets called when we interact with a object, we extend from UnityEvent<GrabState> so we can see this onn the inspector and add some listeners by hand if we want
/// </summary>
[System.Serializable]
public class OnInteractEvent : UnityEvent<VR_Controller> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8a87b182fd447544ea040092d4eb1ca6
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/Events/OnInteractEvent.cs
uploadId: 546658
@@ -0,0 +1,29 @@
using UnityEngine;
using System;
namespace VRSDK
{
public class OnJointBreakListener : MonoBehaviour
{
private Action<float> onJointBreakCallback = null;
public void SetListener(Action<float> listener)
{
onJointBreakCallback = listener;
}
public void RemoveAllListeners()
{
onJointBreakCallback = null;
}
//method called by Unity when a joint gets break in the gameobject
private void OnJointBreak(float f)
{
if (onJointBreakCallback != null)
onJointBreakCallback( f );
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 08df66d83f0311447a27ba4679b3e234
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/Events/OnJointBreakListener.cs
uploadId: 546658
@@ -0,0 +1,11 @@
using UnityEngine.Events;
namespace VRSDK.Events
{
/// <summary>
/// Event that gets called when a rotation gesture occurs, we extend from UnityEvent<GrabState> so we can see this onn the inspector and add some listeners by hand if we want
/// this is currently in use in the revolver Physical reload system, when we rotate our hand a certain speed and certain angle, the weapon gets a reload
/// </summary>
public class OnRotationGestureEvent : UnityEvent<RotationGestureInfo> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: eb0d886b3f30cfd419578be849ea0078
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/Events/OnRotationGestureEvent.cs
uploadId: 546658
@@ -0,0 +1,10 @@
using UnityEngine.Events;
namespace VRSDK.Events
{
/// <summary>
/// Event that gets called when some valud change, we extend from UnityEvent<GrabState> so we can see this onn the inspector and add some listeners by hand if we want
/// </summary>
[System.Serializable]
public class OnValueChangeEvent : UnityEvent<float> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4c9b6e78fee4f5845b50fccb994d56b9
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/Events/OnValueChangeEvent.cs
uploadId: 546658
@@ -0,0 +1,45 @@
using UnityEngine;
using System;
namespace VRSDK
{
public class TriggerCollisionListener : MonoBehaviour
{
public Action<Collider> OnTriggerEnterEvent = null;
public Action<Collider> OnTriggerExitEvent = null;
public Action<Collider> OnTriggerStayEvent = null;
private void Awake()
{
Collider c = GetComponent<Collider>();
if (c != null)
c.isTrigger = true;
else
Debug.LogError( "you add a trigger collision listener in a gameobject with no collider!" );
}
private void OnTriggerEnter(Collider other)
{
Debug.Log("trigger enter");
if (OnTriggerEnterEvent != null)
OnTriggerEnterEvent( other );
}
private void OnTriggerExit(Collider other)
{
Debug.Log("trigger stay");
if (OnTriggerExitEvent != null)
OnTriggerExitEvent( other );
}
private void OnTriggerStay(Collider other)
{
if (OnTriggerStayEvent != null)
OnTriggerStayEvent( other );
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0482451ce8f6d734695c8fbcc1041601
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/Events/TriggerCollisionListener.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b7cc8d571e05d594d8b328791a60195e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 68aa9e14dd028c748a612675dd98d63c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e8ae55ed26ad3cd4aa229ed752b4f8f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a3ec821b0dfed9a459b982b4d184143b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,98 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;
namespace VRSDK.EditorCode
{
[CustomEditor(typeof(HandVisualizerTool))]
public class I_HandVisualizerTool : Editor
{
private static VR_Controller activeController = null;
private VR_Grabbable grabbableClone = null;
private VR_Grabbable grabbable = null;
private HandVisualizerTool targetScript = null;
private static string returnScenePath = null;
private static Scene returnScene;
private static bool inPreviewMode = false;
private void Awake()
{
/*
targetScript = (HandVisualizerTool)target;
if (activeController == null || grabbableClone == null)
{
grabbable = targetScript.GetComponent<VR_Grabbable>();
grabbableClone = Instantiate( grabbable, grabbable.transform.position, grabbable.transform.rotation );
DestroyImmediate(grabbableClone.GetComponent<HandVisualizerTool>());
activeController = Instantiate( VR_Manager.instance.RightController, grabbable.RightInteractPoint.position, Quaternion.identity );
//try this
//EditorSceneManager.NewPreviewScene();
EditorSceneManager.MoveGameObjectToScene()
}
*/
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!HandPreviewManager.IsPreviewModeEnable)
{
if (GUILayout.Button( "Enter Preview Mode Right Hand" ))
{
EnterPreviewMode(VR_Manager.instance.Player.RightController);
}
if (GUILayout.Button( "Enter Preview Mode Left Hand" ))
{
EnterPreviewMode( VR_Manager.instance.Player.LeftController );
}
}
else
{
if (GUILayout.Button( "Save and Exit Preview Mode" ))
{
HandPreviewManager.SaveAndExit();
}
if (GUILayout.Button( "Exit Preview Mode" ))
{
HandPreviewManager.ExitPreviewMode();
}
}
}
private void EnterPreviewMode(VR_Controller controller)
{
targetScript = (HandVisualizerTool) target;
grabbable = targetScript.GetComponent<VR_Grabbable>();
grabbable.gameObject.AddComponent<GameObjectMarker>();
EditorSceneManager.MarkAllScenesDirty();
EditorSceneManager.SaveOpenScenes();
grabbableClone = Instantiate( grabbable , grabbable.transform.position, grabbable.transform.rotation );
activeController = Instantiate( controller , grabbable.RightInteractPoint.position , Quaternion.identity );
grabbableClone.SetEditorGrabPositionAndRotation( activeController );
HandPreviewManager.EnterPreviewMode(grabbableClone.transform.root.gameObject);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: aa1e7be944d512d4f8e363a91d654dac
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/Experimental/Tools/HandVisualizer/Editor/I_HandVisualizerTool.cs
uploadId: 546658
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameObjectMarker : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3b4724e1bc367a34eac6a65d01a79251
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/Experimental/Tools/HandVisualizer/GameObjectMarker.cs
uploadId: 546658
@@ -0,0 +1,134 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEditor.SceneManagement;
using UnityEditor;
#endif
namespace VRSDK.EditorCode
{
public static class HandPreviewManager
{
#if UNITY_EDITOR
private static string originalScenePath = null;
private static bool previewModeEnable = false;
private static VR_Grabbable inspectedGrabbable = null;
private static VR_Controller activeController = null;
private static HandPreviewSave handPreviewSave = null;
public static bool IsPreviewModeEnable { get { return previewModeEnable; } }
public static void EnterPreviewMode(GameObject clone)
{
Scene originalScene = EditorSceneManager.GetActiveScene();
originalScenePath = EditorApplication.currentScene;
Scene previewScene = EditorSceneManager.NewScene( NewSceneSetup.DefaultGameObjects, NewSceneMode.Additive );
EditorSceneManager.MoveGameObjectToScene( clone, previewScene );
EditorSceneManager.UnloadSceneAsync( originalScene );
previewModeEnable = true;
inspectedGrabbable = GameObject.FindObjectOfType<VR_Grabbable>();
activeController = GameObject.FindObjectOfType<VR_Controller>();
OverrideGrabAnimation();
activeController.Animator.SetBool("IsGrabbing" , true);
EditorApplication.update += Update;
}
public static void ExitPreviewMode()
{
previewModeEnable = false;
EditorSceneManager.OpenScene(originalScenePath);
EditorApplication.update -= Update;
}
public static void SaveAndExit()
{
handPreviewSave = new HandPreviewSave( inspectedGrabbable );
ExitPreviewMode();
GameObjectMarker marker = GameObject.FindObjectOfType<GameObjectMarker>();
handPreviewSave.LoadInto(marker.GetComponent<VR_Grabbable>());
GameObject.DestroyImmediate(marker);
}
private static void Update()
{
activeController.Animator.Update(1.0f/30.0f);
inspectedGrabbable.SetEditorGrabPositionAndRotation(activeController);
OverrideGrabAnimation();
}
private static void OverrideGrabAnimation()
{
VR_HandInteractSettings settings = inspectedGrabbable.GetHandInteractionSettings( activeController );
//AnimationClip clip = settings.animation;
//activeController.OverrideInteractAnimation( settings.animation );
}
}
public class HandPreviewSave
{
public VR_HandInteractSettings handSettings = null;
public VR_HandInteractSettings leftSettings = null;
public VR_HandInteractSettings rightSettings = null;
public Vector3 handSettingsInteractPointLocalPosition = Vector3.zero;
public Vector3 rightHandSettingsInteractPointLocalPosition = Vector3.zero;
public Vector3 leftHandSettingsInteractPointLocalPosition = Vector3.zero;
public HandPreviewSave(VR_Grabbable grabbable)
{
handSettings = grabbable.HandSettings;
leftSettings = grabbable.LeftHandSettings;
rightSettings = grabbable.RightHandSettings;
handSettingsInteractPointLocalPosition = handSettings.interactPoint.localPosition;
leftHandSettingsInteractPointLocalPosition = leftSettings.interactPoint.localPosition;
rightHandSettingsInteractPointLocalPosition = rightSettings.interactPoint.localPosition;
}
public void LoadInto(VR_Grabbable grabbable)
{
CopyTo(handSettings , grabbable.HandSettings);
CopyTo(rightSettings , grabbable.RightHandSettings);
CopyTo(leftSettings , grabbable.LeftHandSettings);
if (grabbable.HandSettings.interactPoint != null)
{
Debug.Log( grabbable.HandSettings.interactPoint.localPosition );
Debug.Log( handSettingsInteractPointLocalPosition );
grabbable.HandSettings.interactPoint.localPosition = handSettingsInteractPointLocalPosition;
}
if (grabbable.LeftHandSettings.interactPoint != null)
grabbable.LeftHandSettings.interactPoint.localPosition = leftHandSettingsInteractPointLocalPosition;
if (grabbable.RightHandSettings.interactPoint != null)
grabbable.RightHandSettings.interactPoint.localPosition = rightHandSettingsInteractPointLocalPosition;
}
private void CopyTo(VR_HandInteractSettings from , VR_HandInteractSettings to)
{
//to.animation = from.animation;
to.canInteract = from.canInteract;
to.rotationOffset = from.rotationOffset;
}
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cc8c956f7ac50bb48a414e7ed997168d
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/Experimental/Tools/HandVisualizer/HandPreviewManager.cs
uploadId: 546658
@@ -0,0 +1,11 @@
using UnityEngine;
namespace VRSDK
{
public class HandVisualizerTool : MonoBehaviour
{
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7b64809843e26e54bab447966e86bd4e
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/Experimental/Tools/HandVisualizer/HandVisualizerTool.cs
uploadId: 546658
@@ -0,0 +1,36 @@
namespace VRSDK
{
public class VR_HandSnapPoint : VR_Grabbable
{
protected override void Start()
{
base.Start();
preventDefault = true;
}
private void LateUpdate()
{
if (currentGrabState != GrabState.Grab)
return;
activeController.transform.position = GetCurrentHandInteractSettings().interactPoint.position;
}
public override void OnGrabSuccess(VR_Controller controller)
{
activeController = controller;
currentGrabState = GrabState.Grab;
RaiseOnGrabStateChangeEvent( GrabState.Grab );
GrabController.SetVisibility( !GetCurrentHandAnimationSettings().hideHandOnGrab );
activeController.SetPositionControlMode( MotionControlMode.Free );
activeController.SetRotationControlMode( MotionControlMode.Free );
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 10b0b76b98de95145b90a5f67064f0f0
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/Experimental/VR_HandSnapPoint.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4a29534426cc5bd428bad06e565da6a3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,21 @@
using UnityEngine;
namespace VRSDK
{
public static class GameObjectExtension
{
/// <summary>
/// VR Shooter Kit extension method just try to get a component, if the component is no found we add one
/// </summary>
public static T GetOrAddComponent<T>(this GameObject go) where T : Component
{
T component = go.GetComponent<T>();
if (component == null) component = go.AddComponent<T>();
return component;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 98c34e2184cf5cf4aa0270688f307b20
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/Extension/GameObjectExtension.cs
uploadId: 546658
@@ -0,0 +1,26 @@
using UnityEngine;
namespace VRSDK
{
public static class MathfExtension
{
public static Vector3 ClampVectorMagnitude(Vector3 value , float min , float max)
{
Vector3 clampVector = value;
float m = clampVector.magnitude;
if (m > max)
{
clampVector = clampVector.normalized * max;
}
else if (m < min)
{
clampVector = clampVector.normalized * min;
}
return clampVector;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cb8e15f33ac8b544c83af3954c152941
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/Extension/MathfExtension.cs
uploadId: 546658
@@ -0,0 +1,23 @@
using UnityEngine.AI;
using UnityEngine;
namespace VRSDK.AI
{
public static class NavMeshExtension
{
public static Vector3 CalculateRandomPointInsideNavMesh(Vector3 center , float radius , int areaMask)
{
Vector3 point = center + Random.insideUnitSphere * radius;
NavMeshHit hit;
if (NavMesh.SamplePosition( point, out hit, radius, areaMask ))
{
return hit.position;
}
return center;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b49bcdb3c08aa5b48856d53c8fdb168a
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/Extension/NavMeshExtension.cs
uploadId: 546658
@@ -0,0 +1,287 @@
// MIT License
//
// Copyright (c) 2017 Justin Larrabee <justonia@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public static class PhysicsExtensions
{
//
// Box
//
public static bool BoxCast(BoxCollider box, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.BoxCast( center, halfExtents, direction, orientation, maxDistance, layerMask, queryTriggerInteraction );
}
public static bool BoxCast(BoxCollider box, Vector3 direction, out RaycastHit hitInfo, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.BoxCast( center, halfExtents, direction, out hitInfo, orientation, maxDistance, layerMask, queryTriggerInteraction );
}
public static RaycastHit[] BoxCastAll(BoxCollider box, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.BoxCastAll( center, halfExtents, direction, orientation, maxDistance, layerMask, queryTriggerInteraction );
}
public static int BoxCastNonAlloc(BoxCollider box, Vector3 direction, RaycastHit[] results, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.BoxCastNonAlloc( center, halfExtents, direction, results, orientation, maxDistance, layerMask, queryTriggerInteraction );
}
public static bool CheckBox(BoxCollider box, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.CheckBox( center, halfExtents, orientation, layerMask, queryTriggerInteraction );
}
public static Collider[] OverlapBox(BoxCollider box, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.OverlapBox( center, halfExtents, orientation, layerMask, queryTriggerInteraction );
}
public static int OverlapBoxNonAlloc(BoxCollider box, Collider[] results, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center, halfExtents;
Quaternion orientation;
box.ToWorldSpaceBox( out center, out halfExtents, out orientation );
return Physics.OverlapBoxNonAlloc( center, halfExtents, results, orientation, layerMask, queryTriggerInteraction );
}
public static void ToWorldSpaceBox(this BoxCollider box, out Vector3 center, out Vector3 halfExtents, out Quaternion orientation)
{
orientation = box.transform.rotation;
center = box.transform.TransformPoint( box.center );
var lossyScale = box.transform.lossyScale;
var scale = AbsVec3( lossyScale );
halfExtents = Vector3.Scale( scale, box.size ) * 0.5f;
}
//
// Sphere
//
public static bool SphereCast(SphereCollider sphere, Vector3 direction, out RaycastHit hitInfo, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.SphereCast( center, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction );
}
public static RaycastHit[] SphereCastAll(SphereCollider sphere, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.SphereCastAll( center, radius, direction, maxDistance, layerMask, queryTriggerInteraction );
}
public static int SphereCastNonAlloc(SphereCollider sphere, Vector3 direction, RaycastHit[] results, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.SphereCastNonAlloc( center, radius, direction, results, maxDistance, layerMask, queryTriggerInteraction );
}
public static bool CheckSphere(SphereCollider sphere, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.CheckSphere( center, radius, layerMask, queryTriggerInteraction );
}
public static Collider[] OverlapSphere(SphereCollider sphere, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.OverlapSphere( center, radius, layerMask, queryTriggerInteraction );
}
public static int OverlapSphereNonAlloc(SphereCollider sphere, Collider[] results, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 center;
float radius;
sphere.ToWorldSpaceSphere( out center, out radius );
return Physics.OverlapSphereNonAlloc( center, radius, results, layerMask, queryTriggerInteraction );
}
public static void ToWorldSpaceSphere(this SphereCollider sphere, out Vector3 center, out float radius)
{
center = sphere.transform.TransformPoint( sphere.center );
radius = sphere.radius * MaxVec3( AbsVec3( sphere.transform.lossyScale ) );
}
//
// Capsule
//
public static bool CapsuleCast(CapsuleCollider capsule, Vector3 direction, out RaycastHit hitInfo, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.CapsuleCast( point0, point1, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction );
}
public static RaycastHit[] CapsuleCastAll(CapsuleCollider capsule, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.CapsuleCastAll( point0, point1, radius, direction, maxDistance, layerMask, queryTriggerInteraction );
}
public static int CapsuleCastNonAlloc(CapsuleCollider capsule, Vector3 direction, RaycastHit[] results, float maxDistance = Mathf.Infinity, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.CapsuleCastNonAlloc( point0, point1, radius, direction, results, maxDistance, layerMask, queryTriggerInteraction );
}
public static bool CheckCapsule(CapsuleCollider capsule, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.CheckCapsule( point0, point1, radius, layerMask, queryTriggerInteraction );
}
public static Collider[] OverlapCapsule(CapsuleCollider capsule, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.OverlapCapsule( point0, point1, radius, layerMask, queryTriggerInteraction );
}
public static int OverlapCapsuleNonAlloc(CapsuleCollider capsule, Collider[] results, int layerMask = Physics.DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
Vector3 point0, point1;
float radius;
capsule.ToWorldSpaceCapsule( out point0, out point1, out radius );
return Physics.OverlapCapsuleNonAlloc( point0, point1, radius, results, layerMask, queryTriggerInteraction );
}
public static void ToWorldSpaceCapsule(this CapsuleCollider capsule, out Vector3 point0, out Vector3 point1, out float radius)
{
var center = capsule.transform.TransformPoint( capsule.center );
radius = 0f;
float height = 0f;
Vector3 lossyScale = AbsVec3( capsule.transform.lossyScale );
Vector3 dir = Vector3.zero;
switch (capsule.direction)
{
case 0: // x
radius = Mathf.Max( lossyScale.y, lossyScale.z ) * capsule.radius;
height = lossyScale.x * capsule.height;
dir = capsule.transform.TransformDirection( Vector3.right );
break;
case 1: // y
radius = Mathf.Max( lossyScale.x, lossyScale.z ) * capsule.radius;
height = lossyScale.y * capsule.height;
dir = capsule.transform.TransformDirection( Vector3.up );
break;
case 2: // z
radius = Mathf.Max( lossyScale.x, lossyScale.y ) * capsule.radius;
height = lossyScale.z * capsule.height;
dir = capsule.transform.TransformDirection( Vector3.forward );
break;
}
if (height < radius * 2f)
{
dir = Vector3.zero;
}
point0 = center + dir * ( height * 0.5f - radius );
point1 = center - dir * ( height * 0.5f - radius );
}
//
// Util
//
public static void SortClosestToFurthest(RaycastHit[] hits, int hitCount = -1)
{
if (hitCount == 0)
{
return;
}
if (hitCount < 0)
{
hitCount = hits.Length;
}
Array.Sort<RaycastHit>( hits, 0, hitCount, ascendDistance );
}
//
// Private
//
private class AscendingDistanceComparer : IComparer<RaycastHit>
{
public int Compare(RaycastHit h1, RaycastHit h2)
{
return h1.distance < h2.distance ? -1 : ( h1.distance > h2.distance ? 1 : 0 );
}
}
private static AscendingDistanceComparer ascendDistance = new AscendingDistanceComparer();
private static Vector3 AbsVec3(Vector3 v)
{
return new Vector3( Mathf.Abs( v.x ), Mathf.Abs( v.y ), Mathf.Abs( v.z ) );
}
private static float MaxVec3(Vector3 v)
{
return Mathf.Max( v.x, Mathf.Max( v.y, v.z ) );
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 77bcdb3d3b96a9a4ca97490b750d6630
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/Extension/PhysicsExtensions.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d304cf2d24b02ed4285713dab1573dd3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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

Some files were not shown because too many files have changed in this diff Show More