private void OpenLayout(object userstate) { var e = userstate as EventContainer; //LayoutWindow LayoutEditorWindow.OpenLayout(e.layoutPath); }
public static void LayoutPathSelect(object obj, FieldInfo field, string label, object attr) { var resources = "Assets/Resources/"; var path = (string)field.GetValue(obj); var res = AssetDatabase.LoadAssetAtPath <UnityEngine.TextAsset> (resources + path); //GUILayout.BeginVertical (); GUILayout.Label(label); GUILayout.BeginHorizontal(); res = EditorGUILayout.ObjectField(res, typeof(TextAsset), false, GUILayout.Width(100)) as TextAsset; path = AssetDatabase.GetAssetPath(res); path = path.Replace(resources, ""); field.SetValue(obj, path); if (GUILayout.Button("New")) { var fPath = EditorUtility.SaveFilePanel("新建Layout", Application.dataPath + "/Resources/", "layout", "xml"); if (!string.IsNullOrEmpty(fPath)) { path = fPath.Replace(Application.dataPath + "/Resources/", ""); var layout = new TimeLine(); var xml = XmlParser.Serialize(layout); File.WriteAllText(fPath, xml, XmlParser.UTF8); AssetDatabase.Refresh(); field.SetValue(obj, path); } } if (!string.IsNullOrEmpty(path)) { if (GUILayout.Button("Open")) { //Open layout window LayoutEditorWindow.OpenLayout(path); } } GUILayout.EndHorizontal(); //GUILayout.EndVertical (); }