Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active June 14, 2017 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/9258e88a09fdad3bbf4b47d67ec92391 to your computer and use it in GitHub Desktop.
Save tsubaki/9258e88a09fdad3bbf4b47d67ec92391 to your computer and use it in GitHub Desktop.
レイアウトの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