Add ultimate xr

This commit is contained in:
2024-08-06 21:58:35 +02:00
parent 864033bf10
commit 7165bacd9d
3952 changed files with 2162037 additions and 35 deletions

View File

@@ -0,0 +1,71 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MagAmmoIndicator.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using UltimateXR.Core.Components;
using UltimateXR.Mechanics.Weapons;
using UnityEngine;
namespace UltimateXR.Examples.FullScene.Weapons
{
[RequireComponent(typeof(UxrFirearmMag))]
public class MagAmmoIndicator : UxrComponent
{
#region Inspector Properties/Serialized Fields
[SerializeField] private bool _setValueOnStart = true;
[SerializeField] private Renderer _renderer;
#endregion
#region Unity
protected override void Awake()
{
base.Awake();
_mag = GetComponent<UxrFirearmMag>();
}
protected override void OnEnable()
{
base.OnEnable();
_mag.RoundsChanged += OnRoundsChanged;
}
protected override void OnDisable()
{
base.OnDisable();
_mag.RoundsChanged -= OnRoundsChanged;
}
protected override void Start()
{
base.OnEnable();
if (_setValueOnStart)
{
OnRoundsChanged();
}
}
#endregion
#region Event Trigger Methods
private void OnRoundsChanged()
{
_renderer.material.SetFloat(FillVariableName, (float)_mag.Rounds / _mag.Capacity);
}
#endregion
#region Private Types & Data
private const string FillVariableName = "_Fill";
private UxrFirearmMag _mag;
#endregion
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 80780a72a3aeaf549a04f479bfc41f47
timeCreated: 1533626585
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: