upgrade to unity 6.1

This commit is contained in:
2025-07-17 15:57:56 +02:00
parent 702b766981
commit eea0e3ffad
1167 changed files with 62538 additions and 8659 deletions

View File

@@ -15,11 +15,11 @@ namespace HurricaneVR.Framework.Weapons.Guns
{
public class HVRGunBase : HVRDamageProvider
{
public HVRGrabbable Grabbable { get; private set; }
[Header("Settings")]
public float TriggerPullThreshold = .7f;
public float TriggerResetThreshold = .6f;
[Tooltip("Cooldown before the next shot")]
@@ -27,6 +27,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Tooltip("Physics layers for the ray cast")]
public LayerMask HitLayerMask;
public float MuzzleFlashTime = .2f;
[Tooltip("Flexible bullet range per gun type")]
@@ -37,6 +38,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Tooltip("Is chambering required to shoot")]
public bool RequiresChamberedBullet = true;
public GunFireType FireType = GunFireType.Single;
[Tooltip("Speed of the bullet prefab")]
@@ -68,10 +70,10 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Header("Haptics")]
public HVRGunHaptics Haptics;
public List<HVRGrabbable> HapticGrabbables = new List<HVRGrabbable>();
[Header("Objects")]
[Tooltip("Muzzle flash object")]
public GameObject MuzzleFlashObject;
@@ -82,7 +84,6 @@ namespace HurricaneVR.Framework.Weapons.Guns
public GameObject ChamberedCasing;
[Header("Required Transforms")]
[Tooltip("Optional Direction to eject Ammo - use the z axis")]
public Transform AmmoEjectDirection; //forward
@@ -91,6 +92,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Header("Components")]
public HVRGunEmitterBase BulletEmitter;
public HVRGunEmitterBase CasingEmitter;
public HVRCockingHandle CockingHandle;
public HVRGunBolt Bolt;
@@ -110,6 +112,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Header("Animation")]
public HVRTriggerAnimator TriggerAnimator;
public float CyclingTime;
public bool AnimateGun = true;
public Animator Animator;
@@ -119,12 +122,14 @@ namespace HurricaneVR.Framework.Weapons.Guns
[Header("Projectile")]
public bool SlowMotionBulletOnly;
public GameObject BulletPrefab;
public float BulletLife = 5f;
private readonly List<HVRBulletTracker> _objects = new List<HVRBulletTracker>();
private HVRGunPart[] _animatableGunParts;
private Coroutine _animationRoutine;
private HashSet<IGunHitHandler> _hitHandlers;
public UnityEvent Fired = new UnityEvent();
public HVRGunHitEvent Hit = new HVRGunHitEvent();
@@ -234,10 +239,24 @@ namespace HurricaneVR.Framework.Weapons.Guns
{
CasingEmitter.Gun = this;
}
_hitHandlers = new HashSet<IGunHitHandler>();
foreach (var handler in GetComponentsInChildren<IGunHitHandler>())
{
_hitHandlers.Add(handler);
}
}
public void AddHitHandler(IGunHitHandler handler)
{
_hitHandlers.Add(handler);
}
public void RemoveHitHandler(IGunHitHandler handler)
{
_hitHandlers.Remove(handler);
}
protected virtual void SetupPooledBullets()
{
@@ -282,7 +301,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
}
}
public bool IsTriggerReset;// { get; set; }
public bool IsTriggerReset; // { get; set; }
public bool IsTriggerPulled; //{ get; set; }
protected virtual void CheckTriggerPull()
@@ -437,7 +456,6 @@ namespace HurricaneVR.Framework.Weapons.Guns
}
protected virtual void OnAmmoSocketed(HVRGrabberBase grabber, HVRGrabbable grabbable)
{
var ammo = grabbable.GetComponent<HVRAmmo>();
@@ -484,6 +502,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
{
AfterAmmoReleased(AmmoGrabbable, Ammo);
}
Ammo = null;
AmmoGrabbable = null;
AmmoSocketReleasedHaptics();
@@ -524,7 +543,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
if (ammoGrabbable.Rigidbody)
{
ammoGrabbable.Rigidbody.velocity = direction.normalized * AmmoEjectVelocity;
ammoGrabbable.Rigidbody.linearVelocity = direction.normalized * AmmoEjectVelocity;
}
}
@@ -654,7 +673,6 @@ namespace HurricaneVR.Framework.Weapons.Guns
}
private IEnumerator RenablePhysics(HVRGrabbable grabbable, HVRHandGrabber hand)
{
yield return new WaitForSeconds(1);
@@ -854,6 +872,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
{
EjectCasing();
}
if (Bolt && BoltPushedBackAfterEmpty)
{
Bolt.PushBack();
@@ -935,12 +954,10 @@ namespace HurricaneVR.Framework.Weapons.Guns
bullet.Bullet.transform.rotation = Quaternion.FromToRotation(bullet.Bullet.transform.forward, direction) *
bullet.Bullet.transform.rotation;
bullet.SetRenderersActive(!SlowMotionBulletOnly || HVRTimeManager.Instance.IsTimeSlowed);
}
protected virtual void AfterFired()
{
}
protected virtual void MuzzleFlash()
@@ -953,7 +970,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
private IEnumerator MuzzleFlashRoutine()
{
MuzzleFlashObject.SetActive(false);/// ADDED to cancel longer fx like smoke to allow flame fx to fire again.
MuzzleFlashObject.SetActive(false); /// ADDED to cancel longer fx like smoke to allow flame fx to fire again.
MuzzleFlashObject.SetActive(true);
var elapsed = 0f;
@@ -1005,7 +1022,6 @@ namespace HurricaneVR.Framework.Weapons.Guns
Animator.enabled = false;
}
protected virtual void OnHit(RaycastHit hit, Vector3 direction)
{
var damageHandler = hit.collider.GetComponent<HVRDamageHandlerBase>();
@@ -1015,6 +1031,10 @@ namespace HurricaneVR.Framework.Weapons.Guns
damageHandler.HandleRayCastHit(DamageProvider, hit);
}
foreach (var hh in _hitHandlers)
{
hh.HandleHit(DamageProvider, hit, direction);
}
if (AddForceOnHit && hit.collider.attachedRigidbody)
{
@@ -1095,7 +1115,6 @@ namespace HurricaneVR.Framework.Weapons.Guns
}
}
}
}
private class HVRBulletTracker
@@ -1127,11 +1146,10 @@ namespace HurricaneVR.Framework.Weapons.Guns
}
}
}
[Serializable]
public class HVRGunHitEvent : UnityEvent<GunHitArgs>
{
}
public struct GunHitArgs
@@ -1155,7 +1173,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
Distance = hit.distance;
}
}
public enum GunFireType
{
Single,