43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class GetScale : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform cube;
|
|
private Vector3 cube_Scale;
|
|
[SerializeField] private Transform picturre;
|
|
|
|
[SerializeField] private TMP_Text Log;
|
|
|
|
[SerializeField] private TMP_InputField sclae_InputField;
|
|
|
|
[SerializeField] private TMP_InputField offset_InputField;
|
|
|
|
void Start()
|
|
{
|
|
cube_Scale = cube.localScale;
|
|
sclae_InputField.onEndEdit.AddListener(OnInputFieldChange);
|
|
offset_InputField.onEndEdit.AddListener(OnOffsetInputFieldChange);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
Log.text = "cube: " + cube.lossyScale;
|
|
Log.text += "\npicture: " + picturre.lossyScale;
|
|
}
|
|
|
|
public void OnInputFieldChange(string text)
|
|
{
|
|
float scale = float.Parse(text);
|
|
cube.localScale = new Vector3(scale * cube_Scale.x, scale * cube_Scale.y, scale * cube_Scale.z);
|
|
}
|
|
|
|
public void OnOffsetInputFieldChange(string text)
|
|
{
|
|
float offset = float.Parse(text);
|
|
cube.localPosition = new Vector3(offset, 0, 0);
|
|
}
|
|
}
|