iiDkRemastered/gorillacaptions
Ownership not verified 0Apache-2.0
Viewing main at commit 18e583edbd“Add files via upload”· 2 months ago
48 lines · 1.5 KBRaw on GitHub
using GorillaCaptions.Classes;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
namespace GorillaCaptions.Managers
{
public class BubbleManager : MonoBehaviour
{
public static BubbleManager instance { get; private set; }
private GameObject BubbleAsset;
public void Awake()
{
instance = this;
BubbleAsset = AssetManager.LoadAsset<GameObject>("SpeechBubble");
}
private Dictionary<VRRig, GameObject> SpeechBubbles = new Dictionary<VRRig, GameObject> { };
public void SpawnBubble(VRRig Rig, string Text)
{
if (SpeechBubbles.TryGetValue(Rig, out GameObject ExistingBubble))
DestroyBubble(ExistingBubble);
GameObject TargetBubble = Instantiate(BubbleAsset);
TargetBubble.transform.SetParent(Rig.headMesh.transform, false);
TargetBubble.transform.Find("Canvas/Background/Text")
.GetComponent<TextMeshProUGUI>().text = Text;
TargetBubble.AddComponent<SpeechBubble>().Owner = Rig;
SpeechBubbles.Add(Rig, TargetBubble);
}
public void DestroyBubble(GameObject TargetBubble)
{
foreach (KeyValuePair<VRRig, GameObject> SpeechBubble in SpeechBubbles)
{
if (SpeechBubble.Value == TargetBubble)
{
SpeechBubbles.Remove(SpeechBubble.Key);
Destroy(SpeechBubble.Value);
break;
}
}
}
}
}
Code is shown from GitHub as-is. Linking a repository doesn’t prove that a release file on Canopy was built from it.