Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
レイアウトのminをpreferredと同じ値にする
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class AsPreferred : MonoBehaviour, ILayoutElement
{
[SerializeField] int priority = 2;
[SerializeField, HideInInspector] Text text = null;
void Reset()
{
text = GetComponent<Text> ();
}
public void CalculateLayoutInputHorizontal (){ }
public void CalculateLayoutInputVertical () { }
public float minWidth {
get { return text.preferredWidth; }
}
public float preferredWidth {
get { return -1; }
}
public float flexibleWidth {
get { return -1; }
}
public float minHeight {
get { return text.preferredHeight; }
}
public float preferredHeight {
get { return -1; }
}
public float flexibleHeight {
get { return -1; }
}
public int layoutPriority {
get { return priority; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment