private async Task <Texture2D> LoadTextureByUrl(string url)
 {
     using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(url))
     {
         request.SendWebRequest();
         while (request.downloadProgress < 1f)
         {
             FigmaNodesProgressInfo.ShowProgress(request.downloadProgress);
             await Task.Delay(100);
         }
         if (request.isNetworkError || request.isHttpError)
         {
             return(null);
         }
         var       data = request.downloadHandler.data;
         Texture2D t    = new Texture2D(0, 0);
         t.LoadImage(data);
         FigmaNodesProgressInfo.HideProgress();
         return(t);
     }
 }
        public async Task <Texture2D> GetImage(string nodeId)
        {
            WWWForm form    = new WWWForm();
            string  request = string.Format(ImagesUrl, _fileName, nodeId);

            using (UnityWebRequest www = UnityWebRequest.Get(request))
            {
                www.SetRequestHeader("Authorization", $"Bearer {_settings.Token}");
                www.SendWebRequest();
                while (!www.isDone)
                {
                    FigmaNodesProgressInfo.CurrentInfo = "Getting node image info";
                    FigmaNodesProgressInfo.ShowProgress(www.downloadProgress);
                    await Task.Delay(100);
                }

                FigmaNodesProgressInfo.HideProgress();

                if (www.isNetworkError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    var result  = www.downloadHandler.text;
                    var substrs = result.Split('"');
                    FigmaNodesProgressInfo.CurrentInfo = "Loading node texture";
                    foreach (var s in substrs)
                    {
                        if (s.Contains("http"))
                        {
                            return(await LoadTextureByUrl(s));
                        }
                    }
                }
            }

            return(null);
        }
        private async void GetFile(string fileUrl)
        {
            WWWForm form    = new WWWForm();
            string  request = fileUrl;

            FigmaNodesProgressInfo.CurrentNode  = FigmaNodesProgressInfo.NodesCount = 0;
            FigmaNodesProgressInfo.CurrentTitle = "Loading nodes info";
            using (UnityWebRequest www = UnityWebRequest.Get(request))
            {
                www.SetRequestHeader("Authorization", $"Bearer {_settings.Token}");
                www.SendWebRequest();
                while (!www.isDone)
                {
                    FigmaNodesProgressInfo.CurrentInfo = "Loading nodes info";
                    FigmaNodesProgressInfo.ShowProgress(www.downloadProgress);
                    await Task.Delay(100);
                }

                FigmaNodesProgressInfo.HideProgress();

                if (www.isNetworkError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    var         result = www.downloadHandler.text;
                    FigmaParser parser = new FigmaParser();
                    var         nodes  = parser.ParseResult(result);
                    FigmaNodesProgressInfo.NodesCount = GetNodesCount(nodes);
                    FigmaNodeGenerator generator = new FigmaNodeGenerator(this);
                    foreach (var node in nodes)
                    {
                        await generator.GenerateNode(node);
                    }
                }
                FigmaNodesProgressInfo.HideProgress();
            }
        }