rabidus-test/Assets/MonumentPreviewController.cs

48 lines
1.1 KiB
C#
Raw Normal View History

2023-10-02 19:12:35 +03:00
using BNG;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonumentPreviewController : MonoBehaviour
{
private Grabbable _grabbable;
private MonumentMini _monumentMini;
private MonumentPreview _monumentPreview;
2023-10-23 11:19:20 +03:00
private MonumentPreviewSound _previewSound;
2023-10-02 19:12:35 +03:00
private void Awake()
{
2023-10-23 11:19:20 +03:00
_previewSound = FindObjectOfType<MonumentPreviewSound>();
2023-10-02 19:12:35 +03:00
_grabbable = GetComponent<Grabbable>();
_monumentMini = GetComponent<MonumentMini>();
2023-10-17 17:18:34 +03:00
_monumentPreview = GetComponent<MonumentPreview>();
2023-10-02 19:12:35 +03:00
}
private void OnEnable()
{
_grabbable.OnUniqueGrabbed.AddListener(OnGrab);
}
private void OnDisable()
{
_grabbable.OnUniqueGrabbed.RemoveListener(OnGrab);
}
private void OnGrab(Grabber arg)
{
2023-10-24 14:34:33 +03:00
_monumentPreview.ShowInfo(_monumentMini.Info.Name, _monumentMini.Info.Image, _monumentMini.Info.Description);
2023-10-23 11:19:20 +03:00
_previewSound.PlaySound(_monumentMini.Info.ShortClip);
2023-10-02 19:12:35 +03:00
}
#if UNITY_EDITOR
[ContextMenu("Debug show preview")]
private void DebugShow()
{
OnGrab(null);
}
#endif
}