本文整理汇总了C#中UnityEngine.RectTransform.GetComponents方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.GetComponents方法的具体用法?C# RectTransform.GetComponents怎么用?C# RectTransform.GetComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.RectTransform
的用法示例。
在下文中一共展示了RectTransform.GetComponents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLayoutProperty
public static float GetLayoutProperty(RectTransform rect, System.Func<ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
{
source = null;
if (rect == null)
return 0;
float min = defaultValue;
int maxPriority = System.Int32.MinValue;
var components = ComponentListPool.Get();
rect.GetComponents(typeof(ILayoutElement), components);
for (int i = 0; i < components.Count; i++)
{
var layoutComp = components[i] as ILayoutElement;
if (layoutComp is Behaviour && !(layoutComp as Behaviour).enabled)
continue;
int priority = layoutComp.layoutPriority;
// If this layout components has lower priority than a previously used, ignore it.
if (priority < maxPriority)
continue;
float prop = property(layoutComp);
// If this layout property is set to a negative value, it means it should be ignored.
if (prop < 0)
continue;
// If this layout component has higher priority than all previous ones,
// overwrite with this one's value.
if (priority > maxPriority)
{
min = prop;
maxPriority = priority;
source = layoutComp;
}
// If the layout component has the same priority as a previously used,
// use the largest of the values with the same priority.
else if (prop > min)
{
min = prop;
source = layoutComp;
}
}
ComponentListPool.Release(components);
return min;
}
示例2: GetLayoutProperty
public static float GetLayoutProperty(RectTransform rect, Func<ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
{
source = (ILayoutElement) null;
if ((UnityEngine.Object) rect == (UnityEngine.Object) null)
return 0.0f;
float num1 = defaultValue;
int num2 = int.MinValue;
List<Component> list = ListPool<Component>.Get();
rect.GetComponents(typeof (ILayoutElement), list);
for (int index = 0; index < list.Count; ++index)
{
ILayoutElement layoutElement = list[index] as ILayoutElement;
if (!(layoutElement is Behaviour) || ((Behaviour) layoutElement).isActiveAndEnabled)
{
int layoutPriority = layoutElement.layoutPriority;
if (layoutPriority >= num2)
{
float num3 = property(layoutElement);
if ((double) num3 >= 0.0)
{
if (layoutPriority > num2)
{
num1 = num3;
num2 = layoutPriority;
source = layoutElement;
}
else if ((double) num3 > (double) num1)
{
num1 = num3;
source = layoutElement;
}
}
}
}
}
ListPool<Component>.Release(list);
return num1;
}
示例3: ValidLayoutGroup
private static bool ValidLayoutGroup(RectTransform parent, List<Component> comps)
{
if ((UnityEngine.Object) parent == (UnityEngine.Object) null)
return false;
parent.GetComponents(typeof (ILayoutGroup), comps);
LayoutRebuilder.StripDisabledBehavioursFromList(comps);
return comps.Count > 0;
}
示例4: ValidController
private static bool ValidController(RectTransform layoutRoot, List<Component> comps)
{
if ((UnityEngine.Object) layoutRoot == (UnityEngine.Object) null)
return false;
layoutRoot.GetComponents(typeof (ILayoutController), comps);
LayoutRebuilder.StripDisabledBehavioursFromList(comps);
return comps.Count > 0;
}
示例5: PerformLayoutCalculation
private void PerformLayoutCalculation(RectTransform rect, UnityAction<Component> action)
{
if ((UnityEngine.Object) rect == (UnityEngine.Object) null)
return;
List<Component> list = ListPool<Component>.Get();
rect.GetComponents(typeof (ILayoutElement), list);
LayoutRebuilder.StripDisabledBehavioursFromList(list);
if (list.Count > 0)
{
for (int index = 0; index < rect.childCount; ++index)
this.PerformLayoutCalculation(rect.GetChild(index) as RectTransform, action);
for (int index = 0; index < list.Count; ++index)
action(list[index]);
}
ListPool<Component>.Release(list);
}