Added highlight proxy

This commit is contained in:
Jeonghyeon Ha 2025-08-29 12:16:37 +09:00
parent 517a7ec1f4
commit 0bdacf1e19

View File

@ -62,10 +62,11 @@ public class InteractableHighlight : MonoBehaviour
private float _opacityMultiply = 1.0f; private float _opacityMultiply = 1.0f;
private float _breathingTime; private float _breathingTime;
private HighlightEffect _highlightComponent; private HighlightEffect _highlightComponent;
private HighlightEffect _highlightProxy;
private RestaurantInteractionComponent _interactionComponent; private RestaurantInteractionComponent _interactionComponent;
private IInteractor _interactor; private IInteractor _interactor;
private InteractionOutlineType _lastAppliedType = InteractionOutlineType.None; private InteractionOutlineType _lastAppliedType = InteractionOutlineType.None;
`
private void Awake() private void Awake()
{ {
// OutlineData 딕셔너리 초기화 // OutlineData 딕셔너리 초기화
@ -76,7 +77,23 @@ private void Awake()
_interactionComponent = GetComponent<RestaurantInteractionComponent>(); _interactionComponent = GetComponent<RestaurantInteractionComponent>();
// HighlightEffect 설정 적용 // HighlightEffect 설정 적용
ApplyHighlightSettings(); ApplyHighlightSettings(_highlightComponent);
}
private HighlightEffect GetHighlightComponent()
{
return _highlightProxy? _highlightProxy : _highlightComponent;
}
public void RegisterHighlightProxy(HighlightEffect highlightProxy)
{
_highlightProxy = highlightProxy;
ApplyHighlightSettings(highlightProxy);
}
public void UnregisterHighlightProxy()
{
_highlightProxy = null;
} }
private void InitializeOutlineData() private void InitializeOutlineData()
@ -91,17 +108,17 @@ private void InitializeOutlineData()
}; };
} }
private void ApplyHighlightSettings() private void ApplyHighlightSettings(HighlightEffect highlightComponent)
{ {
if (!_highlightComponent) return; if (!highlightComponent) return;
_highlightComponent.alphaCutOff = _alphaCutOff; highlightComponent.alphaCutOff = _alphaCutOff;
_highlightComponent.combineMeshes = _combineMeshes; highlightComponent.combineMeshes = _combineMeshes;
_highlightComponent.constantWidth = _constantWidth; highlightComponent.constantWidth = _constantWidth;
_highlightComponent.outlineQuality = _outlineQuality; highlightComponent.outlineQuality = _outlineQuality;
_highlightComponent.outlineIndependent = _outlineIndependent; highlightComponent.outlineIndependent = _outlineIndependent;
_highlightComponent.outlineBlurPasses = _outlineBlurPasses; highlightComponent.outlineBlurPasses = _outlineBlurPasses;
_highlightComponent.outlineSharpness = _outlineSharpness; highlightComponent.outlineSharpness = _outlineSharpness;
} }
private void Update() private void Update()
@ -200,7 +217,8 @@ private void ApplyOutlineType(InteractionOutlineType type)
_lastAppliedType = type; _lastAppliedType = type;
if (!_highlightComponent) var highlightComponent = GetHighlightComponent();
if (!highlightComponent)
return; return;
// OutlineData에서 해당 타입의 스타일 가져오기 // OutlineData에서 해당 타입의 스타일 가져오기
@ -213,18 +231,18 @@ private void ApplyOutlineType(InteractionOutlineType type)
// HighlightEffect에 적용 // HighlightEffect에 적용
if (type == InteractionOutlineType.None) if (type == InteractionOutlineType.None)
{ {
_highlightComponent.highlighted = false; highlightComponent.highlighted = false;
_highlightComponent.outline = 0; highlightComponent.outline = 0;
} }
else else
{ {
_highlightComponent.highlighted = true; highlightComponent.highlighted = true;
Color color = data.Color; Color color = data.Color;
// color.a = data.Opacity * _opacityMultiply; // color.a = data.Opacity * _opacityMultiply;
color *= _opacityMultiply; color *= _opacityMultiply;
_highlightComponent.outlineColor = color; highlightComponent.outlineColor = color;
_highlightComponent.outlineWidth = data.Width; highlightComponent.outlineWidth = data.Width;
_highlightComponent.outline = 1; highlightComponent.outline = 1;
} }
} }
@ -257,7 +275,7 @@ private void RefreshOutlineData()
[Button("Apply Highlight Settings")] [Button("Apply Highlight Settings")]
private void ApplyHighlightSettingsButton() private void ApplyHighlightSettingsButton()
{ {
ApplyHighlightSettings(); ApplyHighlightSettings(_highlightComponent);
} }
} }
} }