mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 21:37:40 +02:00
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
This commit is contained in:
36
Assets/Scripts/Common/TextboxObject.cs
Normal file
36
Assets/Scripts/Common/TextboxObject.cs
Normal file
@ -0,0 +1,36 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user