@@ -11,6 +11,7 @@ Unity plugin that requires:
11
11
[ AARs] ( https://developer.android.com/studio/projects/android-library.html ) ).
12
12
* iOS [ CocoaPods] ( https://cocoapods.org/ ) .
13
13
* Version management of transitive dependencies.
14
+ * Management of Unity Package Manager Registries.
14
15
15
16
# Background
16
17
@@ -65,6 +66,22 @@ Using CocoaPods allows multiple plugins to utilize shared components without
65
66
forcing developers to fix either duplicate or incompatible versions of
66
67
libraries included through multiple Unity plugins in their project.
67
68
69
+ ## Unity Package Manager Registry Setup
70
+
71
+ The [ Unity Package Manager] ( https://docs.unity3d.com/Manual/Packages.html )
72
+ (UPM) makes use of [ NPM] ( https://www.npmjs.com/ ) registry servers for package
73
+ hosting and provides ways to discover, install, upgrade and uninstall packages.
74
+ This makes it easier for developers to manage plugins within their projects.
75
+
76
+ However, installing additional package registries requires a few manual steps
77
+ that can potentially be error prone. The * Unity Package Manager Resolver*
78
+ component of this plugin integrates with
79
+ [ UPM] ( https://docs.unity3d.com/Manual/Packages.html ) to provide a way to
80
+ auto-install UPM package registries when a ` .unitypackage ` is installed which
81
+ allows plugin maintainers to ship a ` .unitypackage ` that can provide access
82
+ to their own UPM registry server to make it easier for developers to
83
+ manage their plugins.
84
+
68
85
## Unity Plugin Version Management
69
86
70
87
Finally, the * Version Handler* component of this plugin simplifies the process
@@ -106,21 +123,28 @@ section of this document.
106
123
107
124
# Requirements
108
125
109
- The Android Resolver and iOS Resolver components of the plugin only work with
110
- Unity version 4.6.8 or higher.
126
+ The * Android Resolver* and * iOS Resolver* components of the plugin only work
127
+ with Unity version 4.6.8 or higher.
111
128
112
129
The * Version Handler* component only works with Unity 5.x or higher as it
113
130
depends upon the ` PluginImporter ` UnityEditor API.
114
131
132
+ The * Unity Package Manager Resolver* component only works with
133
+ Unity 2018.4 or above, when
134
+ [ scoped registry] ( https://docs.unity3d.com/Manual/upm-scoped.html )
135
+ support was added to the Unity Package Manager.
136
+
115
137
# Getting Started
116
138
117
139
Before you import EDM4U into your plugin project, you first
118
140
need to consider whether you intend to * redistribute* ` EDM4U `
119
141
along with your own plugin.
120
142
121
- Redistributing ` EDM4U ` inside your own plugin will ease
122
- the integration process for your users, by resolving dependency conflicts
123
- between your plugin and other plugins in a user's project.
143
+ ## Plugin Redistribution
144
+
145
+ If you're a plugin maintainer, redistributing ` EDM4U ` inside your own plugin
146
+ will ease the integration process for your users, by resolving dependency
147
+ conflicts between your plugin and other plugins in a user's project.
124
148
125
149
If you wish to redistribute ` EDM4U ` inside your plugin,
126
150
you ** must** follow these steps when importing the
@@ -153,7 +177,7 @@ Unity -gvh_disable \
153
177
-quit
154
178
```
155
179
156
- ## Background
180
+ ### Background
157
181
158
182
The * Version Handler* component relies upon deferring the load of editor DLLs
159
183
so that it can run first and determine the latest version of a plugin component
@@ -175,9 +199,10 @@ target in the Unity editor.
175
199
EDM4U with your plugin, you ** must** follow the
176
200
import steps in the [ Getting Started] ( #getting-started ) section!
177
201
178
- 2 . Copy and rename the ` SampleDependencies.xml ` file into your
179
- plugin and add the dependencies your plugin requires.
180
-
202
+ 2 . Copy and rename the
203
+ [ SampleDependencies.xml] ( https://github.com/googlesamples/unity-jar-resolver/blob/master/sample/Assets/ExternalDependencyManager/Editor/SampleDependencies.xml )
204
+ file into your plugin and add the dependencies your plugin requires.
205
+
181
206
The XML file just needs to be under an ` Editor ` directory and match the
182
207
name ` *Dependencies.xml ` . For example,
183
208
` MyPlugin/Editor/MyPluginDependencies.xml ` .
@@ -324,7 +349,7 @@ results in the execution of the following operations:
324
349
local maven repositories.
325
350
- Inject the required Gradle repositories into ` mainTemplate.gradle ` at the
326
351
line matching the pattern
327
- ` .*apply plugin: 'com\.android\.(application|library)'.*" ` or the section
352
+ ` .*apply plugin: 'com\.android\.(application|library)'.* ` or the section
328
353
starting at the line ` // Android Resolver Repos Start ` .
329
354
If you want to control the injection point in the file, the section
330
355
delimited by the lines ` // Android Resolver Repos Start ` and
@@ -374,9 +399,10 @@ Dependencies for iOS are added by referring to CocoaPods.
374
399
EDM4U with your plugin, you ** must** follow the
375
400
import steps in the [ Getting Started] ( #getting-started ) section!
376
401
377
- 2 . Copy and rename the SampleDependencies.xml file into your
378
- plugin and add the dependencies your plugin requires.
379
-
402
+ 2 . Copy and rename the
403
+ [ SampleDependencies.xml] ( https://github.com/googlesamples/unity-jar-resolver/blob/master/sample/Assets/ExternalDependencyManager/Editor/SampleDependencies.xml )
404
+ file into your plugin and add the dependencies your plugin requires.
405
+
380
406
The XML file just needs to be under an ` Editor ` directory and match the
381
407
name ` *Dependencies.xml ` . For example,
382
408
` MyPlugin/Editor/MyPluginDependencies.xml ` .
@@ -419,18 +445,195 @@ private static void PostProcessBuild_iOS(BuildTarget target, string buildPath)
419
445
{
420
446
421
447
using (StreamWriter sw = File.AppendText(buildPath + "/Podfile"))
422
- {
448
+ {
423
449
//in this example I'm adding an app extension
424
450
sw.WriteLine("\ntarget 'NSExtension' do\n pod 'Firebase/Messaging', '6.6.0'\nend");
425
451
}
426
452
}
427
453
}
428
454
```
455
+
456
+ # Unity Package Manager Resolver Usage
457
+
458
+ Adding registries to the
459
+ [ Unity Package Manager] ( https://docs.unity3d.com/Manual/Packages.html )
460
+ (UPM) is a manual process. The Unity Package Manager Resolver (UPMR) component
461
+ of this plugin makes it easy for plugin maintainers to distribute new UPM
462
+ registry servers and easy for plugin users to manage UPM registry servers.
463
+
464
+ ## Adding Registries
465
+
466
+ 1 . Add the ` external-dependency-manager-*.unitypackage ` to your plugin
467
+ project (assuming you are developing a plugin). If you are redistributing
468
+ EDM4U with your plugin, you ** must** follow the
469
+ import steps in the [ Getting Started] ( #getting-started ) section!
470
+
471
+ 2 . Copy and rename the
472
+ [ SampleRegistries.xml] ( https://github.com/googlesamples/unity-jar-resolver/blob/master/sample/Assets/ExternalDependencyManager/Editor/sample/Assets/ExternalDependencyManager/Editor/SampleRegistries.xml )
473
+ file into your plugin and add the registries your plugin requires.
474
+
475
+ The XML file just needs to be under an ` Editor ` directory and match the
476
+ name ` *Registries.xml ` or labeled with ` gumpr_registries ` . For example,
477
+ ` MyPlugin/Editor/MyPluginRegistries.xml ` .
478
+
479
+ 3 . Follow the steps in the [ Getting Started] ( #getting-started )
480
+ section when you are exporting your plugin package.
481
+
482
+ For example, to add a registry for plugins in the scope ` com.coolstuff ` :
483
+
484
+ ```
485
+ <registries>
486
+ <registry name="Cool Stuff"
487
+ url="https://unityregistry.coolstuff.com"
488
+ termsOfService="https://coolstuff.com/unityregistry/terms"
489
+ privacyPolicy="https://coolstuff.com/unityregistry/privacy">
490
+ <scopes>
491
+ <scope>com.coolstuff</scope>
492
+ </scopes>
493
+ </registry>
494
+ </registries>
495
+ ```
496
+
497
+ When UPMR is loaded it will prompt the developer to add the registry to their
498
+ project if it isn't already present in the ` Packages/manifest.json ` file.
499
+
500
+ For more information, see Unity's documentation on
501
+ [ scoped package registries] ( https://docs.unity3d.com/Manual/upm-scoped.html ) .
502
+
503
+ ## Managing Registries
504
+
505
+ It's possible to add and remove registries that are specified via UPMR
506
+ XML configuration files via the following menu options:
507
+
508
+ * `Assets > External Dependency Manager > Unity Package Manager Resolver >
509
+ Add Registries` will prompt the user with a window which allows them to
510
+ add registries discovered in the project to the Unity Package Manager.
511
+ * `Assets > External Dependency Manager > Unity Package Manager Resolver >
512
+ Remove Registries` will prompt the user with a window which allows them to
513
+ remove registries discovered in the project from the Unity Package Manager.
514
+ * `Assets > External Dependency Manager > Unity Package Manager Resolver >
515
+ Modify Registries` will prompt the user with a window which allows them to
516
+ add or remove registries discovered in the project.
517
+
518
+ ## Configuration
519
+
520
+ UPMR can be configured via the `Assets > External Dependency Manager >
521
+ Unity Package Manager Resolver > Settings` menu option:
522
+
523
+ * ` Add package registries ` when enabled, when the plugin loads or registry
524
+ configuration files change, this will prompt the user to add registries
525
+ that are not present in the Unity Package Manager.
526
+ * ` Prompt to add package registries ` will cause a developer to be prompted
527
+ with a window that will ask for confirmation before adding registries.
528
+ When this is disabled registries are added silently to the project.
529
+ * ` Enable Analytics Reporting ` when enabled, reports the use of the plugin
530
+ to the developers so they can make imrpovements.
531
+ * ` Verbose logging ` when enabled prints debug information to the console
532
+ which can be useful when filing bug reports.
533
+
429
534
# Version Handler Usage
430
535
431
536
The Version Handler component of this plugin manages:
537
+
432
538
* Shared Unity plugin dependencies.
433
539
* Upgrading Unity plugins by cleaning up old files from previous versions.
540
+ * Uninstallation of plugins that are distributed with manifest files.
541
+ * Restoration of plugin assets to their original install locations if assets
542
+ are tagged with the ` exportpath ` label.
543
+
544
+ Since the Version Handler needs to modify Unity asset metadata (` .meta ` files),
545
+ to enable / disable components, rename and delete asset files it does not
546
+ work with Unity Package Manager installed packages. It's still possible to
547
+ include EDM4U in Unity Package Manager packages, the Version Handler component
548
+ simply won't do anything to UPM plugins in this case.
549
+
550
+ ## Using Version Handler Managed Plugins
551
+
552
+ If a plugin is imported at multiple different versions into a project, if
553
+ the Version Handler is enabled, it will automatically check all managed
554
+ assets to determine the set of assets that are out of date and assets that
555
+ should be removed. To disable automatic checking managed assets disable
556
+ the ` Enable version management ` option in the
557
+ ` Assets > External Dependency Manager > Version Handler > Settings ` menu.
558
+
559
+ If version management is disabled, it's possible to check managed assets
560
+ manually using the
561
+ ` Assets > External Dependency Manager > Version Handler > Update ` menu option.
562
+
563
+ ### Listing Managed Plugins
564
+
565
+ Plugins managed by the Version Handler, those that ship with manifest files,
566
+ can displayed using the `Assets > External Dependency Manager >
567
+ Version Handler > Display Managed Packages` menu option. The list of plugins
568
+ are written to the console window along with the set of files used by each
569
+ plugin.
570
+
571
+ ### Uninstalling Managed Plugins
572
+
573
+ Plugins managed by the Version Handler, those that ship with manifest files,
574
+ can be removed using the `Assets > External Dependency Manager >
575
+ Version Handler > Uninstall Managed Packages` menu option. This operation
576
+ will display a window that allows a developer to select a set of plugins to
577
+ remove which will remove all files owned by each plugin excluding those that
578
+ are in use by other installed plugins.
579
+
580
+ Files managed by the Version Handler, those labeled with the ` gvh ` asset label,
581
+ can be checked to see whether anything needs to be upgraded, disabled or
582
+ removed using the `Assets > External Dependency Manager >
583
+ Version Handler > Update` menu option.
584
+
585
+ ### Restore Install Paths
586
+
587
+ Some developers move assets around in their project which can make it
588
+ harder for plugin maintainers to debug issues if this breaks Unity's
589
+ [ special folders] ( https://docs.unity3d.com/Manual/SpecialFolders.html ) rules.
590
+ If assets are labeled with their original install / export path
591
+ (see ` gvhp_exportpath ` below), Version Handler can restore assets to their
592
+ original locations when using the `Assets > External Dependency Manager >
593
+ Version Handler > Move Files To Install Locations` menu option.
594
+
595
+ ### Settings
596
+
597
+ Some behavior of the Version Handler can be configured via the
598
+ ` Assets > External Dependency Manager > Version Handler > Settings ` menu
599
+ option.
600
+
601
+ * ` Enable version management ` controls whether the plugin should automatically
602
+ check asset versions and apply changes. If this is disabled the process
603
+ should be run manually when installing or upgrading managed plugins using
604
+ ` Assets > External Dependency Manager > Version Handler > Update ` .
605
+ * ` Rename to canonical filenames ` is a legacy option that will rename files to
606
+ remove version numbers and other labels from filenames.
607
+ * ` Prompt for obsolete file deletion ` enables the display of a window when
608
+ obsolete files are deleted allowing the developer to select which files to
609
+ delete and those to keep.
610
+ * ` Allow disabling files via renaming ` controls whether obsolete or disabled
611
+ files should be disabled by renaming them to ` myfilename_DISABLED ` .
612
+ Renaming to disable files is required in some scenarios where Unity doesn't
613
+ support removing files from the build via the PluginImporter.
614
+ * ` Enable Analytics Reporting ` enables / disables usage reporting to plugin
615
+ developers to improve the product.
616
+ * ` Verbose logging ` enables _ very_ noisy log output that is useful for
617
+ debugging while filing a bug report or building a new managed plugin.
618
+ * ` Use project settings ` saves settings for the plugin in the project rather
619
+ than system-wide.
620
+
621
+ ## Redistributing a Managed Plugin
622
+
623
+ The Version Handler employs a couple of methods for managing version
624
+ selection, upgrade and removal of plugins.
625
+
626
+ * Each plugin can ship with a manifest file that lists the files it includes.
627
+ This makes it possible for Version Handler to calculate the difference
628
+ in assets between the most recent release of a plugin and the previous
629
+ release installed in a project. If a files are removed the Version Handler
630
+ will prompt the user to clean up obsolete files.
631
+ * Plugins can ship using assets with unique names, unique GUIDs and version
632
+ number labels. Version numbers can be attached to assets using labels or
633
+ added to the filename (e.g ` myfile.txt ` would be `myfile_version-x.y.z.txt).
634
+ This allows the Version Handler to determine which set of files are the
635
+ same file at different versions, select the most recent version and prompt
636
+ the developer to clean up old versions.
434
637
435
638
Unity plugins can be managed by the Version Handler using the following steps:
436
639
@@ -474,7 +677,7 @@ If you follow these steps:
474
677
multiple packages that include your plugin, assuming the steps in
475
678
[ Plugin Redistribution] ( #plugin-redistribution ) are followed.
476
679
477
- ## Building from Source
680
+ # Building from Source
478
681
479
682
To build this plugin from source you need the following tools installed:
480
683
* Unity (with iOS and Android modules installed)
@@ -492,7 +695,7 @@ or Windows:
492
695
./gradlew.bat build
493
696
```
494
697
495
- ### Releasing
698
+ # Releasing
496
699
497
700
Each time a new build of this plugin is checked into the source tree you
498
701
need to do the following:
0 commit comments