// Make a vertical scrollbar. public static float VerticalScrollbar(float value, float size, float topValue, float bottomValue, GUIStyle style, params GUILayoutOption[] options) { return(GUI.VerticalScrollbar(GUILayoutUtility.GetRect(GUIContent.Temp("\n\n\n\n"), style, options), value, size, topValue, bottomValue, style)); }
void OnGUI() { if (null == mRipData) { return; } if (null == mStyles) { mStyles = new Styles(); } int vertexNum = (int)mRipData.vertexCount; float height = this.position.height - 20; float width = 40; int viewItemNum = Mathf.FloorToInt(height / 18 - 1); current = (int)GUI.VerticalScrollbar(new Rect(0, 0, 20, height + 3), current, viewItemNum, 0, vertexNum); int end = Mathf.Min(current + viewItemNum, vertexNum); int start = Mathf.Max(0, end - viewItemNum); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(20); //draw id EditorGUILayout.BeginVertical(mStyles.mPreviewBox, GUILayout.Width(width), GUILayout.Height(height)); { EditorGUILayout.BeginHorizontal(mStyles.mOLTitle); { EditorGUILayout.LabelField(" id", EditorStyles.boldLabel, GUILayout.Width(width)); } EditorGUILayout.EndHorizontal(); for (int i = start; i < end; ++i) { EditorGUILayout.LabelField(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(width)); } } EditorGUILayout.EndVertical(); GUILayout.Space(1); //data DataPanelScroll = EditorGUILayout.BeginScrollView(DataPanelScroll); EditorGUILayout.BeginHorizontal(); { for (int i = 0; i < mRipData.elements.Length; ++i) { RipAttributeElement ele = mRipData.elements[i]; width = ele.dimension * 100; EditorGUILayout.BeginVertical(mStyles.mPreviewBox, GUILayout.Width(width), GUILayout.Height(height)); { EditorGUILayout.BeginHorizontal(mStyles.mOLTitle); { ele.sematic = (ESemantic)EditorGUILayout.EnumPopup(ele.sematic, GUILayout.Width(width)); } EditorGUILayout.EndHorizontal(); for (int j = start; j < end; ++j) { EditorGUILayout.BeginHorizontal(); for (int k = 0; k < ele.dimension; ++k) { EditorGUILayout.LabelField(mRipData.vertexData[j * mRipData.dimensionPerVertex + k + ele.bytesOffset / 4].ToString(), GUILayout.Width(90)); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); } EditorGUILayout.BeginVertical(); { GUILayout.Label(mRipData.GetInfo()); mMdlscaler = EditorGUILayout.FloatField("Scale:", mMdlscaler); if (GUILayout.Button("确认导入")) { onMeshDataPrepared(ConvertRipToMeshData(mRipData)); this.Close(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }