Esempio n. 1
0
 private void RegisterForCallbacks()
 {
     if (CallbackHooksEnabled && m_CallbackHooks == null)
     {
         m_CallbackHooks = new GameObject("ResourceManagerCallbacks", typeof(MonoBehaviourCallbackHooks)).GetComponent <MonoBehaviourCallbackHooks>();
         m_CallbackHooks.OnUpdateDelegate += Update;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Disposes internal resources used by the resource manager
 /// </summary>
 public void Dispose()
 {
     if (m_CallbackHooks != null)
     {
         GameObject.Destroy(m_CallbackHooks.gameObject);
     }
     m_CallbackHooks = null;
 }
    public void InitializationObjects_OperationRegistersForCallbacks()
    {
        if (m_RuntimeSettingsPath.StartsWith("GUID:"))
        {
            Debug.Log($"{nameof(InitializationObjects_OperationRegistersForCallbacks)} skipped due to not having a runtime settings asset (Fast mode does not create this).");
            return;
        }
        //We're checking to make sure we've created a new ResourceManagerCallbacks object.  If this isn't null
        //then we won't create a new one.  This would never be needed in a legitimate scenario.
        MonoBehaviourCallbackHooks.DestroySingleton();
        int startCount = Resources.FindObjectsOfTypeAll <MonoBehaviourCallbackHooks>().Length;

        InitalizationObjectsOperation op = new InitalizationObjectsOperation();
        var runtimeDataLocation          = new ResourceLocationBase("RuntimeData", m_RuntimeSettingsPath, typeof(JsonAssetProvider).FullName, typeof(ResourceManagerRuntimeData));
        var rtdOp = m_Addressables.ResourceManager.ProvideResource <ResourceManagerRuntimeData>(runtimeDataLocation);

        //Test
        op.Init(rtdOp, m_Addressables);
        int endCount = Resources.FindObjectsOfTypeAll <MonoBehaviourCallbackHooks>().Length;

        //Assert
        Assert.AreEqual(startCount, endCount);
    }