20 lines
471 B
C#
20 lines
471 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class AutoResize : MonoBehaviour
|
|||
|
{
|
|||
|
public RectTransform parentRect; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RectTransform
|
|||
|
public Text taskText; // Text <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
//<2F><>ȡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ԥ<EFBFBD>ڸ߶<DAB8>
|
|||
|
float textHeight = taskText.preferredHeight;
|
|||
|
|
|||
|
//<2F><><EFBFBD>¸<EFBFBD><C2B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߶<C4B8>
|
|||
|
parentRect.sizeDelta = new Vector2(parentRect.sizeDelta.x, textHeight);
|
|||
|
}
|
|||
|
}
|