当前位置: 首页>>代码示例>>C#>>正文


C# RectTransform.GetComponents方法代码示例

本文整理汇总了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;
        }
开发者ID:aammfe,项目名称:unity3d-ui,代码行数:45,代码来源:LayoutUtility.cs

示例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;
 }
开发者ID:NetherDrk,项目名称:Eternal-Empire,代码行数:38,代码来源:LayoutUtility.cs

示例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;
 }
开发者ID:NetherDrk,项目名称:Eternal-Empire,代码行数:8,代码来源:LayoutRebuilder.cs

示例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;
 }
开发者ID:NetherDrk,项目名称:Eternal-Empire,代码行数:8,代码来源:LayoutRebuilder.cs

示例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);
 }
开发者ID:NetherDrk,项目名称:Eternal-Empire,代码行数:16,代码来源:LayoutRebuilder.cs


注:本文中的UnityEngine.RectTransform.GetComponents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。