Last active
June 14, 2017 16:44
-
-
Save tsubaki/9258e88a09fdad3bbf4b47d67ec92391 to your computer and use it in GitHub Desktop.
レイアウトのminをpreferredと同じ値にする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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