本文整理匯總了C#中UnityEngine.Rect.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Rect.Equals方法的具體用法?C# Rect.Equals怎麽用?C# Rect.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UnityEngine.Rect
的用法示例。
在下文中一共展示了Rect.Equals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnGui
public void OnGui(float startX, float startY, float width, float rowHeight, float minColorWidth)
{
// Precalculate
float colf = Mathf.Floor(width / minColorWidth);
int columns = Mathf.Min(Count,(int)(Mathf.Floor(width / minColorWidth))); // over x
int rows = (int)(Mathf.Ceil((float)Count / columns)); // over y
float height = rowHeight * rows;
float colorWidth = width/columns;
//// Get StartPos
Rect rec = new Rect(startX, startY, width, height);
GUILayoutUtility.BeginGroup("test");
if(!rec.Equals(curRec))
{
// Set rects
posRec = new Rect[Count];
for (int i = 0; i < Count; i++)
{
float x = startX + colorWidth * (i % columns);
float y = startY + (rowHeight + 2)* ((i) / columns);
posRec[i] = new Rect(x, y, colorWidth, rowHeight);
}
curRec = rec;
}
// Draw the Color Field
for (int i = 0; i < Count; i++)
{
//Replace with: EditorGUIUtility.DrawColorSwatch(posRec[i], colors[i]); ??
colors[i] = EditorGUI.ColorField(posRec[i], colors[i]);
}
GUILayoutUtility.EndGroup("test");
}