Exemplo n.º 1
0
 public void LoadFromAssetBundle(CResourcePackerInfo resourcePackerInfo)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
     }
     else
     {
         string name   = this.m_name;
         string rename = resourcePackerInfo.GetRename(this.m_fullPathInResourcesWithoutExtension);
         if (!string.IsNullOrEmpty(rename))
         {
             name = CFileManager.GetFullName(rename);
         }
         if (this.m_contentType == null)
         {
             this.m_content = resourcePackerInfo.m_assetBundle.Load(name);
         }
         else
         {
             this.m_content = resourcePackerInfo.m_assetBundle.Load(name, this.m_contentType);
         }
         this.m_state = enResourceState.Loaded;
         if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset)))
         {
             CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>();
             obj2.m_data    = (this.m_content as TextAsset).bytes;
             this.m_content = obj2;
         }
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// 从AssetBundle中加载资源
    /// </summary>
    /// <param name="resourcePackerInfo">AB资源包信息</param>
    public void LoadFromAssetBundle(ResourcePackerInfo resourcePackerInfo)
    {
        if (m_isAbandon)
        {
            m_state = enResourceState.Unload;
            return;
        }
        string name = FileManager.EraseExtension(m_name);;

        if (m_contentType == null)
        {
            m_content = resourcePackerInfo.assetBundle.LoadAsset(name);
        }
        else
        {
            m_content = resourcePackerInfo.assetBundle.LoadAsset(name, m_contentType);
        }
        m_state = enResourceState.Loaded;
        if (m_content != null && m_content.GetType() == typeof(TextAsset))
        {
            BinaryObject binaryObject = ScriptableObject.CreateInstance <BinaryObject>();
            binaryObject.data = (m_content as TextAsset).bytes;
            m_content         = binaryObject;
        }
    }
Exemplo n.º 3
0
 public void Load()
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
     }
     else
     {
         if (this.m_contentType == null)
         {
             this.m_content = Resources.Load(CFileManager.EraseExtension(this.m_fullPathInResources));
         }
         else
         {
             this.m_content = Resources.Load(CFileManager.EraseExtension(this.m_fullPathInResources), this.m_contentType);
         }
         this.m_state = enResourceState.Loaded;
         if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset)))
         {
             CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>();
             obj2.m_data    = (this.m_content as TextAsset).bytes;
             this.m_content = obj2;
         }
     }
 }
Exemplo n.º 4
0
 public void Load(AssetBundle assetBundle)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
     }
     else
     {
         string name = this.m_name;
         if (this.m_contentType == null)
         {
             this.m_content = assetBundle.Load(name);
         }
         else
         {
             this.m_content = assetBundle.Load(name, this.m_contentType);
         }
         this.m_state = enResourceState.Loaded;
         if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset)))
         {
             CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>();
             obj2.m_data    = (this.m_content as TextAsset).bytes;
             this.m_content = obj2;
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 卸载资源
 /// </summary>
 public void Unload()
 {
     if (m_state == enResourceState.Loaded)
     {
         m_content = null;
         m_state   = enResourceState.Unload;
     }
     else if (m_state == enResourceState.Loading)
     {
         m_isAbandon = true;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="keyHash">键索引</param>
 /// <param name="fullPathInResources">资源在Resource文件夹下完整路径</param>
 /// <param name="contentType">数据类型</param>
 /// <param name="resourceType">资源类型</param>
 /// <param name="unloadBelongedAssetBundleAfterLoaded"></param>
 public ResourceBase(int keyHash, string fullPathInResources, Type contentType, enResourceType resourceType, bool unloadBelongedAssetBundleAfterLoaded)
 {
     this.m_key = keyHash;
     this.m_fullPathInResources = fullPathInResources;
     this.m_fullPathInResourcesWithoutExtension = FileManager.EraseExtension(this.m_fullPathInResources);
     this.m_name         = FileManager.EraseExtension(FileManager.GetFullName(fullPathInResources));
     this.m_resourceType = resourceType;
     this.m_state        = enResourceState.Unload;
     this.m_contentType  = contentType;
     this.m_unloadBelongedAssetBundleAfterLoaded = unloadBelongedAssetBundleAfterLoaded;
     this.m_content   = null;
     this.m_isAbandon = false;
 }
Exemplo n.º 7
0
 /// <summary>
 /// 用C#IO流读取文件资源
 /// </summary>
 /// <param name="ifsExtractPath">文件路径,ifsExtractPath + m_fileFullPathInResources等于文件完整路径</param>
 public void Load(string ifsExtractPath)
 {
     if (m_isAbandon)
     {
         m_state = enResourceState.Unload;
         return;
     }
     byte[] array = FileManager.ReadFile(FileManager.CombinePath(ifsExtractPath, m_fileFullPathInResources));
     m_state = enResourceState.Loaded;
     if (array != null)
     {
         BinaryObject binaryObject = ScriptableObject.CreateInstance <BinaryObject>();
         binaryObject.data = array;
         binaryObject.name = m_name;
         m_content         = binaryObject;
     }
 }
Exemplo n.º 8
0
 public void Load(string ifsExtractPath)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
         return;
     }
     byte[] array = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources));
     this.m_state = enResourceState.Loaded;
     if (array != null)
     {
         CBinaryObject cBinaryObject = ScriptableObject.CreateInstance <CBinaryObject>();
         cBinaryObject.m_data = array;
         cBinaryObject.name   = this.m_name;
         this.m_content       = cBinaryObject;
     }
 }
Exemplo n.º 9
0
 public void Load(string ifsExtractPath)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
     }
     else
     {
         byte[] buffer = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources));
         this.m_state = enResourceState.Loaded;
         if (buffer != null)
         {
             CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>();
             obj2.m_data    = buffer;
             obj2.name      = this.m_name;
             this.m_content = obj2;
         }
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// 用Unity的API加载Resouces中的资源
 /// </summary>
 public void Load()
 {
     if (m_isAbandon)
     {
         m_state = enResourceState.Unload;
         return;
     }
     if (m_contentType == null)
     {
         m_content = Resources.Load(m_fullPathInResourcesWithoutExtension);
     }
     else
     {
         m_content = Resources.Load(m_fullPathInResourcesWithoutExtension, m_contentType);
     }
     m_state = enResourceState.Loaded;
     if (m_content != null && m_content.GetType() == typeof(TextAsset))
     {
         BinaryObject binaryObject = ScriptableObject.CreateInstance <BinaryObject>();
         binaryObject.data = (m_content as TextAsset).bytes;
         m_content         = binaryObject;
     }
 }