示例#1
0
    private void LoadBundlesFiles()
    {
        // Set empty, but valid, state. This way we work OK even when indicated directory is not valid.
        bundlesFiles = new string[] { };
        bundles      = new AssetBundleLoader[] { };

        string dir = LocalConfig.GetBundlesDirectory();

        try {
            bundlesFiles = Directory.GetFiles(dir, "*" + bundleFileSuffix);
        } catch (Exception e) {
            Debug.LogWarning("Cannot read directory \"" + dir + "\":" + e.Message);
            return;
        }
        if (bundlesFiles.Length == 0)
        {
            Debug.LogWarning("No asset bundles found in directory \"" + dir + "\". On PC, make sure to set correct BundlesDirectory in LocalConfig in Assets/Resources/LocalConfig.asset. On Hololens, make sure to upload the bundles using the device portal.");
            return;
        }

        // success, we found asset bundles
        Debug.Log("Found " + bundlesFiles.Length.ToString() + " asset bundles in \"" + dir + "\".");
        bundles = new AssetBundleLoader[bundlesFiles.Length];
        for (int i = 0; i < bundles.Length; i++)
        {
            bundles[i] = new AssetBundleLoader(BundleName(i), bundlesFiles[i]);
        }
    }
示例#2
0
    private void LoadBundlesFiles()
    {
        // Set empty, but valid, state. This way we work OK even when indicated directory is not valid.
        bundlesFiles = new string[] { };
        bundles      = new AssetBundleLoader[] { };

        LocalConfig localConfig = Resources.Load <LocalConfig>("LocalConfig");

        if (localConfig == null || string.IsNullOrEmpty(localConfig.GetBundlesDirectory()))
        {
            Debug.LogWarning("No \"Assets/Resources/LocalConfig.asset\", or \"BundlesDirectory\" not set. Create LocalConfig.asset from Unity Editor by \"Holo -> Create Local Configuration\"");
            return;
        }

        string dir = localConfig.GetBundlesDirectory();

        try {
            bundlesFiles = Directory.GetFiles(dir, "*" + bundleFileSuffix);
        } catch (Exception e) {
            Debug.LogWarning("Cannot read directory \"" + dir + "\":" + e.Message);
            return;
        }
        if (bundlesFiles.Length == 0)
        {
            Debug.LogWarning("No asset bundles found in directory \"" + dir + "\". Make sure to set correct BundlesDirectory in LocalConfig in Assets/Resources/LocalConfig.asset.");
            return;
        }

        // success, we found asset bundles
        Debug.Log("Found " + bundlesFiles.Length.ToString() + " asset bundles in \"" + dir + "\".");
        bundles = new AssetBundleLoader[bundlesFiles.Length];
        for (int i = 0; i < bundles.Length; i++)
        {
            bundles[i] = new AssetBundleLoader(BundleName(i), bundlesFiles[i]);
        }
    }
示例#3
0
 public void LoadRawDataFromFile(string filePath)
 {
     SetSizes();
     if (File.Exists(filePath))
     {
         LocalConfig localConfig = Resources.Load <LocalConfig>("LocalConfig");
         string      dir         = localConfig.GetBundlesDirectory();
         Debug.Log("Going to load micro data [size: " + size * 2 + "] from: " + filePath);
         var          s     = new FileStream(filePath, FileMode.Open);
         BinaryReader br    = new BinaryReader(s);
         var          bytes = br.ReadBytes(size * 2);
         Debug.Log("Bytes read: " + bytes.Length);
         SetRawBytes(bytes);
         br.Dispose();
     }
 }