Refactor interaction prompt system to use world space prompts
- Removed the InteractPromptWidget from HUD and its references in HUDController. - Introduced IInteractPromptView interface for world space interaction prompts. - Implemented WorldInteractPrompt class to manage display of interaction prompts in world space. - Updated InteractableDetector to handle showing/hiding of world space prompts based on player proximity to interactable objects. - Created a new prefab for UI_WorldInteractPrompt to facilitate the new interaction prompt system.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
namespace BaseGames.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 交互提示事件负载。
|
||||
/// 由 InteractableDetector 广播,包含触发动作名称和显示文本,
|
||||
/// UI 层(InteractPromptWidget)据此查询图标并显示提示。
|
||||
/// </summary>
|
||||
public readonly struct InteractPromptEvent
|
||||
{
|
||||
/// <summary>InputSystem Action 名称,如 "Interact"。用于查询按键图标。</summary>
|
||||
public readonly string ActionName;
|
||||
|
||||
/// <summary>交互物提供的说明文本,如 "对话"、"存档"、"传送"。</summary>
|
||||
public readonly string LabelText;
|
||||
|
||||
public InteractPromptEvent(string actionName, string labelText)
|
||||
{
|
||||
ActionName = actionName;
|
||||
LabelText = labelText;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BaseGames.Core.Events
|
||||
{
|
||||
[CreateAssetMenu(menuName = "BaseGames/Events/InteractPrompt")]
|
||||
public class InteractPromptEventChannelSO : BaseEventChannelSO<InteractPromptEvent> { }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6db212f7619344588f054af0c6330a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/_Game/Scripts/Core/Interaction.meta
Normal file
8
Assets/_Game/Scripts/Core/Interaction.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af30250f65fc2f745a3b4089172739be
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/_Game/Scripts/Core/Interaction/IInteractPromptView.cs
Normal file
21
Assets/_Game/Scripts/Core/Interaction/IInteractPromptView.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace BaseGames.Core.Interaction
|
||||
{
|
||||
/// <summary>
|
||||
/// 世界空间交互提示视图接口。
|
||||
/// <para>
|
||||
/// 由可交互物上的子节点组件实现(如 <c>WorldInteractPrompt</c>),挂在世界空间里跟随物体显示。
|
||||
/// 玩家身上的交互探测器在「最近可交互物」变化时调用 <see cref="Show"/> / <see cref="Hide"/> 驱动其显隐。
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// 接口放在 Core 程序集,使「世界检测」(World)与「UI 表现」(UI)解耦,避免程序集互相引用。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public interface IInteractPromptView
|
||||
{
|
||||
/// <summary>显示提示。<paramref name="label"/> 为交互动作文字(来自 IInteractable.InteractPrompt)。</summary>
|
||||
void Show(string label);
|
||||
|
||||
/// <summary>隐藏提示。</summary>
|
||||
void Hide();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eccce8fdbd936b46a467d078957a387
|
||||
guid: 8559c1ac8ee8243459db9370032e789a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
Reference in New Issue
Block a user