Before this, I try to insert an image in a tooltip and it was already done. But right now, I want to try to insert a sound in the tooltip. What I want to do is when I point my cursor to the object it will display the image and also the sound at the same time.
My question:
Can sound insert in the tooltip?
Can I insert the code of sound in the same place as the image function?
-----TooltipManager Script--------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class TooltipManager: MonoBehaviour
{
public static TooltipManager _instance;
public Image imageComponent;
// public Sound soundComponent;
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(this.gameObject);
}
else
{
_instance = this;
}
}
// Start is called before the first frame update
void Start()
{
Cursor.visible = true;
gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
transform.position = Input.mousePosition;
}
public void SetAndShowToolTip(Sprite image)
{
gameObject.SetActive(true);
imageComponent.sprite = image;
}
public void HideToolTip()
{
gameObject.SetActive(false);
}
}
So can I insert the sound code inside the SetAndShowToolTip? or do I need to create a new function?