Example #1
0
    public UnityEngine.Object Load(string name)
    {
        string fullPath;

        if (m_fileName2path.ContainsKey(name))
        {
            fullPath = m_fileName2path[name].FullName;//Path.Combine( Path.Combine(m_path, path),name);
        }
        else if (m_fileNameAndExt2path.ContainsKey(name))
        {
            fullPath = m_fileNameAndExt2path[name].FullName;
        }
        else
        {
            return(null);
        }



        using (BufferedStream myBS = new BufferedStream(new FileStream(fullPath, FileMode.Open)))
        {
            int    len   = (int)myBS.Length;
            byte[] bytes = new byte[len];

            myBS.Read(bytes, 0, len);
            myBS.Close();

            BinAsset re = new BinAsset(bytes);

            return(re);
        }
    }
Example #2
0
 public UnityEngine.Object Load(string path, FileSystem.RES_LOCATION resLocation = FileSystem.RES_LOCATION.auto)
 {
     foreach (IPacket curr in m_packets)
     {
         if (resLocation != FileSystem.RES_LOCATION.auto && curr.ResLocation != resLocation)
         {
             continue;                                                                                //资源所在的域不对
         }
         UnityEngine.Object re       = curr.Load(path);
         BinAsset           binAsset = re as BinAsset;
         if (binAsset != null || re != null)
         {
             return(re);
         }
     }
     return(null);
 }
Example #3
0
    byte[] GetBytesFromPacketFile(UnityEngine.Object file)
    {
        TextAsset textAsset = file as TextAsset;

        if (textAsset != null)
        {
            return(textAsset.bytes);
        }
        else
        {
            BinAsset bin = (BinAsset)file;
            if (bin == null)
            {
                return(null);
            }

            return(bin.bytes);
        }
    }