Exemplo n.º 1
0
 public void LoadToAsync()
 {
     if (toAsync)
     {
         state = ESourceState.Loading;
         var request = AssetBundle.LoadFromFileAsync(assetPath);
         request.completed += OnCreateRequest;
     }
     else
     {
         state     = ESourceState.Loading;
         bundle    = AssetBundle.LoadFromFile(assetPath);
         allAssets = bundle.LoadAllAssets();
         if (allAssets.Length > 0)
         {
             mainAsset = allAssets[0];
         }
         state = ESourceState.Loaded;
         for (int i = 0; i < m_mainCompleteEventHandlers.Count; i++)
         {
             m_mainCompleteEventHandlers[i](mainAsset);
         }
         m_mainCompleteEventHandlers.Clear();
         for (int i = 0; i < m_allCompleteEventHandlers.Count; i++)
         {
             m_allCompleteEventHandlers[i](allAssets);
         }
         m_allCompleteEventHandlers.Clear();
     }
 }
Exemplo n.º 2
0
 public void Reset()
 {
     state = ESourceState.None;
     m_allCompleteEventHandlers.Clear();
     assetPath = null;
     toAsync   = false;
 }
Exemplo n.º 3
0
 public void LoadAllAsset()
 {
     state     = ESourceState.Loading;
     bundle    = AssetBundle.LoadFromFile(assetPath);
     allAssets = bundle.LoadAllAssets();
     if (allAssets.Length > 0)
     {
         mainAsset = allAssets[0];
     }
     state = ESourceState.Loaded;
 }
Exemplo n.º 4
0
        private void OnBundleRequest(AsyncOperation async)
        {
            var request = (AssetBundleRequest)async;

            UnityEngine.Object obj = request.asset;
            mainAsset = obj;
            allAssets = request.allAssets;
            state     = ESourceState.Loaded;
            for (int i = 0; i < m_mainCompleteEventHandlers.Count; i++)
            {
                m_mainCompleteEventHandlers[i](mainAsset);
            }
            m_mainCompleteEventHandlers.Clear();
            for (int i = 0; i < m_allCompleteEventHandlers.Count; i++)
            {
                m_allCompleteEventHandlers[i](allAssets);
            }
            m_allCompleteEventHandlers.Clear();
        }
Exemplo n.º 5
0
 internal StateEventArgs(ESourceState SubjectState = ESourceState.Stable, Exception Exception = null)
 {
     this.Exception    = Exception;
     this.SubjectState = SubjectState;
 }
Exemplo n.º 6
0
 internal StateEventArgs(T Subject, ESourceState SubjectState = ESourceState.Stable, Exception Exception = null) : base(SubjectState, Exception)
 {
     this.Subject = Subject;
 }
Exemplo n.º 7
0
 private void OnStateChanged(ESourceState state)
 {
     State = state;
     OnStateChanged();
 }
Exemplo n.º 8
0
 private void OnStateChanged(ESourceState state)
 {
     State = state;
     OnStateChanged();
 }