void OnDriverReady() { // Act as a middle-man, hooking up update events from the driver to the UI drawer ContentManagerDriver.SubscribeStatusCallback(OnContentPacksLoaded); ContentManagerDriver.SubscribeChangeCallback(m_Drawer.RefreshContentView); // Likewise, ensure any buttons drawn by the Content Manager window send messages to the driver m_Drawer.Init(rootVisualElement, OnContentWindowSizeChanged, OnContentProductChanged, OnContentFilterChanged, ContentManagerDriver.InstallContent, ContentManagerDriver.InstallContent, ContentManagerDriver.UninstallContent, ContentManagerDriver.CancelContentAction, OnContentSelect, m_ActivePack, m_ActiveFilter, m_ActiveProduct); ContentManagerDriver.UpdateContentStatus(); }
void OnDisable() { if (m_ContentManagerDriver != null) { ContentManagerDriver.UnsubscribeStatusCallback(OnContentPacksLoaded); ContentManagerDriver.UnsubscribeChangeCallback(m_Drawer.RefreshContentView); } m_Drawer?.Deinit(); m_ContentManagerDriver = null; }
void OnEnable() { if (m_ContentManagerDriver != null) { return; } m_ContentManagerDriver = ContentManagerDriver.Instance; if (m_ContentManagerDriver != null) { OnDriverReady(); } }
static void Initialize() { var result = "Initialize: "; // Cache the path to the library s_CachedPackagePath = $"{Path.GetDirectoryName(Application.dataPath)?.ToLower()}{Path.DirectorySeparatorChar}library"; if (s_Instance != null) { result += "Duplicate"; ConditionalLog(result); return; } if (s_Instance == null) { result += " Instance not set, searching."; s_Instance = Resources.FindObjectsOfTypeAll <ContentManagerDriver>().FirstOrDefault(); } if (s_Instance == null) { result += " Instance not found, creating."; s_Instance = CreateInstance <ContentManagerDriver>(); } s_CurrentEvent = null; s_StatusRequested = false; s_StatusInitialized = false; SubscribeStatusCallback(LogStatusResult); SubscribeInstallCallback(LogInstallResult); SubscribeUninstallCallback(LogUninstallResult); // Is there any queued events? Start a status update which will kick off events again if (s_Instance.m_QueuedEvents.Count > 0) { result += " Events already enqueue - updated status."; UpdateContentStatus(); } ConditionalLog(result); }