Ejemplo n.º 1
0
    public void OpenFile()
    {
        IsoLayerManager.instance.DeleteAll();

        OpenFileDialog ofd = new OpenFileDialog();

        ofd.Filter = "JSON Files |*.json";
        if (ofd.ShowDialog() == DialogResult.OK)
        {
            InputRootModel = JsonUtility.FromJson <IsoMetricRootModel> (File.ReadAllText(ofd.FileName));
            AddResourceItems();
            ExportFileManager.currentPath = ofd.FileName;
            loading.SetActive(true);
            StartCoroutine(LoadAllResources((done) => {
                if (done)
                {
                    if (errorText != "")
                    {
                        MessageBox.Show(errorText, "Error Read Resource!");
                    }
                    else
                    {
                        RenderRootModel();
                        loading.SetActive(false);
                    }
                }
            }));

            CameraTool._isDragging = false;
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.S))
     {
         if (currentPath != null)
         {
             Debug.Log("Ctrl + S");
             OutputRootModel = new IsoMetricRootModel();
             OutputRootModel.ConvertAllLayer();
             string jsonContent = JsonUtility.ToJson(OutputRootModel);
             File.WriteAllText(currentPath, jsonContent);
         }
         else
         {
             ExportToJSONDialog();
         }
     }
 }
Ejemplo n.º 3
0
    public void ExportToJSONDialog()
    {
        SaveFileDialog saveDialog = new SaveFileDialog();

        saveDialog.Filter = "JSON Files |*.json";
        if (saveDialog.ShowDialog() == DialogResult.OK)
        {
            try{
                OutputRootModel.ConvertAllLayer();
                string jsonContent = JsonUtility.ToJson(OutputRootModel);
                currentPath = saveDialog.FileName;
                File.WriteAllText(saveDialog.FileName, jsonContent);
                CameraTool._isDragging = false;
                // Reset RootModel.
                OutputRootModel = new IsoMetricRootModel();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
    }