com.elestrago.unity.package-tools 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CAHNGELOG.md +130 -0
  2. package/CAHNGELOG.md.meta +7 -0
  3. package/Documentation~/Inspector.png +0 -0
  4. package/Documentation~/PackageManifestConfigIcon.png +0 -0
  5. package/Editor/CIUtils.cs +247 -0
  6. package/Editor/CIUtils.cs.meta +11 -0
  7. package/Editor/Drawers/AuthorPropertyDrawer.cs +82 -0
  8. package/Editor/Drawers/AuthorPropertyDrawer.cs.meta +11 -0
  9. package/Editor/Drawers/DependencyPropertyDrawer.cs +60 -0
  10. package/Editor/Drawers/DependencyPropertyDrawer.cs.meta +3 -0
  11. package/Editor/Drawers/SamplePropertyDrawer.cs +62 -0
  12. package/Editor/Drawers/SamplePropertyDrawer.cs.meta +3 -0
  13. package/Editor/Drawers.meta +3 -0
  14. package/Editor/EditorConstants.cs +110 -0
  15. package/Editor/EditorConstants.cs.meta +3 -0
  16. package/Editor/IconMap/PackageManifestConfigIcon.png +0 -0
  17. package/Editor/IconMap/PackageManifestConfigIcon.png.meta +127 -0
  18. package/Editor/IconMap.meta +8 -0
  19. package/Editor/Inspectors/PackageManifestConfigInspector.cs +404 -0
  20. package/Editor/Inspectors/PackageManifestConfigInspector.cs.meta +3 -0
  21. package/Editor/Inspectors.meta +3 -0
  22. package/Editor/MenuItems.cs +11 -0
  23. package/Editor/MenuItems.cs.meta +11 -0
  24. package/Editor/PackageManifestConfig.cs +194 -0
  25. package/Editor/PackageManifestConfig.cs.meta +11 -0
  26. package/Editor/Playdarium.PackageTool.Editor.asmdef +16 -0
  27. package/Editor/Playdarium.PackageTool.Editor.asmdef.meta +7 -0
  28. package/Editor/Tools/CodeGenTools.cs +145 -0
  29. package/Editor/Tools/CodeGenTools.cs.meta +11 -0
  30. package/Editor/Tools/CommandLineTools.cs +68 -0
  31. package/Editor/Tools/CommandLineTools.cs.meta +11 -0
  32. package/Editor/Tools/FileTools.cs +328 -0
  33. package/Editor/Tools/FileTools.cs.meta +3 -0
  34. package/Editor/Tools/GUILayoutTools.cs +177 -0
  35. package/Editor/Tools/GUILayoutTools.cs.meta +3 -0
  36. package/Editor/Tools/GitTools.cs +66 -0
  37. package/Editor/Tools/GitTools.cs.meta +11 -0
  38. package/Editor/Tools/PackageJsonModel.cs +149 -0
  39. package/Editor/Tools/PackageJsonModel.cs.meta +3 -0
  40. package/Editor/Tools/PackageManifestTools.cs +77 -0
  41. package/Editor/Tools/PackageManifestTools.cs.meta +3 -0
  42. package/Editor/Tools/UnityFileTools.cs +132 -0
  43. package/Editor/Tools/UnityFileTools.cs.meta +3 -0
  44. package/Editor/Tools.meta +3 -0
  45. package/Editor/Utils/PackageInitialize/PackageInitializeTemplates.cs +171 -0
  46. package/Editor/Utils/PackageInitialize/PackageInitializeTemplates.cs.meta +3 -0
  47. package/Editor/Utils/PackageInitialize/PackageInitializeUtil.cs +111 -0
  48. package/Editor/Utils/PackageInitialize/PackageInitializeUtil.cs.meta +3 -0
  49. package/Editor/Utils/PackageInitialize/PackageInitializeWindow.cs +92 -0
  50. package/Editor/Utils/PackageInitialize/PackageInitializeWindow.cs.meta +3 -0
  51. package/Editor/Utils/PackageInitialize.meta +3 -0
  52. package/Editor/Utils.meta +3 -0
  53. package/Editor.meta +3 -0
  54. package/LICENSE +21 -0
  55. package/LICENSE.meta +7 -0
  56. package/README.md +204 -0
  57. package/README.md.meta +7 -0
  58. package/package.json +41 -0
  59. package/package.json.meta +7 -0
package/CAHNGELOG.md ADDED
@@ -0,0 +1,130 @@
1
+ # Changelog
2
+
3
+ ---
4
+
5
+ ## [v2.0.7](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.7)
6
+
7
+ ### Fixed
8
+
9
+ - Newtonsoft Json dependency
10
+
11
+ ---
12
+
13
+ ## [v2.0.6](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.6)
14
+
15
+ ### Fixed
16
+
17
+ - Remove `npm install` from CI job template
18
+
19
+ ---
20
+
21
+ ## [v2.0.5](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.5)
22
+
23
+ ### Fixed
24
+
25
+ - Remove `.idea` folder from package
26
+ - Package repository url in README.md
27
+
28
+ ---
29
+
30
+ ## [v2.0.4](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.4)
31
+
32
+ ### Fixed
33
+
34
+ - Remove `npm install` from CI job for avoid unresolved dependencies conflicts
35
+ - Package initializer window size and make size flexible
36
+
37
+ ---
38
+
39
+ ## [v2.0.3](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.3)
40
+
41
+ ### Fixed
42
+
43
+ - Links to readme, changelog and license files
44
+
45
+ ---
46
+
47
+ ## [v2.0.2](https://gitlab.com/pd-packages/package-tool/-/tags/v2.0.2)
48
+
49
+ ### Changed
50
+
51
+ - Migrate to GitLab
52
+ - New package name `com.playdarium.unity.package-tools`
53
+ - CI file generation
54
+
55
+ ---
56
+
57
+ ## [v1.0.3](https://github.com/playdarium/package-tool/releases/tag/v1.0.3)
58
+
59
+ ### Changed
60
+
61
+ - Fix generated package folder path
62
+
63
+ ---
64
+
65
+ ## [v1.0.2](https://github.com/playdarium/package-tool/releases/tag/v1.0.2)
66
+
67
+ ### Added
68
+
69
+ - `ExampleProject` for show how work adding samples to package
70
+
71
+ ### Changed
72
+
73
+ - Update changelog template
74
+
75
+ ---
76
+
77
+ ## [v1.0.1](https://github.com/playdarium/package-tool/releases/tag/v1.0.1)
78
+
79
+ ### Added
80
+
81
+ - Init package fields validation
82
+ - CIUtils script for generate package and prepare dll configuration
83
+ - Auto generate `Documentation~` and `Samples~` folders when init package
84
+
85
+ ### Changed
86
+
87
+ - Changed namespace from `Package.PackageTool` to `Playdarium.PackageTool`
88
+
89
+ ---
90
+
91
+ ## [v1.0.0](https://github.com/playdarium/package-tool/releases/tag/v1.0.0)
92
+
93
+ ### Added
94
+
95
+ - Export `Documentation~` folder to package manifest
96
+ - Export samples to package manifest
97
+ - Fields for copy files README, CHANGELOG, LICENSE
98
+ - Auto filled url for documentation, changelog and license in `package.json`
99
+
100
+ ### Changed
101
+
102
+ - Make readable json format in `package.json` file
103
+
104
+ ---
105
+
106
+ ## [v1.0.0](https://github.com/playdarium/package-tool/releases/tag/v1.0.0)
107
+
108
+ ### Added
109
+
110
+ - For new features.
111
+
112
+ ### Changed
113
+
114
+ - For changes in existing functionality.
115
+
116
+ ### Deprecated
117
+
118
+ - For soon-to-be removed features.
119
+
120
+ ### Removed
121
+
122
+ - For now removed features.
123
+
124
+ ### Fixed
125
+
126
+ - For any bug fixes.
127
+
128
+ ### Security
129
+
130
+ - In case of vulnerabilities.
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 0efa450279b0a4c68be92211275d49f2
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
Binary file
@@ -0,0 +1,247 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.Linq;
4
+ using System.Text;
5
+ using Playdarium.PackageTool.Tools;
6
+ using UnityEditor;
7
+ using UnityEngine;
8
+
9
+ namespace Playdarium.PackageTool
10
+ {
11
+ /// <summary>
12
+ /// Continuous-integration API for package tools.
13
+ /// </summary>
14
+ public static class CIUtils
15
+ {
16
+ // Command-line arguments
17
+ private const string ID_ARG_KEY = "id";
18
+ private const string VERSION_ARG_KEY = "version";
19
+ private const string PREVIEW_ARG_KEY = "preview";
20
+ private const string GENERATE_VERSION_CONSTANTS_ARG_KEY = "generateversionconstants";
21
+
22
+ // Logs
23
+ private const string LOG_PREFIX = "[Package Tools] ";
24
+ private const string CI_STARTING = LOG_PREFIX + "Starting Package Tools CI...";
25
+ private const string CI_COMPLETE = LOG_PREFIX + "Package Tools CI has completed!";
26
+ private const string CI_COMMAND_LINE_ARGS_PARSED_FORMAT = LOG_PREFIX + "Parsed CI Command Line Args.\n\n{0}";
27
+
28
+ private const string CI_USING_ONLY_CONFIGS_FROM_ARG =
29
+ LOG_PREFIX + "Using configs matching IDs passed in 'ID' argument";
30
+
31
+ private const string CI_FOUND_CONFIGS = LOG_PREFIX + "Found [{0}] configs in project.";
32
+ private const string CI_USING_ALL_CONFIGS = LOG_PREFIX + "Using all configs in project.";
33
+ private const string CI_GENERATION_STARTING = LOG_PREFIX + "Starting to generate packages...";
34
+
35
+ private const string CI_PACKAGE_NOT_FOUND_FORMAT =
36
+ LOG_PREFIX + "Could not find a package for ID: [{0}], skipping it.";
37
+
38
+ private const string CI_PACKAGE_FOUND_FORMAT = LOG_PREFIX + "Package [{0}] found for ID: [{1}]";
39
+
40
+ private const string CI_GENERATING_LEGACY_PACKAGE_FORMAT =
41
+ LOG_PREFIX + "Generating Legacy Package for Config [{0}] with ID: [{1}]";
42
+
43
+ private const string CI_SKIPPING_LEGACY_PACKAGE_FORMAT = LOG_PREFIX +
44
+ "Skipping Legacy Package for Config [{0}] with ID: [{1}] as no output path is present in config.";
45
+
46
+ private const string CI_GENERATING_PACKAGE_SOURCE_FORMAT =
47
+ LOG_PREFIX + "Generating Package Source for Config [{0}] with ID: [{1}].";
48
+
49
+ private const string CI_SKIPPING_PACKAGE_SOURCE_FORMAT = LOG_PREFIX +
50
+ "Skipping Package Source for Config [{0}] with ID: [{1}] as no output path is present in config.";
51
+
52
+ private static readonly StringBuilder StringBuilder;
53
+
54
+ private static bool IsRunningOnCI => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI"));
55
+
56
+ static CIUtils()
57
+ {
58
+ StringBuilder = new StringBuilder(8192);
59
+ }
60
+
61
+ /// <summary>
62
+ /// Attempts to use zero or more <see cref="PackageManifestConfig"/> assets to generate legacy Unity packages
63
+ /// and Unity source.
64
+ /// </summary>
65
+ public static void Generate()
66
+ {
67
+ Debug.Log(CI_STARTING);
68
+
69
+ PrepareDll();
70
+
71
+ try
72
+ {
73
+ EditorApplication.LockReloadAssemblies();
74
+ AssetDatabase.StartAssetEditing();
75
+
76
+ // Get command line args and log them
77
+ var commandLineArgs = CommandLineTools.GetKVPCommandLineArguments();
78
+
79
+ StringBuilder.Clear();
80
+ const string cliArgFormat = "{0} => {1}";
81
+ foreach (var commandLineArg in commandLineArgs)
82
+ {
83
+ StringBuilder.AppendFormat(cliArgFormat, commandLineArg.Key, commandLineArg.Value);
84
+ StringBuilder.AppendLine();
85
+ }
86
+
87
+ Debug.LogFormat(CI_COMMAND_LINE_ARGS_PARSED_FORMAT, StringBuilder);
88
+
89
+ // Attempt to parse CLI-passed version, if present.
90
+ string version = null;
91
+ if (commandLineArgs.TryGetValue(VERSION_ARG_KEY, out var versionRawValue))
92
+ version = (string)versionRawValue;
93
+
94
+ // Attempt to parse CLI-passed version, if present.
95
+ bool? isPreview = null;
96
+ if (commandLineArgs.TryGetValue(PREVIEW_ARG_KEY, out var previewRawValue))
97
+ isPreview = bool.Parse((string)previewRawValue);
98
+
99
+ // See if we should generate version constants
100
+ var generateVersionConstants = false;
101
+ if (commandLineArgs.TryGetValue(
102
+ GENERATE_VERSION_CONSTANTS_ARG_KEY,
103
+ out var generateVersionConstantsRawValue))
104
+ generateVersionConstants = bool.Parse(generateVersionConstantsRawValue.ToString());
105
+
106
+ // Get all package manifests in project
107
+ var allPackageManifestConfigs = PackageManifestTools.GetAllConfigs();
108
+
109
+ Debug.LogFormat(CI_FOUND_CONFIGS, allPackageManifestConfigs.Length);
110
+
111
+ // Check to see if any IDs have been passed for specific configs
112
+ string[] configIds;
113
+ if (commandLineArgs.TryGetValue(ID_ARG_KEY, out var arg))
114
+ {
115
+ Debug.Log(CI_USING_ONLY_CONFIGS_FROM_ARG);
116
+
117
+ const char commaChar = ',';
118
+ var idArgValue = arg.ToString();
119
+ configIds = idArgValue.Split(commaChar);
120
+ }
121
+ // Otherwise generate all package manifest configs in project.
122
+ else
123
+ {
124
+ Debug.Log(CI_USING_ALL_CONFIGS);
125
+
126
+ configIds = allPackageManifestConfigs.Select(x => x.Id).ToArray();
127
+ }
128
+
129
+ // For each matching config ID, find the matching package manifest config and generate any relevant packages.
130
+ Debug.Log(CI_GENERATION_STARTING);
131
+ foreach (var configId in configIds)
132
+ {
133
+ var matchingConfig = allPackageManifestConfigs.FirstOrDefault(x =>
134
+ string.Compare(x.Id, configId, StringComparison.OrdinalIgnoreCase) == 0);
135
+
136
+ // If a config cannot be found matching config id, skip it and continue.
137
+ if (matchingConfig == null)
138
+ {
139
+ Debug.LogWarningFormat(CI_PACKAGE_NOT_FOUND_FORMAT, configId);
140
+
141
+ continue;
142
+ }
143
+
144
+ var configName = matchingConfig.name;
145
+
146
+ Debug.LogFormat(CI_PACKAGE_FOUND_FORMAT, configName, configId);
147
+
148
+ // Set the CLI passed version if present, otherwise default to checked in version number.
149
+ if (!string.IsNullOrEmpty(version))
150
+ {
151
+ matchingConfig.packageVersion = version;
152
+ EditorUtility.SetDirty(matchingConfig);
153
+ }
154
+
155
+ // If set to generate version constants, do so.
156
+ if (generateVersionConstants) CodeGenTools.GenerateVersionConstants(matchingConfig);
157
+
158
+ // Otherwise generate the corresponding legacy unity package and package source if their output paths
159
+ // have been defined
160
+ if (!string.IsNullOrEmpty(matchingConfig.legacyPackageDestinationPath))
161
+ {
162
+ Debug.LogFormat(CI_GENERATING_LEGACY_PACKAGE_FORMAT, configName, configId);
163
+
164
+ UnityFileTools.CompileLegacyPackage(matchingConfig);
165
+ }
166
+ else
167
+ {
168
+ Debug.LogFormat(CI_SKIPPING_LEGACY_PACKAGE_FORMAT, configName, configId);
169
+ }
170
+
171
+ if (!string.IsNullOrEmpty(matchingConfig.packageDestinationPath))
172
+ {
173
+ Debug.LogFormat(CI_GENERATING_PACKAGE_SOURCE_FORMAT, configName, configId);
174
+
175
+ FileTools.CreateOrUpdatePackageSource(matchingConfig);
176
+ }
177
+ else
178
+ {
179
+ Debug.LogFormat(CI_SKIPPING_PACKAGE_SOURCE_FORMAT, configName, configId);
180
+ }
181
+ }
182
+ }
183
+ catch (Exception e)
184
+ {
185
+ Debug.LogErrorFormat("An unexpected error occured during package generation:\n\n{0}", e);
186
+ }
187
+ finally
188
+ {
189
+ AssetDatabase.StopAssetEditing();
190
+ EditorApplication.UnlockReloadAssemblies();
191
+ }
192
+
193
+ Debug.Log(CI_COMPLETE);
194
+ }
195
+
196
+ [MenuItem("Tools/PackageTools/PrepareDll")]
197
+ public static void PrepareDll()
198
+ {
199
+ try
200
+ {
201
+ Debug.Log($"[{nameof(CIUtils)}] PrepareDll");
202
+
203
+ var packageManifestConfig = PackageManifestTools.GetAllConfigs().Single();
204
+ var sourcePath = packageManifestConfig.sourcePath;
205
+
206
+ Debug.Log($"[{nameof(CIUtils)}] Find assets in path: {sourcePath}");
207
+
208
+ var assets = AssetDatabase.GetAllAssetPaths().Where(s => s.Contains(sourcePath));
209
+ foreach (var asset in assets)
210
+ {
211
+ if (Path.GetExtension(asset) != ".dll")
212
+ continue;
213
+
214
+ var isEditor = Path.GetFileNameWithoutExtension(asset).Contains("Editor")
215
+ || asset.Contains("/Editor/");
216
+ var pluginImporter = (PluginImporter)AssetImporter.GetAtPath(asset);
217
+ if (isEditor)
218
+ {
219
+ pluginImporter.SetCompatibleWithAnyPlatform(false);
220
+ pluginImporter.SetCompatibleWithEditor(true);
221
+ Debug.Log($"[{nameof(CIUtils)}] SetCompatibleWithEditor: {asset}");
222
+ }
223
+ else
224
+ {
225
+ pluginImporter.SetCompatibleWithAnyPlatform(true);
226
+ pluginImporter.SetExcludeEditorFromAnyPlatform(false);
227
+ Debug.Log($"[{nameof(CIUtils)}] SetCompatibleWithAnyPlatform and ExcludeEditor: {asset}");
228
+ }
229
+
230
+ pluginImporter.SaveAndReimport();
231
+ }
232
+
233
+ Debug.Log($"[{nameof(CIUtils)}] Complete dll import");
234
+ }
235
+ catch (Exception e)
236
+ {
237
+ Debug.LogException(e);
238
+
239
+ if (IsRunningOnCI)
240
+ EditorApplication.Exit(1);
241
+ }
242
+
243
+ if (IsRunningOnCI)
244
+ EditorApplication.Exit(0);
245
+ }
246
+ }
247
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f92113ddd09bdc8468d95ff663ade584
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,82 @@
1
+ /*
2
+ MIT License
3
+
4
+ Copyright (c) 2020 Jeff Campbell
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ using UnityEditor;
26
+ using UnityEngine;
27
+
28
+ namespace Playdarium.PackageTool.Drawers
29
+ {
30
+ /// <summary>
31
+ /// A property drawer for drawing <see cref="PackageManifestConfig.Author"/>
32
+ /// </summary>
33
+ [CustomPropertyDrawer(typeof(PackageManifestConfig.Author))]
34
+ internal sealed class AuthorPropertyDrawer : PropertyDrawer
35
+ {
36
+ private const string NAME_PROPERTY_NAME = "name";
37
+ private const string EMAIL_PROPERTY_NAME = "email";
38
+ private const string URL_PROPERTY_NAME = "url";
39
+
40
+ private const string NAME_LABEL = "Author Name";
41
+ private const string EMAIL_LABEL = "Author Email";
42
+ private const string URL_LABEL = "Author URL";
43
+
44
+ private readonly GUIContent _nameGUIContent;
45
+ private readonly GUIContent _emailGUIContent;
46
+ private readonly GUIContent _urlGUIContent;
47
+
48
+ public AuthorPropertyDrawer()
49
+ {
50
+ _nameGUIContent = new GUIContent(NAME_LABEL);
51
+ _emailGUIContent = new GUIContent(EMAIL_LABEL);
52
+ _urlGUIContent = new GUIContent(URL_LABEL);
53
+ }
54
+
55
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
56
+ {
57
+ var nameRect = new Rect(position)
58
+ {
59
+ height = EditorGUIUtility.singleLineHeight
60
+ };
61
+
62
+ var emailRect = new Rect(nameRect)
63
+ {
64
+ position = new Vector2(position.x, nameRect.y + nameRect.height + 2f)
65
+ };
66
+
67
+ var urlRect = new Rect(emailRect)
68
+ {
69
+ position = new Vector2(position.x, emailRect.y + emailRect.height + 2f)
70
+ };
71
+
72
+ EditorGUI.PropertyField(nameRect, property.FindPropertyRelative(NAME_PROPERTY_NAME), _nameGUIContent);
73
+ EditorGUI.PropertyField(emailRect, property.FindPropertyRelative(EMAIL_PROPERTY_NAME), _emailGUIContent);
74
+ EditorGUI.PropertyField(urlRect, property.FindPropertyRelative(URL_PROPERTY_NAME), _urlGUIContent);
75
+ }
76
+
77
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
78
+ {
79
+ return EditorGUIUtility.singleLineHeight * 3f + 6f;
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2db3369bb93dff540861ebdcef3b41cc
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,60 @@
1
+ /*
2
+ MIT License
3
+
4
+ Copyright (c) 2020 Jeff Campbell
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ using UnityEditor;
26
+ using UnityEngine;
27
+
28
+ namespace Playdarium.PackageTool.Drawers
29
+ {
30
+ /// <summary>
31
+ /// A property drawer for drawing <see cref="PackageManifestConfig.Dependency"/>
32
+ /// </summary>
33
+ [CustomPropertyDrawer(typeof(PackageManifestConfig.Dependency))]
34
+ internal sealed class DependencyPropertyDrawer : PropertyDrawer
35
+ {
36
+ private const string PACKAGE_NAME_PROPERTY_NAME = "packageName";
37
+ private const string PACKAGE_VERSION_PROPERTY_NAME = "packageVersion";
38
+
39
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
40
+ {
41
+ var packageRect = new Rect(position)
42
+ {
43
+ height = EditorGUIUtility.singleLineHeight
44
+ };
45
+
46
+ var packageVersionRect = new Rect(packageRect)
47
+ {
48
+ position = new Vector2(position.x, packageRect.y + packageRect.height)
49
+ };
50
+
51
+ EditorGUI.PropertyField(packageRect, property.FindPropertyRelative(PACKAGE_NAME_PROPERTY_NAME));
52
+ EditorGUI.PropertyField(packageVersionRect, property.FindPropertyRelative(PACKAGE_VERSION_PROPERTY_NAME));
53
+ }
54
+
55
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
56
+ {
57
+ return EditorGUIUtility.singleLineHeight * 2f;
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 14741f16085841cc9711fa0107a9c584
3
+ timeCreated: 1554966411
@@ -0,0 +1,62 @@
1
+ using Playdarium.PackageTool.Tools;
2
+ using UnityEditor;
3
+ using UnityEngine;
4
+
5
+ namespace Playdarium.PackageTool.Drawers
6
+ {
7
+ [CustomPropertyDrawer(typeof(PackageManifestConfig.Sample))]
8
+ public class SamplePropertyDrawer : PropertyDrawer
9
+ {
10
+ private const string DISPLAY_NAME_PROPERTY_NAME = "displayName";
11
+ private const string DESCRIPTION_PROPERTY_NAME = "description";
12
+ private const string PATH_PROPERTY_NAME = "path";
13
+
14
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
15
+ {
16
+ var displayNameRect = new Rect(position)
17
+ {
18
+ height = EditorGUIUtility.singleLineHeight
19
+ };
20
+ displayNameRect.height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT;
21
+
22
+ var descriptionRect = new Rect(displayNameRect)
23
+ {
24
+ position = new Vector2(position.x, displayNameRect.y + displayNameRect.height + 2)
25
+ };
26
+ descriptionRect.height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT;
27
+
28
+ var pathRect = new Rect(descriptionRect)
29
+ {
30
+ position = new Vector2(position.x, descriptionRect.y + displayNameRect.height + 2),
31
+ };
32
+
33
+ pathRect.width -= EditorConstants.FOLDER_PATH_PICKER_BUFFER;
34
+ pathRect.height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT;
35
+ var newPathRect = new Rect(pathRect);
36
+
37
+ var pathProperty = property.FindPropertyRelative(PATH_PROPERTY_NAME);
38
+ EditorGUI.PropertyField(displayNameRect, property.FindPropertyRelative(DISPLAY_NAME_PROPERTY_NAME));
39
+ EditorGUI.PropertyField(descriptionRect, property.FindPropertyRelative(DESCRIPTION_PROPERTY_NAME));
40
+ EditorGUI.PropertyField(newPathRect, pathProperty);
41
+
42
+ var folderPickerRect = new Rect
43
+ {
44
+ position = new Vector2(
45
+ newPathRect.width + EditorConstants.FOLDER_PATH_PICKER_BUFFER + 10,
46
+ newPathRect.position.y),
47
+ width = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
48
+ height = EditorConstants.FOLDER_PATH_PICKER_HEIGHT,
49
+ };
50
+
51
+ GUILayoutTools.DrawSourceFolderPicker(
52
+ folderPickerRect,
53
+ pathProperty,
54
+ EditorConstants.SELECT_SAMPLES_PATH_FOLDER_TITLE);
55
+ }
56
+
57
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
58
+ {
59
+ return EditorGUIUtility.singleLineHeight * 3f;
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 84a7cde6b5ef4569a2e1fba5ff3b1a5d
3
+ timeCreated: 1655809044
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 710552c69d1d4891b536566eb51c787e
3
+ timeCreated: 1554966389