Пример #1
0
 public void LoadScene(object key)
 {
     isLoading = true;
     if (handle.IsValid())
     {
         Addressables.Release(handle);
     }
     Fade.Instance().Play(Fade.Mode.Out, Color.black, new Color(0.0f, 0.0f, 0.0f, 0.0f), action: () => {
         handle            = Addressables.LoadSceneAsync(key);
         handle.Completed += Handle_Completed;
     });
 }
 public void Init(ResourceManager rm, IResourceProvider provider, IResourceLocation location, AsyncOperationHandle <IList <AsyncOperationHandle> > depOp, bool releaseDependenciesOnFailure)
 {
     m_DownloadStatus  = default;
     m_ResourceManager = rm;
     m_DepOp           = depOp;
     if (m_DepOp.IsValid())
     {
         m_DepOp.Acquire();
     }
     m_Provider = provider;
     m_Location = location;
     m_ReleaseDependenciesOnFailure = releaseDependenciesOnFailure;
     SetWaitForCompletionCallback(WaitForCompletionHandler);
 }
Пример #3
0
 internal void Start(ResourceManager rm, AsyncOperationHandle dependency, DelegateList <float> updateCallbacks)
 {
     m_RM = rm;
     m_RM.PostDiagnosticEvent(new AsyncOperationHandle(this), ResourceManager.DiagnosticEventType.AsyncOperationCreate);
     m_RM.PostDiagnosticEvent(new AsyncOperationHandle(this), ResourceManager.DiagnosticEventType.AsyncOperationPercentComplete, 0);
     IncrementReferenceCount(); // keep a reference until the operation completes
     m_UpdateCallbacks = updateCallbacks;
     if (dependency.IsValid() && !dependency.IsDone)
     {
         dependency.Completed += m_dependencyCompleteAction;
     }
     else
     {
         InvokeExecute();
     }
 }
 static int IsValid(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <object> obj = (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <object>)ToLua.CheckObject(L, 1, typeof(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <object>));
         bool o = obj.IsValid();
         LuaDLL.lua_pushboolean(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 ///<inheritdoc />
 protected override bool InvokeWaitForCompletion()
 {
     if (IsDone)
     {
         return(true);
     }
     if (m_DepOp.IsValid() && !m_DepOp.IsDone)
     {
         m_DepOp.WaitForCompletion();
     }
     if (m_WaitForCompletionCallback == null)
     {
         return(false);
     }
     m_RM?.Update(Time.deltaTime);
     if (!HasExecuted)
     {
         InvokeExecute();
     }
     return(m_WaitForCompletionCallback.Invoke());
 }
Пример #6
0
        internal override DownloadStatus GetDownloadStatus(HashSet <object> visited)
        {
            var depDLS = m_DepOp.IsValid() ? m_DepOp.InternalGetDownloadStatus(visited) : default;

            if (m_GetDownloadProgressCallback != null)
            {
                m_DownloadStatus = m_GetDownloadProgressCallback();
            }
            else if (IsDone)
            {
                m_DownloadStatus.DownloadedBytes = m_DownloadStatus.TotalBytes;
            }

            if (IsDone)
            {
                m_DownloadStatus.DownloadedBytes = m_DownloadStatus.TotalBytes;
            }

            return(new DownloadStatus()
            {
                DownloadedBytes = m_DownloadStatus.DownloadedBytes + depDLS.DownloadedBytes, TotalBytes = m_DownloadStatus.TotalBytes + depDLS.TotalBytes, IsDone = IsDone
            });
        }