public static void downloadAndImportAssetFromServer(string directory, string assetName)
 {
     if (File.Exists(TheBlackArmsSDX_Settings.getAssetPath() + assetName))
     {
         TbaLog(assetName + " exists. Importing it..");
         importDownloadedAsset(assetName);
     }
     else
     {
         TbaLog(assetName + " does not exist. Starting download..");
         downloadFile(directory, assetName);
     }
 }
        private static void downloadFile(string directory, string assetName)
        {
            WebClient w = new WebClient();

            w.Headers.Set(HttpRequestHeader.UserAgent, "Webkit Gecko wHTTPS (Keep Alive 55)");
            w.QueryString.Add("assetName", assetName);
            w.DownloadFileCompleted   += fileDownloadCompleted;
            w.DownloadProgressChanged += fileDownloadProgress;
            //Debug.Log($"Download URL: {serverUrl}{directory}\\{assetName}");
            string url = $"{serverUrl}{directory}\\{assetName}";

            w.DownloadFileAsync(new Uri(url), TheBlackArmsSDX_Settings.getAssetPath() + assetName);
        }
Exemple #3
0
        public void OnGUI()
        {
            GUILayout.Box("", _nanoHeader);
            GUILayout.Space(4);
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("SDK made by PhoenixAceVFX/zombie2312"))
            {
                Application.OpenURL("https://github.com/TheBlackArms/TheBlackArmsSDX");
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("TheBlackArmsSDX Discord"))
            {
                Application.OpenURL("https://discord.gg/wngbcHS7NC");
            }
            if (GUILayout.Button("TheBlackArmsSDX Website"))
            {
                Application.OpenURL("https://trigon.systems/");
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(4);
            //Update assets
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Update assets (config)"))
            {
                TheBlackArmsSDX_ImportManager.updateConfig();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(4);



            //Imports V!V
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            _changeLogScroll    = GUILayout.BeginScrollView(_changeLogScroll, GUILayout.Width(_sizeX));
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            foreach (var asset in assets)
            {
                GUILayout.BeginHorizontal();
                if (asset.Value == "")
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(asset.Key);
                    GUILayout.FlexibleSpace();
                }
                else
                {
                    if (GUILayout.Button(
                            (File.Exists(TheBlackArmsSDX_Settings.getAssetPath() + asset.Value) ? "Import" : "Download") +
                            " " + asset.Key))
                    {
                        TheBlackArmsSDX_ImportManager.downloadAndImportAssetFromServer(asset.Value.Split('\\')[0], asset.Value.Split('\\')[1]);
                    }

                    if (GUILayout.Button("Del", GUILayout.Width(40)))
                    {
                        TheBlackArmsSDX_ImportManager.deleteAsset(asset.Value);
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
 public static void deleteAsset(string assetName)
 {
     File.Delete(TheBlackArmsSDX_Settings.getAssetPath() + assetName);
 }
 public static void importDownloadedAsset(string assetName)
 {
     AssetDatabase.ImportPackage(TheBlackArmsSDX_Settings.getAssetPath() + assetName, true);
 }