chore: Project Restructuring & Theatre
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using UnityEngine;
|
||||
using Unheimlich.Features.Player;
|
||||
|
||||
namespace Unheimlich.Dev
|
||||
{
|
||||
public class AudioSourceDemo : MonoBehaviour
|
||||
{
|
||||
[Header("Demo Settings")]
|
||||
[SerializeField] private AudioClip _clip;
|
||||
[SerializeField] private bool _playOnStart = true;
|
||||
[SerializeField] private bool _loop = true;
|
||||
[SerializeField] private float _volume = 0.5f;
|
||||
[SerializeField] private float _sourceMinDistance = 1f;
|
||||
[SerializeField] private float _sourceMaxDistance = 20;
|
||||
|
||||
[Header("Distance Culling")]
|
||||
[SerializeField] private bool _enableDistanceCulling = true;
|
||||
[SerializeField] private float _cullingDistance = 50f;
|
||||
[SerializeField] private float _fadeStartDistance = 40f;
|
||||
|
||||
private AudioSource _source;
|
||||
private bool _hasStarted = false;
|
||||
private float _savedTime = 0f;
|
||||
private bool _wasPlaying = false;
|
||||
private bool _isCulled = false;
|
||||
private Transform _player;
|
||||
|
||||
public float OriginalVolume => _volume;
|
||||
|
||||
public float GetDistanceFadeMultiplier(Vector3 listenerPosition)
|
||||
{
|
||||
if (!_enableDistanceCulling)
|
||||
return 1f;
|
||||
|
||||
float distance = Vector3.Distance(transform.position, listenerPosition);
|
||||
|
||||
if (distance > _cullingDistance)
|
||||
return 0f;
|
||||
|
||||
if (distance > _fadeStartDistance)
|
||||
{
|
||||
float fadeRange = _cullingDistance - _fadeStartDistance;
|
||||
float fadeAmount = (distance - _fadeStartDistance) / fadeRange;
|
||||
return 1f - Mathf.Clamp01(fadeAmount);
|
||||
}
|
||||
|
||||
return 1f;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_source = GetComponent<AudioSource>();
|
||||
if (_source == null)
|
||||
_source = gameObject.AddComponent<AudioSource>();
|
||||
|
||||
_source.clip = _clip;
|
||||
_source.loop = _loop;
|
||||
_source.volume = _volume;
|
||||
_source.playOnAwake = false;
|
||||
_source.spatialBlend = 1f;
|
||||
_source.rolloffMode = AudioRolloffMode.Logarithmic;
|
||||
_source.minDistance = _sourceMinDistance;
|
||||
_source.maxDistance = _sourceMaxDistance;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_wasPlaying && _savedTime > 0f)
|
||||
{
|
||||
_source.time = _savedTime;
|
||||
_source.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_playOnStart && _clip != null && !_hasStarted && !_source.isPlaying)
|
||||
{
|
||||
_source.Play();
|
||||
_hasStarted = true;
|
||||
}
|
||||
|
||||
PlayerController playerObj = PlayerController.Instance;
|
||||
if (playerObj != null)
|
||||
_player = playerObj.transform;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_enableDistanceCulling && _player != null && _source != null)
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, _player.position);
|
||||
|
||||
if (distance > _cullingDistance)
|
||||
{
|
||||
if (!_isCulled)
|
||||
{
|
||||
_source.volume = 0f;
|
||||
_isCulled = true;
|
||||
}
|
||||
}
|
||||
else if (distance > _fadeStartDistance)
|
||||
{
|
||||
float fadeRange = _cullingDistance - _fadeStartDistance;
|
||||
float fadeAmount = (distance - _fadeStartDistance) / fadeRange;
|
||||
fadeAmount = Mathf.Clamp01(fadeAmount);
|
||||
_source.volume = _volume * (1f - fadeAmount);
|
||||
_isCulled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isCulled || _source.volume != _volume)
|
||||
{
|
||||
_source.volume = _volume;
|
||||
_isCulled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_wasPlaying = _source.isPlaying;
|
||||
_savedTime = _source.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f399329860533c14fba15187d7e340db
|
||||
@@ -0,0 +1,124 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using UnityEngine;
|
||||
using Unheimlich.Features.Player;
|
||||
using Unheimlich.Features.Diapason;
|
||||
using Unheimlich.Core.Audio;
|
||||
namespace Unheimlich.Dev
|
||||
{
|
||||
public class DiapasonDebugger : MonoBehaviour
|
||||
{
|
||||
[Header("Debug Display")]
|
||||
[SerializeField] private bool _showDebugInfo = true;
|
||||
[SerializeField] private bool _showGizmos = true;
|
||||
[SerializeField] private Color _listeningRangeColor = Color.cyan;
|
||||
[SerializeField] private Color _activeTargetColor = Color.green;
|
||||
|
||||
private DiapasonListeningHandlerV2 _listeningHandler;
|
||||
private AudioListenable[] _allListenables;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_listeningHandler = DiapasonListeningHandlerV2.Instance;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
RefreshListenablesList();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!_showDebugInfo || _listeningHandler == null)
|
||||
return;
|
||||
|
||||
GUILayout.BeginArea(new Rect(10, 10, 300, 200));
|
||||
GUILayout.Box("Diapason System Debug");
|
||||
|
||||
GUILayout.Label($"Is Listening: {_listeningHandler.IsListening}");
|
||||
GUILayout.Label($"Is Concentrating: {_listeningHandler.IsConcentrating}");
|
||||
|
||||
if (_allListenables != null)
|
||||
GUILayout.Label($"Total Listenables: {_allListenables.Length}");
|
||||
|
||||
if (GUILayout.Button("Refresh Listenables List"))
|
||||
RefreshListenablesList();
|
||||
|
||||
if (GUILayout.Button("Toggle Debug Gizmos"))
|
||||
_showGizmos = !_showGizmos;
|
||||
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
|
||||
private void RefreshListenablesList()
|
||||
{
|
||||
_allListenables = FindObjectsByType<AudioListenable>(FindObjectsSortMode.None);
|
||||
if (!_showDebugInfo)
|
||||
return;
|
||||
Debug.Log($"Found {_allListenables.Length} AudioListenable objects in scene");
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (!_showGizmos)
|
||||
return;
|
||||
|
||||
if (_allListenables == null)
|
||||
_allListenables = FindObjectsByType<AudioListenable>(FindObjectsSortMode.None);
|
||||
|
||||
foreach (AudioListenable listenable in _allListenables)
|
||||
{
|
||||
if (listenable == null)
|
||||
continue;
|
||||
|
||||
Gizmos.color = _listeningRangeColor;
|
||||
Gizmos.DrawIcon(listenable.transform.position, "sv_icon_dot3_pix16_gizmo", true);
|
||||
|
||||
Gizmos.color = new Color(_listeningRangeColor.r, _listeningRangeColor.g, _listeningRangeColor.b, 0.1f);
|
||||
Gizmos.DrawSphere(listenable.transform.position, 0.2f);
|
||||
}
|
||||
|
||||
if (_listeningHandler != null && _listeningHandler.IsListening)
|
||||
{
|
||||
Gizmos.color = _activeTargetColor;
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("List All Listenables")]
|
||||
private void ListAllListenables()
|
||||
{
|
||||
RefreshListenablesList();
|
||||
|
||||
Debug.Log("=== Audio Listenables in Scene ===");
|
||||
foreach (AudioListenable listenable in _allListenables)
|
||||
{
|
||||
if (listenable != null)
|
||||
Debug.Log($"- {listenable.gameObject.name} (Type: {listenable.GetType().Name})");
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Enable All Listenables")]
|
||||
private void EnableAllListenables()
|
||||
{
|
||||
RefreshListenablesList();
|
||||
foreach (AudioListenable listenable in _allListenables)
|
||||
{
|
||||
if (listenable != null)
|
||||
listenable.enabled = true;
|
||||
}
|
||||
Debug.Log("Enabled all AudioListenable components");
|
||||
}
|
||||
|
||||
[ContextMenu("Disable All Listenables")]
|
||||
private void DisableAllListenables()
|
||||
{
|
||||
RefreshListenablesList();
|
||||
foreach (AudioListenable listenable in _allListenables)
|
||||
{
|
||||
if (listenable != null)
|
||||
listenable.enabled = false;
|
||||
}
|
||||
Debug.Log("Disabled all AudioListenable components");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7093688fd39800645bbe00b6d9a3f27b
|
||||
@@ -0,0 +1,183 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using UnityEngine;
|
||||
using Unheimlich.Features.OctoArms;
|
||||
|
||||
namespace Unheimlich.Dev
|
||||
{
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class DiapasonPoseTweaker : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private OctoIkArmsImproved _armsSystem;
|
||||
// [SerializeField] private int _armIndex = 1;
|
||||
|
||||
[Header("Quick Presets")]
|
||||
[SerializeField] private bool _applyPreset1 = false;
|
||||
[SerializeField] private bool _applyPreset2 = false;
|
||||
[SerializeField] private bool _applyPreset3 = false;
|
||||
|
||||
[Header("Live Tweaking (Runtime Only)")]
|
||||
[SerializeField] private Vector3 _shoulderRotation = new Vector3(20, 0, -10);
|
||||
[SerializeField] private Vector3 _elbowRotation = new Vector3(0, 0, 0);
|
||||
[SerializeField] private Vector3 _wristRotation = new Vector3(0, 0, 90);
|
||||
|
||||
[Header("Preview")]
|
||||
[SerializeField] private bool _previewPose = false;
|
||||
|
||||
private ArmEquipment _equipment;
|
||||
private bool _wasPreviewActive = false;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (_armsSystem == null)
|
||||
return;
|
||||
|
||||
if (_equipment == null)
|
||||
{
|
||||
var armRigField = typeof(OctoIkArmsImproved).GetField("_rightArm",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
if (armRigField != null)
|
||||
{
|
||||
var armRig = armRigField.GetValue(_armsSystem);
|
||||
var equipmentField = armRig.GetType().GetField("Equipment");
|
||||
if (equipmentField != null)
|
||||
{
|
||||
_equipment = (ArmEquipment)equipmentField.GetValue(armRig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_equipment == null)
|
||||
return;
|
||||
|
||||
if (_previewPose && _equipment.State == ArmState.Environmental)
|
||||
{
|
||||
ApplyRotations();
|
||||
_wasPreviewActive = true;
|
||||
}
|
||||
else if (_wasPreviewActive && !_previewPose)
|
||||
{
|
||||
ResetRotations();
|
||||
_wasPreviewActive = false;
|
||||
}
|
||||
|
||||
if (_equipment.State == ArmState.Equipped)
|
||||
{
|
||||
_equipment.ShoulderRotationOffset = _shoulderRotation;
|
||||
_equipment.ElbowRotationOffset = _elbowRotation;
|
||||
_equipment.WristRotationOffset = _wristRotation;
|
||||
}
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
if (_applyPreset1)
|
||||
{
|
||||
_applyPreset1 = false;
|
||||
ApplyPreset1();
|
||||
}
|
||||
|
||||
if (_applyPreset2)
|
||||
{
|
||||
_applyPreset2 = false;
|
||||
ApplyPreset2();
|
||||
}
|
||||
|
||||
if (_applyPreset3)
|
||||
{
|
||||
_applyPreset3 = false;
|
||||
ApplyPreset3();
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyPreset1()
|
||||
{
|
||||
_shoulderRotation = new Vector3(30, 0, -15);
|
||||
_elbowRotation = new Vector3(0, 10, 0);
|
||||
_wristRotation = new Vector3(0, 0, 90);
|
||||
Debug.Log("[DiapasonPose] Applied Preset 1: Close to body, slight inward");
|
||||
}
|
||||
|
||||
private void ApplyPreset2()
|
||||
{
|
||||
_shoulderRotation = new Vector3(20, -10, -20);
|
||||
_elbowRotation = new Vector3(0, 0, 0);
|
||||
_wristRotation = new Vector3(0, -15, 90);
|
||||
Debug.Log("[DiapasonPose] Applied Preset 2: Further from left hand, angled");
|
||||
}
|
||||
|
||||
private void ApplyPreset3()
|
||||
{
|
||||
_shoulderRotation = new Vector3(15, 0, -25);
|
||||
_elbowRotation = new Vector3(0, 15, 0);
|
||||
_wristRotation = new Vector3(0, 0, 85);
|
||||
Debug.Log("[DiapasonPose] Applied Preset 3: Natural grip, centered");
|
||||
}
|
||||
|
||||
private void ApplyRotations()
|
||||
{
|
||||
if (_equipment.ShoulderBone != null)
|
||||
{
|
||||
_equipment.ShoulderBone.localRotation = _equipment.OriginalShoulderRotation * Quaternion.Euler(_shoulderRotation);
|
||||
}
|
||||
|
||||
if (_equipment.ElbowBone != null)
|
||||
{
|
||||
_equipment.ElbowBone.localRotation = _equipment.OriginalElbowRotation * Quaternion.Euler(_elbowRotation);
|
||||
}
|
||||
|
||||
if (_equipment.WristBone != null)
|
||||
{
|
||||
_equipment.WristBone.localRotation = _equipment.OriginalWristRotation * Quaternion.Euler(_wristRotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetRotations()
|
||||
{
|
||||
if (_equipment.ShoulderBone != null)
|
||||
{
|
||||
_equipment.ShoulderBone.localRotation = _equipment.OriginalShoulderRotation;
|
||||
}
|
||||
|
||||
if (_equipment.ElbowBone != null)
|
||||
{
|
||||
_equipment.ElbowBone.localRotation = _equipment.OriginalElbowRotation;
|
||||
}
|
||||
|
||||
if (_equipment.WristBone != null)
|
||||
{
|
||||
_equipment.WristBone.localRotation = _equipment.OriginalWristRotation;
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
|
||||
GUILayout.BeginArea(new Rect(10, 150, 350, 250));
|
||||
GUILayout.Label("=== Diapason Pose Tweaker ===");
|
||||
|
||||
GUILayout.Label($"Shoulder: {_shoulderRotation}");
|
||||
GUILayout.Label($"Elbow: {_elbowRotation}");
|
||||
GUILayout.Label($"Wrist: {_wristRotation}");
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Tips:");
|
||||
GUILayout.Label("• Shoulder X: + = down, - = up");
|
||||
GUILayout.Label("• Shoulder Y: + = inward, - = outward");
|
||||
GUILayout.Label("• Shoulder Z: + = twist out, - = twist in");
|
||||
GUILayout.Label("• Elbow Y: + = bend out, - = bend in");
|
||||
GUILayout.Label("• Wrist Z: rotation du diapason");
|
||||
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d1a1f500877b404fa6d23dff3bfa8c8
|
||||
@@ -0,0 +1,54 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using UnityEngine;
|
||||
using Unheimlich.Features.Portals;
|
||||
|
||||
namespace Unheimlich.Dev
|
||||
{
|
||||
public class PortalAudioDebugger : MonoBehaviour
|
||||
{
|
||||
private Portal _portal;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_portal = GetComponent<Portal>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_portal != null)
|
||||
{
|
||||
_portal.RoomLoaded += OnRoomLoadedDebug;
|
||||
_portal.RoomUnloaded += OnRoomUnloadedDebug;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_portal != null)
|
||||
{
|
||||
_portal.RoomLoaded -= OnRoomLoadedDebug;
|
||||
_portal.RoomUnloaded -= OnRoomUnloadedDebug;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRoomLoadedDebug()
|
||||
{
|
||||
Debug.Log($"<color=green>[PortalDebug] RoomLoaded event fired on {gameObject.name}</color>");
|
||||
|
||||
if (_portal.LoadedRoomInstance != null)
|
||||
{
|
||||
AudioSource[] sources = _portal.LoadedRoomInstance.GetComponentsInChildren<AudioSource>();
|
||||
Debug.Log($"<color=green>[PortalDebug] Found {sources.Length} AudioSources in loaded room:</color>");
|
||||
|
||||
foreach (var source in sources)
|
||||
Debug.Log($" - {source.name} | Playing: {source.isPlaying} | Clip: {(source.clip != null ? source.clip.name : "NULL")}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRoomUnloadedDebug()
|
||||
{
|
||||
Debug.Log($"<color=red>[PortalDebug] RoomUnloaded event fired on {gameObject.name}</color>");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897784c22112f5f48af4313022397d8e
|
||||
Reference in New Issue
Block a user