public void Draw(Rect area) { GUILayout.BeginArea(area); DrawTitle(area.width - 15); GUIStyle s = new GUIStyle(); s.fixedHeight = _appearance.LineHeight * (m_lines.Count + 1); s.stretchWidth = true; GUILayout.BeginArea(new Rect(0, _appearance.LineHeight, area.width, area.height)); _scrollPos = GUILayout.BeginScrollView(_scrollPos, GUIStyle.none, GUI.skin.verticalScrollbar); //Debug.LogFormat("scroll pos: {0:0.00}, {1:0.00}", _scrollPos.x, _scrollPos.y); { Rect r = EditorGUILayout.BeginVertical(s); { // this silly line (empty label) is required by Unity to ensure the scroll bar appear as expected. PAEditorUtil.DrawLabel("", _appearance.Style_Line); // these first/last calculatings are for smart clipping int firstLine = Mathf.Max((int)(_scrollPos.y / _appearance.LineHeight) - 1, 0); int shownLineCount = (int)(area.height / _appearance.LineHeight) + 2; int lastLine = Mathf.Min(firstLine + shownLineCount, m_lines.Count); for (int i = firstLine; i < lastLine; i++) { DrawLine(i, m_lines[i], r.width); } } EditorGUILayout.EndVertical(); } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.EndArea(); }
public static FooItem MakeRandom() { return(new FooItem() { SeqID = (int)(Random.value * 100.0f), Name = "Foo " + PAEditorUtil.GetRandomString(), Count_A = (int)(Random.value * 100.0f), Time_A = (Random.value * 100.0f), Count_B = (int)(Random.value * 100.0f), Time_B = (Random.value * 100.0f), }); }
public GUIStyle GetTitleStyle(bool selected) { if (_styleTitle == null || _titleOrdinary == null || _titleSelected == null) { _styleTitle = new GUIStyle(EditorStyles.whiteBoldLabel); _styleTitle.alignment = TextAnchor.MiddleCenter; _titleOrdinary = PAEditorUtil.getColorTexture(PAEditorConst.TitleColor); _titleSelected = PAEditorUtil.getColorTexture(PAEditorConst.TitleColorSelected); } _styleTitle.normal.background = selected ? _titleSelected : _titleOrdinary; _styleTitle.normal.textColor = selected ? Color.yellow : Color.white; return(_styleTitle); }
public int Compare(object o1, object o2) { object fv1 = PAEditorUtil.FieldValue(o1, FieldInfo); object fv2 = PAEditorUtil.FieldValue(o2, FieldInfo); IComparable fc1 = fv1 as IComparable; IComparable fc2 = fv2 as IComparable; if (fc1 == null || fc2 == null) { return(fv1.ToString().CompareTo(fv2.ToString())); } return(fc1.CompareTo(fc2)); }
public string FormatObject(object obj) { return(PAEditorUtil.FieldToString(obj, FieldInfo, Format)); }
public string FormatObject(object obj) { return(PAEditorUtil.MemberToString(obj, MemInfo, Format)); }