private void DrawBodyContent() { var height = this.position.height - 3 * EditorGUIUtility.singleLineHeight; var width = this.position.width - 1 * EditorGUIUtility.singleLineHeight; using (var hor = new EditorGUILayout.HorizontalScope(GUILayout.Width(width), GUILayout.Height(height))) { using (var ver = new EditorGUILayout.VerticalScope(GUILayout.Width(width * 0.3f), GUILayout.Height(height))) { WidgetUtility.DrawContentColor(ver.rect, Color.green); using (var scroll = new EditorGUILayout.ScrollViewScope(scroll_left, false, true)) { scroll_left = scroll.scrollPosition; DrawWidghtsOptions(width * 0.3f); } } using (var ver = new EditorGUILayout.VerticalScope(GUILayout.Width(width * 0.7f), GUILayout.Height(height))) { WidgetUtility.DrawContentColor(ver.rect, Color.green); DrawScrollViewObjs(width * 0.7f, height * 0.9f); using (var hor0 = new EditorGUILayout.HorizontalScope(GUILayout.Width(width * 0.7f), GUILayout.Height(height * 0.1f))) { WidgetUtility.DrawContentColor(hor0.rect, Color.green); DrawToolButtons(); } } } }
private void DrawHeader() { using (var ver = new EditorGUILayout.VerticalScope(GUILayout.Height(3 * EditorGUIUtility.singleLineHeight))) { WidgetUtility.DrawContentColor(ver.rect, Color.yellow); EditorGUILayout.PropertyField(scriptProp); GUILayout.Space(5); using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("自定义加载路径:", GUILayout.Width(100)); if (GUILayout.Button(userPath, EditorStyles.label)) { var folder = AssetDatabase.LoadAssetAtPath <DefaultAsset>(userPath); Selection.activeObject = folder; } if (GUILayout.Button("选择", EditorStyles.miniButtonRight, GUILayout.Width(40))) { if (Selection.activeObject != null && ProjectWindowUtil.IsFolder(Selection.activeInstanceID)) { var path = AssetDatabase.GetAssetPath(Selection.activeInstanceID); userPath = path; currobjhs = null; UpdateObjectHolders(); } else { var folder = EditorUtility.OpenFolderPanel("选择文件夹", Application.dataPath, ""); folder = folder.Replace(Application.dataPath, "Assets"); if (!string.IsNullOrEmpty(folder)) { userPath = folder; currobjhs = null; UpdateObjectHolders(); } } } } } }
private void DrawWidgeItem(Rect rect, int index, bool isActive, bool isFocused) { var boxRect = new Rect(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4); WidgetUtility.DrawContentColor(boxRect, Color.green); rect = new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10); var item = widgetItems[index]; var typeRect = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); item.type = (WidgetType)EditorGUI.EnumPopup(typeRect, item.type); if (EditorGUI.EndChangeCheck()) { item.ChangeType(item.type); } var nameRect = new Rect(rect.x + rect.width * 0.3f, rect.y, rect.width * 0.7f, EditorGUIUtility.singleLineHeight); item.name = EditorGUI.TextField(nameRect, item.name); if (item.spriteDic == null) { return; } var itemnameRect = new Rect(rect.x + 0.1f * rect.width, rect.y + EditorGUIUtility.singleLineHeight, rect.width * 0.3f, EditorGUIUtility.singleLineHeight); var spriteRect = new Rect(rect.x + 0.4f * rect.width, rect.y + +EditorGUIUtility.singleLineHeight, rect.width * 0.6f, EditorGUIUtility.singleLineHeight); var keys = item.spriteDic.Keys; var array = new List <string>(keys); foreach (var key in array) { EditorGUI.LabelField(itemnameRect, key); item.spriteDic[key] = EditorGUI.ObjectField(spriteRect, item.spriteDic[key], typeof(Sprite), false) as Sprite; itemnameRect.y += EditorGUIUtility.singleLineHeight; spriteRect.y += EditorGUIUtility.singleLineHeight; } }