using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class MateriPenyakitGigi : Menu { [SerializeField] protected TextMeshProUGUI nameText; [SerializeField] protected TextMeshProUGUI descriptionText; [SerializeField] protected Image previewImage; protected MateriSelector MateriSelector; protected MateriSpec currentMateri; int indexBgm = 0; protected override void Awake() { base.Awake(); MateriSelector = GetComponent(); UpdateInfo(); } private void OnEnable() { UpdateInfo(); indexBgm++; if (indexBgm > 1) { PlayInitDubbing(); } } private void OnDisable() { audioController.Instance.StopDubbing(); } public void UpdateInfo() { currentMateri = MateriSelector.GetCurrentMission(); if(currentMateri != null ) { nameText.text = currentMateri.Name; descriptionText.text = currentMateri.Description; previewImage.sprite = currentMateri.Image; } } public void OnNextPressed() { audioController.Instance.PlaySFX("TombolUmum", 0.5f); MateriSelector.IncrementIndex(); UpdateInfo(); PlayNextDubbing(); } public void OnPreviousPressed() { audioController.Instance.PlaySFX("TombolUmum", 0.5f); MateriSelector.DecrementIndex(); UpdateInfo(); PlayPreviousDubbing(); } public void PlayInitDubbing() { currentMateri = MateriSelector.GetCurrentMission(); if(currentMateri != null ) { audioController.Instance.StopDubbing(); audioController.Instance.PlayDubbing(currentMateri.DubbingName); } } public void PlayNextDubbing() { MateriSpec materiDub = MateriSelector.GetNextMissionDubbing(); if (materiDub != null) { audioController.Instance.StopDubbing(); audioController.Instance.PlayDubbing(materiDub.DubbingName); } } public void PlayPreviousDubbing() { MateriSpec materiDub = MateriSelector.GetPreviousMissionDubbing(); if (materiDub != null) { audioController.Instance.StopDubbing(); audioController.Instance.PlayDubbing(materiDub.DubbingName); } } public override void OnBackPressed() { base.OnBackPressed(); audioController.Instance.StopDubbing(); } }