basic setup of a character sheet - needs some more work

Wiring up character interviewed
Added property for bulletized text - ready to add when we have some
This commit is contained in:
Amaan Shawkath
2023-07-08 17:08:45 +01:00
parent 92fd23b6f0
commit be5e2556c6
6 changed files with 490 additions and 4 deletions

View File

@@ -0,0 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class CharacterSheetController : MonoBehaviour
{
[SerializeField] private TMP_Text m_characterNameText;
[SerializeField] private TMP_Text m_line;
[SerializeField] private Transform m_lineHolder;
private Dictionary<string, GameObject> m_lines = new Dictionary<string, GameObject>();
public void Cleanup()
{
foreach(var line in m_lines)
{
Destroy(line.Value);
}
m_lines.Clear();
}
public void SetName(string name)
{
m_characterNameText.text = name;
}
// Adds a line to the character sheet.
public void AddLine(string lineText)
{
if (LineExists(lineText))
return;
var line = Instantiate(m_line, m_lineHolder);
line.text = lineText;
line.gameObject.SetActive(true);
m_lines.Add(lineText, line.gameObject);
}
// Returns if the line has already been added.
private bool LineExists(string lineText)
{
return m_lines.ContainsKey(lineText);
}
}