37 lines
921 B
C#
37 lines
921 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ScaleController : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform[] _scale;
|
|
public TMP_InputField scaleInput;
|
|
|
|
private void Start()
|
|
{
|
|
if (_scale.Length > 0)
|
|
{
|
|
for (int i = 0; i < _scale.Length; i++)
|
|
scaleInput.SetTextWithoutNotify(_scale[i].localScale.x.ToString());
|
|
scaleInput.onEndEdit.AddListener(OnScaleInputChange);
|
|
}
|
|
}
|
|
|
|
public void OnScaleInputChange(string inputString)
|
|
{
|
|
if (_scale.Length > 0)
|
|
{
|
|
for (int i = 0; i < _scale.Length; i++)
|
|
{
|
|
if (float.TryParse(inputString, out float scale))
|
|
{
|
|
_scale[i].localScale = Vector3.one * scale;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|