using System.Collections; using System.Collections.Generic; using UnityEngine; public class FitContentScript : MonoBehaviour { public int Padding; private bool workDone; public void OnRenderObject() { if (workDone) return; var child = transform.GetChild(0); if (child != null) { var childRect = child.GetComponent(); if (childRect != null) { transform.gameObject.GetComponent().sizeDelta = new Vector2( childRect.sizeDelta.x + 2 * Padding, childRect.sizeDelta.y + 2 * Padding); workDone = true; } } } }