Example #1
0
    // load raw file
    public static byte[] LoadRaw(string relativePath)
    {
#if ASSETBUNDLE
        if (dependence_ == null)
        {
            LoadDependence();
            // preload bundles
            LoadDefault();
        }
        return(AutherFile.GetData(relativePath));
#else
        string path = UIPathManager.GetStreamPath() + relativePath;
        if (File.Exists(path))
        {
            FileStream fs     = File.OpenRead(path);
            int        length = (int)fs.Length;
            byte[]     data   = new byte[length];
            fs.Read(data, 0, length);
            fs.Close();
            return(data);
        }
        else
        {
            return(null);
        }
#endif
    }
Example #2
0
    private static void LoadDependence()
    {
#if ASSETBUNDLE
        dependence_bundle_ = LoadBundle("assetbundles");
        dependence_        = dependence_bundle_.LoadAsset <AssetBundleManifest>("assetbundlemanifest");

        byte[]       dependency = AutherFile.GetData("asset_dependency");
        MemoryStream se         = new MemoryStream(dependency);
        StreamReader sr         = new StreamReader(se);

        string[] list;
        string   assetBundleName = string.Empty;
        string   s = sr.ReadLine();
        while (s != null)
        {
            if (s[0] != '\t')
            {
                assetBundleName = s;
            }
            else
            {
                list = s.Substring(1).Split('|');  //assetName|ext
                if (list.Length == 2)
                {
                    AssetNameNode asset_node = new AssetNameNode();
                    asset_node.name_        = list[0] + list[1];
                    asset_node.bundle_name_ = assetBundleName;
                    asset_dependence_.Add(list[0], asset_node);
                }
            }
            s = sr.ReadLine();
        }
        se.Close();
        sr.Close();
#endif
    }