rimworld-animation-studio/Assets/Scripts/GUI/DialogBoxes/DialogBox.cs

72 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class DialogBox : MonoBehaviour
{
public List<GameObject> cloneObjects;
public void OnEnable()
{
Initialize();
}
public void Pop()
{
gameObject.SetActive(gameObject.activeSelf == false);
}
public void RemoveCloneObjectsFromParent(Transform parent)
{
for (int i = 0; i < parent.childCount; i++)
{ Destroy(parent.transform.GetChild(i).gameObject); }
}
public GameObject AddCloneObjectToParent(Transform parent, int i = 0)
{
GameObject cloneObject = null;
if (cloneObjects != null && cloneObjects.Count > i)
{ cloneObject = Instantiate(cloneObjects[i], parent); }
return cloneObject;
}
public void AddCustomTag(InputField field, ref List<string> tags, ref List<string> customTags)
{
if (field?.text == null || field.text == "")
{ return; }
if (tags.Contains(field.text) || customTags.Contains(field.text))
{ field.text = ""; return; }
customTags.Add(field.text);
ApplicationManager.Instance.SaveCustomArrays();
Initialize(true);
}
public void AddCustomRace(InputField field)
{
if (field?.text == null || field.text == "")
{ return; }
AlienRaceDefs.AddDef(new AlienRaceDef(field.text));
ApplicationManager.Instance.SaveAlienRaceDefs();
Initialize(true);
}
public virtual void Initialize(bool addedNewTag = false) { }
}
}