Beispiel #1
0
        public override void LoadProjectStructure(int projectId, Action <ProjectStructure> onFinish)
        {
            var request = new RequestFileRead("/index.json");

            request.OnFinish += response =>
            {
                string jsonWorldStructure = ((ResponseFileRead)response).TextData;
                var    worldStructure     = jsonWorldStructure.JsonDeserialize <ProjectStructure>();

                foreach (var scene in worldStructure.Scenes)
                {
                    var logicRequest = new RequestFileRead(scene.LogicResource);

                    logicRequest.OnFinish += response1 =>
                    {
                        ResponseFileRead logicResponse = (ResponseFileRead)response1;
                        scene.AssemblyBytes = logicResponse.ByteData;
                    };
                }

                onFinish.Invoke(worldStructure);
            };

            request.OnError += s =>
            {
                LauncherErrorManager.Instance.ShowFatal(ErrorHelper.GetErrorDescByCode(Errors.ErrorCode.LoadSceneError),
                                                        null);
                FeedBackText = $"Can't find project folder";
            };
        }
Beispiel #2
0
        private void LoadAssetFromStorage(AssetInfo assetInfo, PrefabObject o)
        {
            string assetName      = assetInfo.AssetName;
            string assetBundleUri = ProjectData.ProjectStructure.IsMobile ? o.AndroidBundleResource : o.BundleResource;

            RequestFileRead requestAssetData = new RequestFileRead(assetBundleUri);

            requestAssetData.OnFinish += responseData =>
            {
                ResponseFileRead responseFileRead = (ResponseFileRead)responseData;
                var bundleData = responseFileRead.ByteData;

                RequestLoadAssetFromMemory requestAsset =
                    new RequestLoadAssetFromMemory(assetName, bundleData, new object[] { o, assetInfo });

                requestAsset.OnFinish += response =>
                {
                    FeedBackText = LanguageManager.Instance.GetTextValue("LOADING")
                                   + " "
                                   + o.Config.i18n.GetCurrentLocale()
                                   + "...";
                    CreatePrefabEntity(response, o);
                };
            };
        }
Beispiel #3
0
        public override void LoadLocation(int locationId)
        {
            LocationPrefab location = ProjectData.ProjectStructure.Locations.GetProjectScene(locationId);

            Logger.Info($"Loading location \"{location.Name}\" from tar file");
            RequestFileRead requestConfig = new RequestFileRead(location.ConfigResource);

            requestConfig.OnFinish += responseConfig =>
            {
                SceneData sceneData = ((ResponseFileRead)responseConfig).TextData.JsonDeserialize <SceneData>();

                RequestFileRead requestFileRead = new RequestFileRead(ProjectData.ProjectStructure.IsMobile
                    ? location.AndroidBundleResource
                    : location.BundleResource);

                requestFileRead.OnFinish += response =>
                {
                    ResponseFileRead responseFileRead = (ResponseFileRead)response;
                    byte[]           bundle           = responseFileRead.ByteData;

                    RequestLoadSceneFromMemory request =
                        new RequestLoadSceneFromMemory(sceneData.AssetBundleLabel, bundle);

                    request.OnFinish += response1 =>
                    {
                        ResponseAsset responseAsset = (ResponseAsset)response1;
                        string        scenePath     = Path.GetFileNameWithoutExtension(responseAsset.Path);

                        ProjectDataListener.Instance.LoadScene(scenePath);
                    };

                    Resources.UnloadUnusedAssets();

                    request.OnError += s => { Helper.ShowErrorLoadScene(); };
                };

                requestFileRead.OnError += s => { Helper.ShowErrorLoadScene(); };
            };
        }