Beispiel #1
0
        internal static List <SceneBundleHandle> LoadSceneBundles(string mainBundlePath, NativeArray <Entities.Hash128> sharedBundles, bool blocking)
        {
            var bundles = new List <SceneBundleHandle>();

            if (sharedBundles.IsCreated)
            {
                for (int i = 0; i < sharedBundles.Length; i++)
                {
                    var path = $"{Application.streamingAssetsPath}/{EntityScenesPaths.RelativePathFolderFor(sharedBundles[i], EntityScenesPaths.PathType.EntitiesSharedReferencesBundle, -1)}";
                    bundles.Add(CreateOrRetainBundle(path));
                }
                sharedBundles.Dispose();
            }

            if (!string.IsNullOrEmpty(mainBundlePath))
            {
                bundles.Insert(0, CreateOrRetainBundle(mainBundlePath));
            }

            if (blocking)
            {
                foreach (var b in bundles)
                {
                    var forceLoad = b.AssetBundle;
                    if (forceLoad == null)
                    {
                        Debug.LogWarning($"Failed to load asset bundle at path {b._bundlePath}");
                    }
                }
            }
            return(bundles);
        }
Beispiel #2
0
        internal static SceneBundleHandle[] LoadSceneBundles(string mainBundlePath, NativeArray <Entities.Hash128> sharedBundles, bool blocking)
        {
            var hasMainBundle = !string.IsNullOrEmpty(mainBundlePath);
            var bundles       = new SceneBundleHandle[sharedBundles.Length + (hasMainBundle ? 1 : 0)];

            if (hasMainBundle)
            {
                LogBundle($"Request main bundle {mainBundlePath}");
            }

            if (sharedBundles.IsCreated)
            {
                for (int i = 0; i < sharedBundles.Length; i++)
                {
                    var path = $"{Application.streamingAssetsPath}/{EntityScenesPaths.RelativePathFolderFor(sharedBundles[i], EntityScenesPaths.PathType.EntitiesSharedReferencesBundle, -1)}";
                    LogBundle($"Request dependency {mainBundlePath}");
                    bundles[i + 1] = CreateOrRetainBundle(path);
                }
            }

            if (hasMainBundle)
            {
                bundles[0] = CreateOrRetainBundle(mainBundlePath);
            }

            if (blocking)
            {
                foreach (var b in bundles)
                {
                    var forceLoad = b.AssetBundle;
                    if (forceLoad == null)
                    {
                        Debug.LogWarning($"Failed to load asset bundle at path {b._bundlePath}");
                    }
                }
            }
            return(bundles);
        }