feat: MCP Unity 场景优化 — 完整交互体系搭建
- 删除重复 Ground - 创建 [Managers] 空物体,挂载 GameManager + StepManager + ExperimentFlowCoordinator + AudioManager - Main Camera 挂载 InteractionSystem - 伤者 InjectedPerson 下创建 5 个交互子物体 (InjuryVisual/Swelling/Pain/VitalSigns/Neuro) - 创建绑带位置、踝关节、衬垫、夹板位置等空物体 - 道具摆放到位:伤者(2,0.05,5) 施救者(3,0,5) 鞋(2.7,0.15,5.5) 绷带/夹板/急救箱在旁 - InjuryLeg Tag 修正,Ground Tag 修正 - 全部新脚本同步导入 (ExperimentTypes/StepData/ExperimentConfig/StepManager/GameManager/ExperimentFlowCoordinator/InteractionSystem/DraggableObject/HighlightEffect/UIManager/ExamPopup/ScoreDisplay/VideoController/AudioManager/CharacterAnimController/StepAnimationHandler) - 旧脚本 (ExperimentController/ConfigLoader/AnimationController/HUDController/VideoPlayerController/PopupSystem/ModeSelectionUI) 全部兼容修复或 stub - 编译通过,0 错误 - Canvas 挂载 UIManager
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物体高亮效果:鼠标悬停时切换 Emission 或轮廓材质。
|
||||
/// 挂在可交互的 3D 物体上。
|
||||
/// </summary>
|
||||
public class HighlightEffect : MonoBehaviour
|
||||
{
|
||||
[Header("高亮设置")]
|
||||
[SerializeField] private Color _highlightColor = Color.yellow;
|
||||
[SerializeField] private float _highlightIntensity = 0.5f;
|
||||
|
||||
[Header("可选 - 使用 Outline 组件")]
|
||||
[SerializeField] private bool _useOutline = true;
|
||||
[SerializeField] private float _outlineWidth = 0.02f;
|
||||
|
||||
private Renderer[] _renderers;
|
||||
private Material[] _originalMaterials;
|
||||
private Material[] _highlightMaterials;
|
||||
private bool _isHighlighted;
|
||||
|
||||
[Header("考核高亮 - 始终显示")]
|
||||
public bool AlwaysHighlighted;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_renderers = GetComponentsInChildren<Renderer>();
|
||||
}
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
if (_isHighlighted) return;
|
||||
SetHighlight(true);
|
||||
}
|
||||
|
||||
private void OnMouseExit()
|
||||
{
|
||||
if (AlwaysHighlighted) return;
|
||||
SetHighlight(false);
|
||||
}
|
||||
|
||||
public void SetHighlight(bool on)
|
||||
{
|
||||
_isHighlighted = on;
|
||||
if (_renderers == null) return;
|
||||
|
||||
foreach (var r in _renderers)
|
||||
{
|
||||
if (r == null) continue;
|
||||
foreach (var mat in r.materials)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
mat.EnableKeyword("_EMISSION");
|
||||
mat.SetColor("_EmissionColor", _highlightColor * _highlightIntensity);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.DisableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>闪烁效果,用于提示用户点击</summary>
|
||||
public void Flash(float duration = 0.5f)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(FlashRoutine(duration));
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator FlashRoutine(float duration)
|
||||
{
|
||||
float half = duration / 2f;
|
||||
SetHighlight(true);
|
||||
yield return new WaitForSeconds(half);
|
||||
SetHighlight(false);
|
||||
yield return new WaitForSeconds(half);
|
||||
SetHighlight(true);
|
||||
yield return new WaitForSeconds(half);
|
||||
SetHighlight(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user