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


C# GUIStyle.CalcSize方法代码示例

本文整理汇总了C#中GUIStyle.CalcSize方法的典型用法代码示例。如果您正苦于以下问题:C# GUIStyle.CalcSize方法的具体用法?C# GUIStyle.CalcSize怎么用?C# GUIStyle.CalcSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GUIStyle的用法示例。


在下文中一共展示了GUIStyle.CalcSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GUIGridSizer

 private GUIGridSizer(GUIContent[] contents, int xCount, GUIStyle buttonStyle, GUILayoutOption[] options)
   : base(0.0f, 0.0f, 0.0f, 0.0f, GUIStyle.none)
 {
   this.m_Count = contents.Length;
   this.m_XCount = xCount;
   this.ApplyStyleSettings(buttonStyle);
   this.ApplyOptions(options);
   if (xCount == 0 || contents.Length == 0)
     return;
   float num1 = (float) (Mathf.Max(buttonStyle.margin.left, buttonStyle.margin.right) * (this.m_XCount - 1));
   float num2 = (float) (Mathf.Max(buttonStyle.margin.top, buttonStyle.margin.bottom) * (this.rows - 1));
   if ((double) buttonStyle.fixedWidth != 0.0)
     this.m_MinButtonWidth = this.m_MaxButtonWidth = buttonStyle.fixedWidth;
   if ((double) buttonStyle.fixedHeight != 0.0)
     this.m_MinButtonHeight = this.m_MaxButtonHeight = buttonStyle.fixedHeight;
   if ((double) this.m_MinButtonWidth == -1.0)
   {
     if ((double) this.minWidth != 0.0)
       this.m_MinButtonWidth = (this.minWidth - num1) / (float) this.m_XCount;
     if ((double) this.maxWidth != 0.0)
       this.m_MaxButtonWidth = (this.maxWidth - num1) / (float) this.m_XCount;
   }
   if ((double) this.m_MinButtonHeight == -1.0)
   {
     if ((double) this.minHeight != 0.0)
       this.m_MinButtonHeight = (this.minHeight - num2) / (float) this.rows;
     if ((double) this.maxHeight != 0.0)
       this.m_MaxButtonHeight = (this.maxHeight - num2) / (float) this.rows;
   }
   if ((double) this.m_MinButtonHeight == -1.0 || (double) this.m_MaxButtonHeight == -1.0 || ((double) this.m_MinButtonWidth == -1.0 || (double) this.m_MaxButtonWidth == -1.0))
   {
     float a1 = 0.0f;
     float a2 = 0.0f;
     foreach (GUIContent content in contents)
     {
       Vector2 vector2 = buttonStyle.CalcSize(content);
       a2 = Mathf.Max(a2, vector2.x);
       a1 = Mathf.Max(a1, vector2.y);
     }
     if ((double) this.m_MinButtonWidth == -1.0)
       this.m_MinButtonWidth = (double) this.m_MaxButtonWidth == -1.0 ? a2 : Mathf.Min(a2, this.m_MaxButtonWidth);
     if ((double) this.m_MaxButtonWidth == -1.0)
       this.m_MaxButtonWidth = (double) this.m_MinButtonWidth == -1.0 ? a2 : Mathf.Max(a2, this.m_MinButtonWidth);
     if ((double) this.m_MinButtonHeight == -1.0)
       this.m_MinButtonHeight = (double) this.m_MaxButtonHeight == -1.0 ? a1 : Mathf.Min(a1, this.m_MaxButtonHeight);
     if ((double) this.m_MaxButtonHeight == -1.0)
     {
       if ((double) this.m_MinButtonHeight != -1.0)
         this.maxHeight = Mathf.Max(this.maxHeight, this.m_MinButtonHeight);
       this.m_MaxButtonHeight = this.maxHeight;
     }
   }
   this.minWidth = this.m_MinButtonWidth * (float) this.m_XCount + num1;
   this.maxWidth = this.m_MaxButtonWidth * (float) this.m_XCount + num1;
   this.minHeight = this.m_MinButtonHeight * (float) this.rows + num2;
   this.maxHeight = this.m_MaxButtonHeight * (float) this.rows + num2;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:57,代码来源:GUIGridSizer.cs


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