using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
namespace SK.Framework
{
///
/// 蓝湖UI界面搭建工具
///
public class LanHu : EditorWindow
{
[MenuItem("SKFramework/UI/LanHu")]
public static void Open()
{
GetWindow("LanHu").Show();
}
private string path;
private List elements;
private Vector2 scroll;
private const float labelWidth = 70f;
private Dictionary foldoutDic;
private CanvasScaler canvasScaler;
private void OnEnable()
{
path = "Assets";
elements = new List();
foldoutDic = new Dictionary();
}
private void OnGUI()
{
OnTopGUI();
OnElementsGUI();
OnMenuGUI();
}
private void OnTopGUI()
{
GUILayout.BeginHorizontal();
GUILayout.Label("切图文件夹路径:", GUILayout.Width(100f));
EditorGUILayout.TextField(path);
if (GUILayout.Button("浏览", GUILayout.Width(40f)))
{
//Assets相对路径
path = EditorUtility.OpenFolderPanel("选择切图文件夹", "", "").Replace(Application.dataPath, "Assets");
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Canvas Scaler", GUILayout.Width(100f));
canvasScaler = (CanvasScaler)EditorGUILayout.ObjectField(canvasScaler, typeof(CanvasScaler), true);
if (canvasScaler == null)
{
if (GUILayout.Button("创建", GUILayout.Width(40f)))
{
var canvas = new GameObject("Canvas").AddComponent