Characters
This commit is contained in:
43
Game/Scripts/WeaponSystem/WeaponView.cs
Normal file
43
Game/Scripts/WeaponSystem/WeaponView.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MegaKoop.Game.WeaponSystem
|
||||
{
|
||||
public class WeaponView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform[] muzzles;
|
||||
|
||||
public Transform[] Muzzles => muzzles;
|
||||
|
||||
public Transform GetMuzzle(int index = 0)
|
||||
{
|
||||
if (muzzles == null || muzzles.Length == 0)
|
||||
{
|
||||
return transform;
|
||||
}
|
||||
|
||||
index = Mathf.Clamp(index, 0, muzzles.Length - 1);
|
||||
return muzzles[index] == null ? transform : muzzles[index];
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (muzzles == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Gizmos.color = Color.cyan;
|
||||
foreach (Transform muzzle in muzzles)
|
||||
{
|
||||
if (muzzle == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Gizmos.DrawLine(muzzle.position, muzzle.position + muzzle.forward * 0.5f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user