コード例 #1
0
 // Start is called before the first frame update
 void Start()
 {
     FileBrowser.CheckPermission();
     if (PlayerPrefs.HasKey("username"))
     {
         StartCoroutine(setImage(PlayerPrefs.GetString("profileimg")));
         ARCanvas.SetActive(false);
         LoginCanvas.SetActive(true);
         HomePanel.SetActive(false);
         LoginPanal.SetActive(false);
         DashBoardPanel.SetActive(true);
         ProjectsPanal.SetActive(false);
         LoadingPanal.SetActive(false);
         UserName.text = PlayerPrefs.GetString("displayname");
     }
     else
     {
         ARCanvas.SetActive(false);
         LoginCanvas.SetActive(true);
         HomePanel.SetActive(true);
         LoginPanal.SetActive(false);
         DashBoardPanel.SetActive(false);
         ProjectsPanal.SetActive(false);
         LoadingPanal.SetActive(false);
     }
 }
コード例 #2
0
    public void OnOpenModel()
    {
        if (FileBrowser.CheckPermission() == FileBrowser.Permission.Granted)
        {
#if UNITY_EDITOR
            Directory.CreateDirectory(LiveViewerTools.EXT_PRESISTDATA_PATH);
#endif
            FileBrowser.ShowLoadDialog(OnFileOpenSuccess, () => { }, false, LiveViewerTools.EXT_PRESISTDATA_PATH + "/save");
        }
        else
        {
            PopUI.ShowMessage(LogType.Error, "请开启文件权限");
        }
    }
コード例 #3
0
ファイル: UploadClothModel.cs プロジェクト: padfoot18/WeAR
    IEnumerator ShowLoadDialogCoroutine()
    {
        /*** TODO: Add file extension filter and request permission ***/
        Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Permission: " + FileBrowser.CheckPermission());
        yield return(FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load"));

        Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> File Dialog Opened: " + FileBrowser.Success);
        Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> File Dialog Result: " + FileBrowser.Result);

        if (FileBrowser.Success)
        {
            Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Selecting cloth model file");
            try {
                IPAddress  ipAddr        = IPAddress.Parse(clothModelServerIP);
                IPEndPoint localEndPoint = new IPEndPoint(ipAddr, port_no);

                Socket sender = new Socket(ipAddr.AddressFamily,
                                           SocketType.Stream, ProtocolType.Tcp);

                try {
                    sender.Connect(localEndPoint);
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Socket connected to: " + sender.RemoteEndPoint.ToString());
                    string fileName = FileBrowser.Result;
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Sending file: " + fileName);
                    sender.Send(FileBrowserHelpers.ReadBytesFromFile(fileName));
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> File sent");
                    sender.Shutdown(SocketShutdown.Both);
                    sender.Close();
                }
                catch (ArgumentNullException ane) {
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> ArgumentNullException: " + ane.ToString());
                }
                catch (SocketException se) {
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> SocketException: " + se.ToString());
                }
                catch (Exception e) {
                    Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Unexpected exception: " + e.ToString());
                }
            }
            catch (Exception e) {
                Debug.Log("UploadClothModel.ShowLoadDialogCoroutine() ===> Other exception: " + e.ToString());
            }
        }
    }
コード例 #4
0
    IEnumerator ShowLoadDialogCoroutine()
    {
        // FileBrowser.SetFilters(true, (".png", ".jpg", ".jpeg"));
        // FileBrowser.SingleClickMode = true;
        Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> Permission: " + FileBrowser.CheckPermission());

        yield return(FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load"));

        Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> Success, Result: " + FileBrowser.Success + ", " + FileBrowser.Result);

        if (FileBrowser.Success)
        {
            Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> Selecting Pattern");
            string fileName = FileBrowser.Result;
            Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> Saving file: " + fileName);

            path = Path.Combine(Application.persistentDataPath, "Pattern");

            if (Directory.Exists(path))
            {
                /*** TODO extract filename from path ***/
                string[] splitFileName = fileName.Split('/');
                path = Path.Combine(path, splitFileName[splitFileName.Length - 1]);
                Debug.Log("New Path: " + path);
                if (!Directory.Exists(path))
                {
                    File.WriteAllBytes(path, FileBrowserHelpers.ReadBytesFromFile(fileName));
                }
                else
                {
                    Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> File already Uploaded");
                }
            }
            else
            {
                Debug.Log("UploadPatternImage.ShowLoadDialogCoroutine() ===> Directory not found: " + path);
            }
            path = Path.Combine(Application.persistentDataPath, "Pattern");
            p.GenerateList(path);
        }
    }