示例#1
0
        private BWebServiceResponse ListModels(Action <string> _ErrorMessageAction)
        {
            if (!DatabaseService.ScanTable(ModelDBEntry.DBSERVICE_MODELS_TABLE(), out List <JObject> ModelsJson, _ErrorMessageAction))
            {
                return(BWebResponse.InternalError("Scan-table operation has failed."));
            }

            var Result      = new JObject();
            var ModelsArray = new JArray();

            Result["models"] = ModelsArray;

            foreach (var ModelJson in ModelsJson)
            {
                var AsModel = JsonConvert.DeserializeObject <ModelDBEntry>(ModelJson.ToString());
                AsModel.Prune_NonGettableProperties();
                ModelsArray.Add(JObject.Parse(ModelJson.ToString()));
            }

            return(BWebResponse.StatusOK("List models operation has succeeded.", Result));
        }
        /// <summary>
        /// Shows dialog for opening files.
        /// </summary>
        public void ShowFileDialog()
        {
            // HACK Deselect active UI element.
            EventSystem.current.SetSelectedGameObject(null);


            // Pre-filter for motions in case a model is loaded.
            if (Model != null)
            {
                FileDialog.FilterIndex = 2;
            }


            // Return unless a file was selected.
            if (FileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }


            var absoluteFilePath = FileDialog.FileName;


            // Store path.
            Config.LastFileDialogPath = absoluteFilePath;


            // Handle model JSON files.
            if (absoluteFilePath.EndsWith(".model3.json"))
            {
                var lastModel = Model;


                // Load model.
                ModelJson = CubismModel3Json.LoadAtPath(absoluteFilePath, CubismViewerIo.LoadAsset);
                Model     = ModelJson.ToModel();


                // Trigger event.
                if (OnNewModel != null)
                {
                    OnNewModel(this, Model);
                }


                // Remove previous model.
                if (lastModel != null)
                {
                    Destroy(lastModel.gameObject);
                }


                // Guess best zoom and position.
                // TODO Improve if necessary.
                var modelBounds = Model
                                  .GetComponent <CubismRenderController>()
                                  .Renderers
                                  .GetMeshRendererBounds();


                Camera.transform.position = new Vector3(0f, 0f, -10f);
                Camera.orthographicSize   = modelBounds.extents.y * 1.1f;


                return;
            }


            // Trigger event for other files.
            if (OnFileDrop != null)
            {
                OnFileDrop(this, absoluteFilePath);
            }
        }