public void Clear([CanBeNull] IUIResourceConsumer resourceConsumer = null) { MonoBehaviour monoBehaviour = Main.monoBehaviour; if (null == monoBehaviour) { throw new Exception(); } if (m_coroutine != null) { monoBehaviour.StopCoroutine(m_coroutine); m_coroutine = null; } if (loadState == UIResourceLoadState.Loading && m_pendingBundleName.Length != 0) { AssetManager.UnloadAssetBundle(m_pendingBundleName); m_pendingBundleName = string.Empty; } if (m_resourceConsumer != null) { m_resourceConsumer.UnRegister(this); } UIResourceDisplayMode displayMode = resourceConsumer?.Register(this) ?? UIResourceDisplayMode.None; m_resourceConsumer = resourceConsumer; m_coroutine = MonoBehaviourExtensions.StartCoroutineImmediate(monoBehaviour, Clear(displayMode)); }
public void Setup(AssetReference assetReference, [NotNull] string bundleName, [CanBeNull] IUIResourceConsumer resourceConsumer = null) { MonoBehaviour monoBehaviour = Main.monoBehaviour; if (null == monoBehaviour) { throw new Exception(); } if (m_coroutine != null) { monoBehaviour.StopCoroutine(m_coroutine); m_coroutine = null; } if (loadState == UIResourceLoadState.Loading && m_pendingBundleName.Length != 0) { AssetManager.UnloadAssetBundle(m_pendingBundleName); m_pendingBundleName = string.Empty; } if (m_resourceConsumer != null) { m_resourceConsumer.UnRegister(this); } UIResourceDisplayMode displayMode = resourceConsumer?.Register(this) ?? UIResourceDisplayMode.None; m_resourceConsumer = resourceConsumer; if (!assetReference.get_hasValue()) { m_coroutine = MonoBehaviourExtensions.StartCoroutineImmediate(monoBehaviour, Clear(displayMode)); return; } if (string.IsNullOrEmpty(bundleName)) { throw new ArgumentException("The bundle name must be a non-null non-empty string.", "bundleName"); } m_pendingBundleName = bundleName; m_coroutine = MonoBehaviourExtensions.StartCoroutineImmediate(monoBehaviour, Load(assetReference.get_value(), bundleName, displayMode)); }