A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.unity3d.com/Manual/sprite/../../ScriptReference/PackageManager.Events.html below:

Unity - Scripting API: Events

Events

class in UnityEditor.PackageManager

Suggest a change Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion*

Cancel

Switch to Manual Description

An interface for accessing the package manager events. Use these events to monitor package changes in your Unity project.

The registeringPackages event fires before any package changes occur. The registeredPackages event fires after all changes are complete. Both events provide a PackageRegistrationEventArgs parameter which contains details about the changes. Events are usually reset during domain reloads, so register your handlers using [InitializeOnLoad].

using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;

[InitializeOnLoad] public class PackageChangeMonitor { static PackageChangeMonitor() { // Register for package change events Events.registeringPackages += OnPackagesRegistering; Events.registeredPackages += OnPackagesRegistered; }

private static void OnPackagesRegistering(PackageRegistrationEventArgs args) { // Called before packages are changed if (args.added.Count > 0) Debug.Log($"About to add {args.added.Count} packages"); if (args.removed.Count > 0) Debug.Log($"About to remove {args.removed.Count} packages"); }

private static void OnPackagesRegistered(PackageRegistrationEventArgs args) { // Called after packages have changed foreach (var package in args.added) Debug.Log($"Added package: {package.name} ({package.version})"); foreach (var package in args.removed) Debug.Log($"Removed package: {package.name}"); } }

Events Event Description registeredPackages Event raised after applying changes to the registered packages list. registeringPackages Event raised before applying changes to the registered packages list.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4