12using System.Collections.Generic;
16 [CustomEditor(typeof(PackageDefinition))]
18 private List<PackageDefinition> _childPackages;
20 private SerializedProperty _ignoredFiles;
21 private SerializedProperty _ignoredFolders;
26 _childPackages = target.GetChildPackages();
28 _ignoredFiles = serializedObject.FindProperty(
"_ignoredFiles");
29 _ignoredFolders = serializedObject.FindProperty(
"_ignoredFolders");
31 hideField(
"_ignoredFolders");
32 hideField(
"_ignoredFiles");
34 createList(
"_dependantFolders", drawFolderElement);
35 createList(
"_dependantFiles", drawFileElement);
36 createList(
"_dependantPackages", drawPackageElement);
38 specifyCustomDecorator(
"_dependantFolders", prop =>
drawExportFolder(prop,
"Build Package",
"Package Export Folder"));
42 base.OnInspectorGUI();
44 if (_childPackages.Count != 0) {
45 GUILayout.Space(EditorGUIUtility.singleLineHeight * 2);
47 EditorGUILayout.BeginHorizontal();
48 EditorGUILayout.LabelField(
"Packages that depend on this package", EditorStyles.boldLabel);
49 if (GUILayout.Button(
"Build All")) {
50 target.BuildAllChildPackages();
52 EditorGUILayout.EndHorizontal();
54 EditorGUI.BeginDisabledGroup(
true);
55 foreach (var childPackage
in _childPackages) {
58 EditorGUI.EndDisabledGroup();
64 target.BuildPackage(interactive:
true);
72 return "BuildPackage";
75 private void drawFolderElement(Rect rect, SerializedProperty property) {
76 drawExplorerElement(rect, property, _ignoredFolders, EditorUtility.OpenFolderPanel);
79 private void drawFileElement(Rect rect, SerializedProperty property) {
80 drawExplorerElement(rect, property, _ignoredFiles, EditorUtility.OpenFilePanel);
83 private void drawPackageElement(Rect rect, SerializedProperty property) {
84 EditorGUI.PropertyField(rect, property, GUIContent.none);
87 private void drawExplorerElement(Rect rect, SerializedProperty property, SerializedProperty ignoredList, Func<string, string, string, string> openAction) {
88 Rect left, middle, right;
90 rect.SplitHorizontallyWithRight(out rect, out right, 100);
91 rect.SplitHorizontallyWithRight(out left, out middle, EditorGUIUtility.singleLineHeight);
93 EditorGUI.TextField(left, property.stringValue);
95 bool isIncluded =
true;
96 for (
int i = 0; i < ignoredList.arraySize; i++) {
97 if (ignoredList.GetArrayElementAtIndex(i).stringValue == property.stringValue) {
103 bool shouldBeIncluded = EditorGUI.Toggle(middle, isIncluded);
105 if (shouldBeIncluded != isIncluded) {
106 if (shouldBeIncluded) {
107 for (
int i = ignoredList.arraySize; i-- != 0;) {
108 if (ignoredList.GetArrayElementAtIndex(i).stringValue == property.stringValue) {
109 ignoredList.DeleteArrayElementAtIndex(i);
113 ignoredList.InsertArrayElementAtIndex(0);
114 ignoredList.GetArrayElementAtIndex(0).stringValue =
property.stringValue;
118 if (GUI.Button(right,
"Change")) {
119 string chosenFolder = openAction(
"Select Folder", Application.dataPath,
"");
120 if (!
string.IsNullOrEmpty(chosenFolder)) {
121 string relativePath = Utils.MakeRelativePath(Application.dataPath, chosenFolder);
122 if (!
string.IsNullOrEmpty(relativePath) && !relativePath.StartsWith(
"..")) {
123 if (relativePath != property.stringValue) {
124 property.stringValue = relativePath;
ReorderableList createList(string propertyName, Action< Rect, SerializedProperty > drawMethod)
void drawExportFolder(SerializedProperty prop, string buildText, string label)
override int GetBuildMenuPriority()
override string GetBuildMethodName()
override void OnInspectorGUI()