HeavenStudio/Assets/Scripts/Common/TextboxObject.cs
minenice55 12fb8c2117
Feature: Textboxes and other text-related features (#90)
* Textboxes: setup prefab

* Textboxes: basic functionality finished

* Textbox: scaling

* Textbox: open captions

* Textbox: res edits

* Textbox: song artist

* Textbox: closed captions

* Textbox: fix not being able to use multiple text events

* I/O: save / load remixes using UTF-8 encoding

* Textboxes: stop editor shortcuts while typing
2022-06-03 20:15:05 -07:00

36 lines
974 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace HeavenStudio.TextboxUtilities
{
public class TextboxObject : MonoBehaviour
{
[Header("Objects")]
public TMP_Text TextboxLabel;
public RectTransform TextboxLabelRect;
public SpriteRenderer UL;
public SpriteRenderer UR;
public SpriteRenderer DL;
public SpriteRenderer DR;
static Vector2 textboxSize = new Vector2(3f, 0.75f);
public void Resize(float scaleX, float scaleY)
{
Vector2 tScale = Vector2.Scale(textboxSize, new Vector2(scaleX, scaleY));
UL.size = tScale;
UR.size = tScale;
DL.size = tScale;
DR.size = tScale;
TextboxLabelRect.sizeDelta = new Vector2(11.2f * scaleX, 2.2f * scaleY);
}
public void SetText(string text)
{
TextboxLabel.text = text;
}
}
}