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: 7cf64ce4bde6f524d880711169fe2b95
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,38 @@
using UnityEngine;
namespace DamageSystem
{
public class DamageInfo
{
public float dmg = 0.0f;
public Vector3 hitDir = Vector3.zero;
public Vector3 hitPoint = Vector3.zero;
public float explosionRadius = 0.0f;
public float upwardsModifier = 0.0f;
public float hitForce = 0.0f;
public ForceMode forceMode = ForceMode.Impulse;
public DamageType damageType = DamageType.Shoot;
public bool canDismember = false;
public GameObject sender = null;
public DamageInfo() { }
public void ApplyImpact(Rigidbody rb)
{
if (rb == null)
return;
if (damageType == DamageType.Explosion)
{
rb.AddExplosionForce( hitForce, hitPoint, explosionRadius, upwardsModifier, forceMode );
}
else if (damageType == DamageType.Shoot)
{
rb.AddForceAtPosition( hitForce * hitDir, hitPoint, forceMode );
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7e92c731e4c9be642a714dcd2b239e1a
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/VRDamageSystem/DamageInfo.cs
uploadId: 546658
@@ -0,0 +1,14 @@
using UnityEngine;
namespace DamageSystem
{
/// <summary>
/// Basic class for all damageable stuff
/// </summary>
public abstract class Damageable : MonoBehaviour
{
public abstract void DoDamage(DamageInfo info);
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a3825a2e982e8a849baa900e14c416e0
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/VRDamageSystem/Damageable.cs
uploadId: 546658
@@ -0,0 +1,56 @@
using UnityEngine;
namespace DamageSystem
{
/// <summary>
/// This component report all limb damage to the the AI
/// </summary>
public class DamageableLimb : Damageable
{
[SerializeField] private float damageMultiplier = 1.0f;
private DamageableManager owner = null;
//public Rigidbody RB { get { return rb; } }
public DamageableManager Owner { get { return owner; } }
public void SetOwner(DamageableManager owner)
{
this.owner = owner;
}
public override void DoDamage(DamageInfo info)
{
info.dmg *= damageMultiplier;
//owner.DoDamage(info, this);
}
private void ProcessHit(Rigidbody rb)
{
DamageInfo info = new DamageInfo();
info.damageType = DamageType.Physical;
info.hitDir = rb.linearVelocity.normalized;
info.dmg = rb.linearVelocity.magnitude * damageMultiplier;
info.hitForce = rb.linearVelocity.magnitude;
DoDamage(info);
}
private void OnCollisionEnter(Collision other)
{
//in this way we can respond to hits from objects and apply damage,
//like the player throwing a box to a enemy
if (other.rigidbody != null)
{
ProcessHit( other.rigidbody );
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0c6d2eeb5625078408a74f80b7bd56d7
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/VRDamageSystem/DamageableLimb.cs
uploadId: 546658
@@ -0,0 +1,158 @@
using DamageSystem.Events;
using UnityEngine;
using UnityEngine.Events;
namespace DamageSystem
{
public enum DamageType
{
Explosion,
Shoot,
Physical
}
public class DamageableManager : MonoBehaviour
{
[SerializeField] protected float hp = 100.0f;
[SerializeField] private float regenerationSpeed = 0.0f;
[SerializeField] protected Rigidbody com = null;
[SerializeField] private OnDamageEvent onDamage = null;
[SerializeField] private UnityEvent onDie = null;
[SerializeField] protected OnValueChangeEvent onHPChangeEvent;
protected bool isDead = false;
private float maxHP = 0.0f;
public float HP { get { return hp; } }
public OnDamageEvent OnDamage { get { return onDamage; } }
public OnValueChangeEvent OnHPChangeEvent { get { return onHPChangeEvent; } }
public UnityEvent OnDie { get { return onDie; } }
public bool Invulnerable { get; set; }
public bool IsDead { get { return isDead; } }
public float MaxHP { get { return maxHP; } }
protected virtual void Awake()
{
maxHP = hp;
SetDamageablePartsOwner();
}
protected virtual void Update()
{
DoRegeneration();
}
protected virtual void DoRegeneration()
{
if(regenerationSpeed > 0.0f && !isDead)
{
ModifyHP( regenerationSpeed * Time.deltaTime );
}
}
protected virtual void SetDamageablePartsOwner()
{
//get all damageable
DamageablePart[] damageableArray = GetComponentsInChildren<DamageablePart>();
//set his owner
for (int n = 0; n < damageableArray.Length; n++)
{
damageableArray[n].SetOwner( this );
}
}
public virtual void DoDamage(DamageInfo info, DamageablePart damageable)
{
//if we are dead just apply the impact force
if (isDead)
{
ApplyImpactForce( info, damageable );
if (onDamage != null)
onDamage.Invoke( info , damageable );
return;
}
ModifyHP(-info.dmg);
if (hp <= 0.0f)
{
TriggerDieEvent();
ApplyImpactForce( info, damageable );
}
if (onDamage != null)
{
onDamage.Invoke( info, damageable );
}
}
protected virtual void ApplyImpactForce(DamageInfo info, DamageablePart damageable)
{
//if this AI if no dead it is being controlled by the Animator so dont apply any impact force
if (!IsDead)
return;
if (com != null && info.damageType == DamageType.Explosion)
{
com.AddExplosionForce( info.hitForce, info.hitPoint, info.explosionRadius, info.upwardsModifier, info.forceMode );
}
else if (damageable.RB != null && info.damageType == DamageType.Shoot)
{
damageable.RB.AddForceAtPosition( info.hitForce * info.hitDir, info.hitPoint, info.forceMode );
}
}
protected virtual void TriggerDieEvent()
{
if (onDie != null)
onDie.Invoke();
isDead = true;
}
public void SetupDamageableLimbs()
{
Collider[] colliderArray = transform.GetComponentsInChildren<Collider>();
for (int n = 0; n < colliderArray.Length; n++)
{
if (colliderArray[n].GetComponent<DamageableLimb>() == null)
{
colliderArray[n].gameObject.AddComponent<DamageableLimb>();
}
}
}
public virtual void Kill()
{
ModifyHP(float.MinValue);
if (onDie != null)
onDie.Invoke();
}
public virtual void ModifyHP(float v, bool triggerEvent = true)
{
hp += v;
if (hp < 0.0f)
hp = 0.0f;
if (hp > MaxHP)
hp = maxHP;
if (triggerEvent)
{
onHPChangeEvent.Invoke(hp);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d98d12e9d483ed74eb1c70105c7cce4d
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/VRDamageSystem/DamageableManager.cs
uploadId: 546658
@@ -0,0 +1,31 @@
using UnityEngine;
namespace DamageSystem
{
public class DamageableManagerAI : DamageableManager
{
protected override void Awake()
{
base.Awake();
OnDamage.AddListener( ApplyImpactForce );
}
private void ApplyImpactForce(DamageInfo info, DamageablePart damageable)
{
//if this AI if no dead it is being controlled by the Animator so dont apply any impact force
if (!IsDead)
return;
if (com != null && info.damageType == DamageType.Explosion)
{
com.AddExplosionForce( info.hitForce, info.hitPoint, info.explosionRadius, info.upwardsModifier, info.forceMode );
}
else if (damageable.RB != null && info.damageType == DamageType.Shoot)
{
damageable.RB.AddForceAtPosition( info.hitForce * info.hitDir, info.hitPoint, info.forceMode );
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6a8bf86371483fe4bb3449526154a5c7
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/VRDamageSystem/DamageableManagerAI.cs
uploadId: 546658
@@ -0,0 +1,86 @@
using UnityEngine;
using UnityEngine.Serialization;
using VRSDK;
namespace DamageSystem
{
public class DamageablePart : Damageable
{
[FormerlySerializedAs("damageMultiplier")]
[SerializeField] private float m_damageMultiplier = 1.0f;
[FormerlySerializedAs("rb")]
[SerializeField] private Rigidbody m_rb = null;
private DamageableManager m_owner = null;
public Rigidbody RB => m_rb;
public DamageableManager Owner => m_owner;
public float DamageMultiplier => m_damageMultiplier;
private void Awake()
{
if(m_rb == null) m_rb = GetComponent<Rigidbody>();
}
public void ExternalSetup(float damageMultiplier, Rigidbody rb)
{
m_damageMultiplier = damageMultiplier;
m_rb = rb;
}
public void SetOwner(DamageableManager owner)
{
this.m_owner = owner;
}
public override void DoDamage(DamageInfo info)
{
if (m_owner == null)
{
return;
}
info.dmg *= m_damageMultiplier;
m_owner.DoDamage( info, this );
}
private void ProcessHit(Rigidbody rb , GameObject sender)
{
if (m_owner == null)
{
return;
}
DamageInfo info = new DamageInfo();
info.damageType = DamageType.Physical;
info.hitDir = rb.linearVelocity.normalized;
info.dmg = rb.linearVelocity.magnitude * m_damageMultiplier;
info.hitForce = rb.linearVelocity.magnitude;
info.sender = sender;
DoDamage( info );
}
private void OnCollisionEnter(Collision other)
{
//in this way we can respond to hits from objects and apply damage,
//like the player throwing a box to a enemy
if (other.rigidbody != null)
{
VR_Grabbable grabbable = VR_Manager.instance.GetGrabbableFromCollider(other.collider);
if (grabbable != null && grabbable.ObjectWasThrow && grabbable.LastInteractController != null)
{
GameObject sender = grabbable.LastInteractController.transform.root.gameObject;
ProcessHit( other.rigidbody, sender );
}
else
{
ProcessHit( other.rigidbody, other.gameObject );
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b09e825e715e4d740bffea4f46d0b742
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/VRDamageSystem/DamageablePart.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 21262b0943f423b4b91dc6d8b743e03a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
using UnityEngine;
using System.Collections.Generic;
namespace DamageSystem.Dismember
{
public enum BodyPartType
{
Head,
LeftArm,
LeftForeArm,
RightArm,
RightForeArm,
RightLeg,
RightCalf,
LeftLeg,
LeftCalf
}
public class DismemberManager : MonoBehaviour
{
[SerializeField] private List<DismemberPart> dismembertPartList = null;
private DamageableManager damageableManager = null;
private void Awake()
{
damageableManager = GetComponent<DamageableManager>();
for (int n = 0; n < dismembertPartList.Count; n++)
{
dismembertPartList[n].SetHP(damageableManager.HP);
dismembertPartList[n].OnDismember.AddListener( OnDismember );
}
}
private void OnDismember(DismemberPart part)
{
if(part.KillOnDismember)
{
damageableManager.Kill();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 56a8f8f39db08334fadbaa616a558c61
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/VRDamageSystem/Dismember/DismemberManager.cs
uploadId: 546658
@@ -0,0 +1,114 @@
using UnityEngine;
using System.Collections.Generic;
using DamageSystem.Events;
namespace DamageSystem.Dismember
{
public class DismemberPart : Damageable
{
[SerializeField] private Rigidbody bodyPartPrefab = null;
[SerializeField] private GameObject realBodyPart = null;
[SerializeField] private float resistance = 0.25f;
[SerializeField] private bool killOnDismember = false;
[SerializeField] private GameObject[] connectedBodyParts = null;
[SerializeField] private OnDismemberEvent onDismember = null;
private float hp = 0.0f;
private DamageablePart thisDamageablePart = null;
private Dictionary<Mesh, GameObject> bodyPartStateConnections = new Dictionary<Mesh, GameObject>();
private Rigidbody thisRB = null;
public bool KillOnDismember { get { return killOnDismember; } }
public float Resistance { get { return resistance; } }
public OnDismemberEvent OnDismember { get { return onDismember; } }
private void Awake()
{
thisDamageablePart = GetComponent<DamageablePart>();
thisRB = GetComponent<Rigidbody>();
}
private void Start()
{
CreateBodyPartStateConnections();
}
private void CreateBodyPartStateConnections()
{
for (int n = 0; n < connectedBodyParts.Length; n++)
{
SkinnedMeshRenderer skinnedMeshRender = connectedBodyParts[n].GetComponent<SkinnedMeshRenderer>();
if (skinnedMeshRender != null)
{
bodyPartStateConnections[skinnedMeshRender.sharedMesh] = skinnedMeshRender.gameObject;
}
}
}
public void SetHP(float hp)
{
this.hp = hp * resistance;
}
public override void DoDamage(DamageInfo info)
{
hp -= info.dmg * thisDamageablePart.DamageMultiplier;
if( CanDismember(info) )
{
Rigidbody bodyPart = CreateBodyPart();
info.ApplyImpact( bodyPart );
onDismember.Invoke(this);
}
}
private bool CanDismember(DamageInfo info)
{
return info.canDismember && hp <= 0.0f && realBodyPart.gameObject.activeInHierarchy;
}
private Rigidbody CreateBodyPart()
{
Rigidbody bodyPart = Instantiate( bodyPartPrefab, transform.position, transform.rotation );
DestroyUnnecesaryBodyParts(bodyPart.gameObject);
realBodyPart.gameObject.SetActive( false );
DisableConnectedBodyParts();
return bodyPart;
}
private void DisableConnectedBodyParts()
{
for (int n = 0; n < connectedBodyParts.Length; n++)
{
connectedBodyParts[n].SetActive(false);
}
}
//disable body parts that has been already dismember
private void DestroyUnnecesaryBodyParts(GameObject bodyPart)
{
foreach ( Transform child in bodyPart.transform)
{
MeshFilter meshRender = child.GetComponent<MeshFilter>();
if (meshRender != null)
{
GameObject bodyPartGO = null;
if (bodyPartStateConnections.TryGetValue( meshRender.sharedMesh, out bodyPartGO ))
{
meshRender.gameObject.SetActive( bodyPartGO.activeInHierarchy );
}
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1c8caeb8b6a7ea946acfd1f6729a1d8d
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/VRDamageSystem/Dismember/DismemberPart.cs
uploadId: 546658
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 994fcaebc2010c345a36ce55b29394b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
using UnityEngine.Events;
namespace DamageSystem.Events
{
[System.Serializable]
public class OnDamageEvent : UnityEvent<DamageInfo , DamageablePart> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 08d138e6abccc3d4fb99c33db9808fe3
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/VRDamageSystem/Events/OnDamageEvent.cs
uploadId: 546658
@@ -0,0 +1,9 @@
using DamageSystem.Dismember;
using UnityEngine.Events;
namespace DamageSystem.Events
{
[System.Serializable]
public class OnDismemberEvent : UnityEvent<DismemberPart> { }
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b652d6b75b904b7cbdcc24f54ca67181
timeCreated: 1669476741
AssetOrigin:
serializedVersion: 1
productId: 168243
packageName: VR Beats Kit
packageVersion: 2.0
assetPath: Assets/VRBeatsKit/Modules/VRDamageSystem/Events/OnDismemberEvent.cs
uploadId: 546658
@@ -0,0 +1,7 @@
using UnityEngine.Events;
namespace DamageSystem.Events
{
[System.Serializable]
public class OnValueChangeEvent : UnityEvent<float> { }
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7688e570cdb728a498bc5f6ce954fb94
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/VRDamageSystem/Events/OnValueChangeEvent.cs
uploadId: 546658
@@ -0,0 +1,109 @@
using UnityEngine;
using VRSDK;
namespace DamageSystem
{
public class Explosion : MonoBehaviour
{
#region INSPECTOR
[SerializeField] private float dmg = 200.0f;
[SerializeField] private float explosionRange = 0.0f;
[SerializeField] private float explosionForce = 0.0f;
[SerializeField] private float upwardsModifier = 0.0f;
[SerializeField] private bool autoExplode = true;
#endregion
private DamageInfo damageInfo = new DamageInfo();
private void Awake()
{
if (autoExplode)
{
Explode();
}
}
public virtual void Explode(GameObject sender = null)
{
Collider[] colliderArray = Physics.OverlapSphere( transform.position, explosionRange );
for (int n = 0; n < colliderArray.Length; n++)
{
Damageable damageable = colliderArray[n].GetComponent<Damageable>();
if (damageable != null)
{
float distance = Vector3.Distance(transform.position, damageable.transform.position);
float distanceFactor = Mathf.Abs((distance / explosionRange) - 1.0f); // a distance factor from 0.0f to 1.0f
//create damage info
DamageInfo info = CreateDamageInfo(distanceFactor);
info.sender = sender;
//send damage event
DoDamage(damageable, info);
}
else
{
Rigidbody rb = colliderArray[n].GetComponent<Rigidbody>();
if (rb != null)
{
ApplyImpactForce( rb );
}
else
{
VR_Grabbable grabbable = VR_Manager.instance.GetGrabbableFromCollider( colliderArray[n] );
if (grabbable != null && grabbable.RB != null)
{
ApplyImpactForce( grabbable.RB );
}
}
}
}
Destroy( gameObject , 5.0f);
}
private DamageInfo CreateDamageInfo(float distanceFactor)
{
if (damageInfo != null)
{
damageInfo = new DamageInfo();
}
damageInfo.hitForce = explosionForce;
damageInfo.hitPoint = transform.position;
damageInfo.explosionRadius = explosionRange;
damageInfo.upwardsModifier = upwardsModifier;
damageInfo.dmg = dmg * distanceFactor;
damageInfo.damageType = DamageType.Explosion;
return damageInfo;
}
protected virtual void ApplyImpactForce(Rigidbody rb)
{
rb.AddExplosionForce( explosionForce, transform.position, explosionRange, upwardsModifier );
}
protected virtual void DoDamage(Damageable damageable, DamageInfo info)
{
damageable.DoDamage(info);
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere( transform.position, explosionRange );
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0c1fe70580def5e41bcb0e40dd75f8a2
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/VRDamageSystem/Explosion.cs
uploadId: 546658
@@ -0,0 +1,109 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageSystem
{
public class FastCollisionListener : MonoBehaviour
{
[SerializeField] private BoxCollider raycastCollider = null;
[SerializeField] private LayerMask layerMask;
[SerializeField] private int collisionAccuracy = 5;
private Pose[] poseArray;
private Pose lastPose;
private bool shouldFillPoses = false;
private BoxCollider raycastColliderClone = null;
private List<Collider> colliderHitThisFrame = new List<Collider>();
private void Awake()
{
poseArray = new Pose[ collisionAccuracy -1 ];
if (raycastCollider != null)
{
raycastColliderClone = Instantiate( raycastCollider );
raycastColliderClone.transform.localScale = raycastCollider.transform.lossyScale;
raycastColliderClone.isTrigger = true;
}
}
private void LateUpdate()
{
UpdateLastPositionAndRotation();
shouldFillPoses = true;
}
private void FillPoses()
{
if (!shouldFillPoses)
return;
shouldFillPoses = false;
float step = 1.0f / collisionAccuracy;
float currentStep = step;
int index = 0;
while (currentStep < 1.0f)
{
Vector3 position = Vector3.Lerp(lastPose.position, raycastCollider.transform.position, currentStep);
Quaternion rotation = Quaternion.Slerp(lastPose.rotation, raycastCollider.transform.rotation, currentStep);
poseArray[index].position = position;
poseArray[index].rotation = rotation;
currentStep += step;
index++;
}
}
private void UpdateLastPositionAndRotation()
{
lastPose.position = raycastCollider.transform.position;
lastPose.rotation = raycastCollider.transform.rotation;
}
private void PoseRaycast(Pose pose)
{
raycastColliderClone.transform.position = pose.position;
raycastColliderClone.transform.rotation = pose.rotation;
Collider[] colliderArray = PhysicsExtensions.OverlapBox(raycastColliderClone, layerMask, QueryTriggerInteraction.Ignore);
for (int n = 0; n < colliderArray.Length; n++)
{
if (colliderArray[n] == null) continue;
if (!colliderHitThisFrame.Contains(colliderArray[n]))
{
colliderHitThisFrame.Add(colliderArray[n]);
}
}
}
public List<Collider> CheckForCollisionsThisFrame()
{
colliderHitThisFrame = new List<Collider>();
FillPoses();
for (int n = 0; n < poseArray.Length; n++)
{
PoseRaycast( poseArray[n] );
}
return colliderHitThisFrame;
}
}
public struct Pose
{
public Vector3 position;
public Quaternion rotation;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 742a6eb0064b358478b6424c10bf9f96
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/VRDamageSystem/FastCollisionListener.cs
uploadId: 546658
@@ -0,0 +1,20 @@
using UnityEngine;
namespace DamageSystem
{
public class GlobalSurfaceDetails : MonoBehaviour
{
[SerializeField] private SurfaceDetails copyBase = null;
private void Awake()
{
SurfaceDetails[] surfaceDetailsArray = transform.GetComponentsInChildren<SurfaceDetails>();
for (int n = 0; n < surfaceDetailsArray.Length; n++)
{
surfaceDetailsArray[n].CopySettings(copyBase);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 95a98fddc3710d449a2db2c665062e5a
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/VRDamageSystem/GlobalSurfaceDetails.cs
uploadId: 546658
@@ -0,0 +1,95 @@
using UnityEngine;
namespace DamageSystem
{
//this script details about how should a bullet bounce over this object
public class SurfaceDetails : Damageable
{
[SerializeField] private bool bulletsCanBounce = false;
[SerializeField] private bool stickArrows = true;
[SerializeField] private float bulletsSpeedLoseOnBounce = 0.20f;
[SerializeField] private AudioClip[] hitSoundArray = null;
[SerializeField] [Range(0.0f , 1.0f)] private float soundvolume = 1.0f;
[SerializeField] private GameObject[] hitEffectArray = null;
[SerializeField] private float lifeTime = 0.0f;
[SerializeField] private bool parentEffect = false;
[SerializeField] private Vector3 rotOffset = Vector3.zero;
[SerializeField] private float effectMinDelay = 0.0f;
[SerializeField] private float effectMaxDelay = 0.0f;
public bool BulletsCanBounce { get { return bulletsCanBounce; } }
public bool StickArrows { get { return stickArrows; } }
public float BulletsSpeedLoseOnBounce { get { return bulletsSpeedLoseOnBounce; } }
private AudioSource audioSource = null;
private float nextEffectTime = 0.0f;
public void CopySettings(SurfaceDetails surface)
{
bulletsCanBounce = surface.bulletsCanBounce;
bulletsSpeedLoseOnBounce = surface.bulletsSpeedLoseOnBounce;
hitSoundArray = surface.hitSoundArray;
hitEffectArray = surface.hitEffectArray;
soundvolume = surface.soundvolume;
lifeTime = surface.lifeTime;
parentEffect = surface.parentEffect;
rotOffset = surface.rotOffset;
effectMinDelay = surface.effectMinDelay;
effectMaxDelay = surface.effectMaxDelay;
}
public override void DoDamage(DamageInfo info)
{
if(nextEffectTime > Time.time)
return;
nextEffectTime = Random.Range(effectMinDelay, effectMaxDelay) + Time.time;
InstantiateHitEffect(info.hitPoint , Quaternion.LookRotation( info.hitDir ) * Quaternion.Euler(rotOffset));
PlayHitSound();
}
private void PlayHitSound()
{
if (hitSoundArray == null || hitSoundArray.Length == 0)
return;
if (audioSource == null)
{
audioSource = GetComponent<AudioSource>();
if (audioSource == null)
{
audioSource = gameObject.AddComponent<AudioSource>();
}
}
if (audioSource.isPlaying)
audioSource.Stop();
audioSource.volume = Random.Range(soundvolume/2.0f , soundvolume);
audioSource.pitch = Random.Range(0.7f , 1.0f);
audioSource.clip = hitSoundArray[ Random.Range(0 , hitSoundArray.Length) ];
audioSource.Play();
}
private void InstantiateHitEffect(Vector3 position , Quaternion rotation)
{
if (hitEffectArray == null || hitEffectArray.Length == 0)
return;
GameObject go = Instantiate( hitEffectArray[Random.Range( 0, hitEffectArray.Length )], position, rotation);
Destroy( go, lifeTime );
if (parentEffect)
{
go.transform.parent = transform;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ebd6e5e201849d845bb8cd39dacac25f
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/VRDamageSystem/SurfaceDetails.cs
uploadId: 546658
@@ -0,0 +1,97 @@
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using VRSDK;
namespace DamageSystem
{
//this script controls the melee weapons like the sword,
//in the demo scene and the weapons prefabs, all the weapons can be use as melee weapons to,
//so they use this script
public class VR_MeleeWeapon : MonoBehaviour
{
#region INSPECTOR
[SerializeField] protected FastCollisionListener fastCollisionListener = null;
[SerializeField] protected Transform rayStart = null;
[SerializeField] protected Transform rayEnd = null;
[SerializeField] protected float minSpeed = 0.0f;
[SerializeField] protected float dmg = 0.0f;
[SerializeField] protected float hitForce = 0.0f;
[SerializeField] protected float maxHitForce = 800.0f;
[SerializeField] protected bool canDismember = false;
#endregion
#region PRIVATE
private VR_Grabbable grabbable = null;
private List<Damageable> thisDamageableList = null;
protected DamageInfo damageInfoCache = new DamageInfo();
#endregion
private void Awake()
{
grabbable = GetComponent<VR_Grabbable>();
thisDamageableList = transform.GetComponentsInChildren<Damageable>().ToList();
}
private void Update()
{
//check if we are hitting something
//we do it in the fixed update because the player can move his hands very quickly
if ( grabbable.CurrentGrabState == GrabState.Grab && grabbable.GrabController.Velocity.magnitude > minSpeed )
{
List<Collider> hitColliders = fastCollisionListener.CheckForCollisionsThisFrame();
for (int n = 0; n < hitColliders.Count; n++)
{
TryDoDamage(hitColliders[n].transform, hitColliders[n].transform.position);
}
}
}
protected bool TryDoDamage(Transform target, Vector3 hitPoint)
{
Damageable[] damageableArray = target.GetComponents<Damageable>();
if (damageableArray != null && damageableArray.Length > 0)
{
for (int n = 0; n < damageableArray.Length; n++)
{
if (damageableArray[n] != null && !thisDamageableList.Contains( damageableArray[n]) )
{
RaycastHit hitInfo;
if (Physics.Linecast(rayStart.position, rayEnd.position, out hitInfo, 1 << target.gameObject.layer))
{
DamageInfo damageInfo = CreateDamageInfo(hitInfo.point);
damageableArray[n].DoDamage(damageInfo);
}
}
}
return true;
}
return false;
}
protected virtual DamageInfo CreateDamageInfo(Vector3 hitPoint)
{
Vector3 controllerVelocity = grabbable.GrabController.Velocity;
damageInfoCache.dmg = dmg * controllerVelocity.magnitude;
damageInfoCache.hitDir = controllerVelocity.normalized;
damageInfoCache.hitPoint = hitPoint;
damageInfoCache.hitForce = Mathf.Min( ( controllerVelocity * hitForce ).magnitude, maxHitForce );
damageInfoCache.sender = grabbable.GrabController != null ? grabbable.GrabController.transform.root.gameObject : null;
damageInfoCache.canDismember = canDismember;
return damageInfoCache;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c68346ff56573a1429560a527ad447e0
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/VRDamageSystem/VR_MeleeWeapon.cs
uploadId: 546658
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 63aa720e8056d2c4d96c09f6a78f32b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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

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