Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 483635457687552
m_Key: Input_Controls_Hold
m_Key: Camera_Control_Reverse
m_Metadata:
m_Items: []
- m_Id: 485408155107328
Expand Down Expand Up @@ -213,6 +213,10 @@ MonoBehaviour:
m_Key: Sprint_Controls
m_Metadata:
m_Items: []
- m_Id: 6465602920128512
m_Key: Input_Controls_Hold
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 483635457687552
m_Localized: Hold
m_Localized: Reverse
m_Metadata:
m_Items: []
- m_Id: 485408155107328
Expand Down Expand Up @@ -214,6 +214,10 @@ MonoBehaviour:
m_Localized: Sprint Controls
m_Metadata:
m_Items: []
- m_Id: 6465602920128512
m_Localized: Hold
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 483635457687552
m_Localized: "\u30DB\u30FC\u30EB\u30C9"
m_Localized: "\u30EA\u30D0\u30FC\u30B9"
m_Metadata:
m_Items: []
- m_Id: 485408155107328
Expand Down Expand Up @@ -214,6 +214,10 @@ MonoBehaviour:
m_Localized: "\u30B9\u30D7\u30EA\u30F3\u30C8\u64CD\u4F5C"
m_Metadata:
m_Items: []
- m_Id: 6465602920128512
m_Localized: "\u30DB\u30FC\u30EB\u30C9"
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,19 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 76672933973
m_Localized: Left Shoulder
m_Localized: LB
m_Metadata:
m_Items: []
- m_Id: 76672933974
m_Localized: Right Shoulder
m_Localized: RB
m_Metadata:
m_Items: []
- m_Id: 76672933975
m_Localized: Left Trigger
m_Localized: LT
m_Metadata:
m_Items: []
- m_Id: 76672933976
m_Localized: Right Trigger
m_Localized: RT
m_Metadata:
m_Items: []
- m_Id: 76672933977
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 76672933973
m_Localized: "L\u30DC\u30BF\u30F3"
m_Localized: LB
m_Metadata:
m_Items: []
- m_Id: 76672933974
m_Localized: "R\u30DC\u30BF\u30F3"
m_Localized: RB
m_Metadata:
m_Items: []
- m_Id: 76672933975
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Game.Shared.Constants;
using Game.Shared.Enums;
using Game.Shared.Extensions;
using Game.Shared.Input;
using Game.Shared.Localization;
using R3;
using UnityEngine;
using UnityEngine.InputSystem;
Expand Down Expand Up @@ -207,26 +209,18 @@ public override UniTask Startup()
})
.AddTo(Disposables);

LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged;
Disposables.Add(Disposable.Create(() => LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged));
LocalizationEvents.OnLocaleChanged
.Subscribe(_ => RefreshBindingDisplays())
.AddTo(Disposables);

// コントローラー接続/切替に追従して family 別表示を更新する
InputSystem.onDeviceChange += OnDeviceChanged;
Disposables.Add(Disposable.Create(() => InputSystem.onDeviceChange -= OnDeviceChanged));
InputSystemEvents.OnDeviceChanged
.Subscribe(_ => RefreshBindingDisplays())
.AddTo(Disposables);

return base.Startup();
}

private void OnLocaleChanged(Locale locale)
{
RefreshBindingDisplays();
}

private void OnDeviceChanged(InputDevice device, InputDeviceChange change)
{
RefreshBindingDisplays();
}

private void RefreshBindingDisplays()
{
// ロケール変更でバインド表示名を再ローカライズ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Game.Shared.Bootstrap;
using Game.Shared.Extensions;
using Game.Shared.Input;
using Game.Shared.Interaction;
using R3;
using UnityEngine;

Expand Down Expand Up @@ -36,6 +37,10 @@ public class HorrorPlayerController : MonoBehaviour
[Header("回転速度(度/秒)")]
[SerializeField] private float _lookRotationSpeed = 0.1f;

[Header("インタラクション")]
[Tooltip("インタラクト対象を検出する検出器(同一 Prefab 上にアタッチ)")]
[SerializeField] private InteractionDetector _interactionDetector;

private InputSystemService _inputService;
private InputSystemService InputService => _inputService ??= GameServiceManager.Get<InputSystemService>();

Expand Down Expand Up @@ -131,6 +136,17 @@ public void Initialize(HorrorOptionSaveData data)
)
.Subscribe(_ => ApplicationEvents.HideCursor())
.AddTo(this);

// インタラクト実行:現在のターゲットがあればその効果を発火する
Player.Interact.OnPerformedAsObservable()
.Subscribe(_ =>
{
if (_interactionDetector != null && _interactionDetector.TryGetActionable(out var interactable))
{
interactable.Interact();
}
})
.AddTo(this);
}

public void ApplyOptions(HorrorOptionSaveData data)
Expand All @@ -143,7 +159,7 @@ public void ApplyOptions(HorrorOptionSaveData data)

_lookAcceleration = data.CameraAcceleration;
_cameraShake = data.CameraShake;
_mainCamera.fieldOfView = data.CameraFov;
if (_mainCamera != null) _mainCamera.fieldOfView = data.CameraFov;

// OnSaved でランタイム再適用される。カメラ基準位置は触らない(しゃがみ中のリセット防止)
_sprintToggle = data.SprintToggle;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using R3;
using UnityEngine.InputSystem;

namespace Game.Shared.Input
{
public static class InputSystemEvents
{
public static Observable<(InputDevice device, InputDeviceChange deviceChange)> OnDeviceChanged
=> Observable.FromEvent<Action<InputDevice, InputDeviceChange>, (InputDevice, InputDeviceChange)>(
h => (a, b) => h((a, b)),
h => InputSystem.onDeviceChange += h,
h => InputSystem.onDeviceChange -= h);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using UnityEngine;

namespace Game.Shared.Interaction
{
/// <summary>
/// インタラクト時に Debug.Log を出すだけの最小 <see cref="IInteractable"/> 実装(検証・サンプル用)。
/// <see cref="InteractionDetector"/> の OverlapSphere に検出されるため Collider が必要。
/// 視覚表現はアウトライン(<see cref="InteractionOutlineHighlighter"/>)と
/// 対象側プロンプト(<see cref="InteractionPromptView"/>)へ委譲する。
/// </summary>
public class DebugInteractable : MonoBehaviour, IInteractable
{
[Tooltip("ログに出す識別ラベル")]
[SerializeField] private string _label = "Object";

[Tooltip("中心位置の上書き。未指定なら自身の transform.position を使う")]
[SerializeField] private Transform _centerOverride;

[Tooltip("アウトライン表現を担うコンポーネント")]
[SerializeField] private InteractionOutlineHighlighter _highlighter;

[Tooltip("対象位置に出すプロンプト表示")]
[SerializeField] private InteractionPromptView _promptView;

public Vector3 CenterPosition =>
_centerOverride != null ? _centerOverride.position : transform.position;

public void Interact()
{
Debug.Log($"[Interact] {_label}");
}

public void SetInteractionState(InteractionState state, Camera viewCamera)
{
// アウトラインは実行可能時のみ点灯(「可能」を強調。発見可能はプロンプトのみで差別化する)
if (_highlighter != null)
_highlighter.SetHighlighted(state == InteractionState.Actionable);

if (_promptView != null)
_promptView.SetState(state, viewCamera);
}

// 無効化・破棄時に提示を確実に消す(検出器の Hidden 通知が届かないケースの保険)
private void OnDisable()
{
if (_promptView != null)
_promptView.SetState(InteractionState.Hidden, null);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using UnityEngine;

namespace Game.Shared.Interaction
{
/// <summary>
/// インタラクト可能なオブジェクトのインターフェース。
/// 検出基準点(<see cref="CenterPosition"/>)・実行(<see cref="Interact"/>)・
/// 提示状態の反映(<see cref="SetInteractionState"/>)を提供する。
/// </summary>
public interface IInteractable
{
/// <summary>
/// 検出の基準となる中心位置。プレイヤーからの距離計算と可視判定(視線の的)に使用する。
/// </summary>
Vector3 CenterPosition { get; }

/// <summary>
/// インタラクトアクション実行時の効果。
/// </summary>
void Interact();

/// <summary>
/// 提示状態を反映する。対象側がアウトラインやプロンプト表示を切り替える。
/// <paramref name="viewCamera"/> は対象側プロンプトがビルボードで正対するための視点カメラ
/// (検出器が保持する唯一の視点。<see cref="InteractionState.Hidden"/> 時は未使用で null 可)。
/// </summary>
void SetInteractionState(InteractionState state, Camera viewCamera);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading