示例#1
0
 private static void FinishInstance()
 {
     EditorUtility.ClearProgressBar();
     UploadDialog.packageController = null;
     EditorApplication.update      -= new EditorApplication.CallbackFunction(UploadDialog.PackageControllerUpdatePump);
     DebugUtils.Log("Upload progress dialog finished it's job");
 }
示例#2
0
 private void Init()
 {
     this.Account.Reset();
     this.Account.mStatus     = AssetStorePublisher.Status.NotLoaded;
     this.m_PackageDataSource = new PackageDataSource();
     this.m_PackageController = new AssetStorePackageController(this.m_PackageDataSource);
 }
示例#3
0
 private void OnEnable()
 {
     this.m_PackageDataSource    = new PackageDataSource();
     this.m_PackageController    = new AssetStorePackageController(this.m_PackageDataSource);
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(AssetStoreClient.Update));
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(AssetStoreClient.Update));
     EditorApplication.update    = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.PackageControllerUpdatePump));
     Application.runInBackground = true;
 }
示例#4
0
    public static void CreateInstance(AssetStorePackageController packageController)
    {
        if (UploadDialog.packageController != null)
        {
            DebugUtils.LogError("New UploadDialog instance being created before an old one has finished");
        }

        UploadDialog.packageController = packageController;
        EditorApplication.update      += new EditorApplication.CallbackFunction(UploadDialog.PackageControllerUpdatePump);
    }
示例#5
0
 private void OnEnable()
 {
     this.m_PackageDataSource    = new PackageDataSource();
     this.m_PackageController    = new AssetStorePackageController(this.m_PackageDataSource);
     EditorApplication.update   -= new EditorApplication.CallbackFunction(AssetStoreClient.Update);
     EditorApplication.update   += new EditorApplication.CallbackFunction(AssetStoreClient.Update);
     EditorApplication.update   += new EditorApplication.CallbackFunction(this.PackageControllerUpdatePump);
     Application.runInBackground = true;
     DebugUtils.Log(string.Concat("OnEnable", base.GetType().ToString()));
 }
 private void RenderAssetsFolderStatus()
 {
     if (this.m_AssetsState == AssetStorePackageController.AssetsState.UploadingPackage)
     {
         int    num = (int)Mathf.Ceil(this.m_DraftAssetsUploadProgress * 100f);
         string str = num.ToString();
         if (AssetStorePackageController.CancelableProgressBar(this.m_DraftAssetsUploadProgress, string.Concat("Uploading ", str, " %"), "Cancel"))
         {
             this.m_DraftAssetsUploadProgress = 0f;
             this.m_AssetsState     = AssetStorePackageController.AssetsState.None;
             this.m_DraftAssetsPath = string.Empty;
             this.m_DraftAssetsSize = (long)0;
             AssetStoreClient.AbortLargeFilesUpload();
         }
     }
     else if (this.m_AssetsState != AssetStorePackageController.AssetsState.BuildingPackage)
     {
         Color  color = GUI.color;
         string str1  = "No assets selected";
         if (this.m_LocalRootPath != null)
         {
             if (!this.IsValidRelativeProjectFolder(this.m_LocalRootPath))
             {
                 GUI.color = GUIUtil.ErrorColor;
                 str1      = string.Format("The path \"{0}\" is not valid within this Project", this.m_LocalRootPath);
             }
             else if (!this.m_LocalRootPath.StartsWith("/AssetStoreTools"))
             {
                 str1 = string.Concat(" ", this.m_LocalRootPath);
             }
             else
             {
                 GUI.color = GUIUtil.ErrorColor;
                 str1      = string.Format("The selected path cannot be part of \"/AssetStoreTools\" folder", this.m_LocalRootPath);
             }
         }
         GUILayout.Label(str1, new GUILayoutOption[0]);
         GUI.color = color;
         GUILayout.FlexibleSpace();
     }
     else
     {
         GUILayout.Label(GUIUtil.StatusWheel, new GUILayoutOption[0]);
         GUILayout.Label("Please wait - building package", new GUILayoutOption[0]);
         GUILayout.FlexibleSpace();
     }
 }
示例#7
0
 private void RenderMainAssetsStatus()
 {
     if (this.m_AssetsState == AssetStorePackageController.AssetsState.BuildingMainAssets)
     {
         GUILayout.Label(GUIUtil.StatusWheel, new GUILayoutOption[0]);
         GUILayout.Label("Please wait - building Main Assets", new GUILayoutOption[0]);
         GUILayout.FlexibleSpace();
     }
     else if (this.m_AssetsState == AssetStorePackageController.AssetsState.UploadingMainAssets)
     {
         float  num = (float)this.m_MainAssetsUploadHelper.GetProgress();
         string str = Mathf.FloorToInt(num).ToString();
         if (AssetStorePackageController.CancelableProgressBar(num, "Uploading " + str + " %", "Cancel"))
         {
             this.m_AssetsState     = AssetStorePackageController.AssetsState.None;
             this.m_DraftAssetsPath = string.Empty;
             this.m_DraftAssetsSize = 0L;
             AssetStoreClient.AbortLargeFilesUpload();
         }
     }
     else
     {
         string text;
         if (this.m_Package != null && !string.IsNullOrEmpty(this.m_LocalRootPath) && this.IsValidRelativeProjectFolder(this.m_LocalRootPath))
         {
             if (this.m_MainAssets.Count == 0)
             {
                 text = "No Files Selected";
             }
             else if (this.m_MainAssets.Count == 1)
             {
                 text = this.m_MainAssets[0] + " selected";
             }
             else
             {
                 text = this.m_MainAssets.Count + " File(s) selected";
             }
         }
         else
         {
             text = "Please select a valid Assets folder";
         }
         GUILayout.Label(text, new GUILayoutOption[0]);
     }
 }
    private void Upload()
    {
        DebugUtils.Log("Upload");
        if (this.m_LocalRootPath == null)
        {
            EditorUtility.DisplayDialog("Package Assets folder not set", "You haven't set the Asset Folder yet. ", "Ok");
            return;
        }
        DebugUtils.Log(string.Concat(Application.dataPath, this.m_LocalRootPath));
        if (!Directory.Exists(string.Concat(Application.dataPath, this.m_LocalRootPath)))
        {
            EditorUtility.DisplayDialog("Project not found!", "The root folder you selected does not exist in the current project.\nPlease make sure you have the correct project open or you have selected the right root folder", "Ok");
            return;
        }
        if ((int)Directory.GetFileSystemEntries(string.Concat(Application.dataPath, this.m_LocalRootPath)).Length == 0)
        {
            EditorUtility.DisplayDialog("Empty folder!", "The root folder you have selected is empty.\nPlease make sure you have the correct project open or you have selected the right root folder", "Ok");
            return;
        }
        this.m_DraftAssetsUploadProgress = 0f;
        this.m_LocalProjectPath          = Application.dataPath;
        this.m_LocalRootGUID             = AssetStorePackageController.GetLocalRootGUID(this.m_Package);
        string str = this.CheckContent();

        if (string.IsNullOrEmpty(str))
        {
            this.m_DraftAssetsPath          = string.Concat("Temp/uploadtool_", this.m_LocalRootPath.Trim(new char[] { '/' }).Replace('/', '\u005F'), ".unitypackage");
            this.m_DraftAssetsSize          = (long)0;
            this.m_DraftAssetsLastCheckTime = EditorApplication.timeSinceStartup;
            this.m_AssetsState = AssetStorePackageController.AssetsState.InitiateBuilding;
            this.m_Dirty       = true;
            EditorApplication.LockReloadAssemblies();
            return;
        }
        string str1 = AssetStorePackageController.kForbiddenExtensions[0];

        for (int i = 1; i < (int)AssetStorePackageController.kForbiddenExtensions.Length; i++)
        {
            str1 = string.Concat(str1, ", ", AssetStorePackageController.kForbiddenExtensions[i]);
        }
        Debug.LogWarning(str);
        EditorUtility.DisplayDialog("Invalid files", string.Concat("Your project contains file types that are not allowed in the AssetStore.\nPlease remove files with the following extensions:\n", str1, "\nYou can find more details in the console."), "Ok");
    }
示例#9
0
    private void Upload()
    {
        DebugUtils.Log("Upload");
        if (this.m_LocalRootPath == null)
        {
            EditorUtility.DisplayDialog("Package Assets folder not set", "You haven't set the Asset Folder yet. ", "Ok");
            return;
        }
        DebugUtils.Log(Application.dataPath + this.m_LocalRootPath);
        if (!Directory.Exists(Application.dataPath + this.m_LocalRootPath))
        {
            EditorUtility.DisplayDialog("Project not found!", "The root folder you selected does not exist in the current project.\nPlease make sure you have the correct project open or you have selected the right root folder", "Ok");
            return;
        }
        this.m_DraftAssetsUploadProgress = 0f;
        this.m_LocalProjectPath          = Application.dataPath;
        this.m_LocalRootGUID             = AssetStorePackageController.GetLocalRootGUID(this.m_Package);
        string text = this.CheckContent();

        if (string.IsNullOrEmpty(text))
        {
            this.m_DraftAssetsPath = "Temp/uploadtool_" + this.m_LocalRootPath.Trim(new char[]
            {
                '/'
            }).Replace('/', '_') + ".unitypackage";
            this.m_DraftAssetsSize          = 0L;
            this.m_DraftAssetsLastCheckTime = EditorApplication.timeSinceStartup;
            this.m_AssetsState = AssetStorePackageController.AssetsState.InitiateBuilding;
            this.m_Dirty       = true;
            return;
        }
        string text2 = AssetStorePackageController.kForbiddenExtensions[0];

        for (int i = 1; i < AssetStorePackageController.kForbiddenExtensions.Length; i++)
        {
            text2 = text2 + ", " + AssetStorePackageController.kForbiddenExtensions[i];
        }
        Debug.LogWarning(text);
        EditorUtility.DisplayDialog("Invalid files", "Your project contains file types that are not allowed in the AssetStore.\nPlease remove files with the following extensions:\n" + text2 + "\nYou can find more details in the console.", "Ok");
    }
示例#10
0
 private void RenderAssetsFolderStatus()
 {
     if (this.m_AssetsState == AssetStorePackageController.AssetsState.UploadingPackage)
     {
         string str = ((int)Mathf.Ceil(this.m_DraftAssetsUploadProgress * 100f)).ToString();
         if (AssetStorePackageController.CancelableProgressBar(this.m_DraftAssetsUploadProgress, "Uploading " + str + " %", "Cancel"))
         {
             this.m_DraftAssetsUploadProgress = 0f;
             this.m_AssetsState     = AssetStorePackageController.AssetsState.None;
             this.m_DraftAssetsPath = string.Empty;
             this.m_DraftAssetsSize = 0L;
             AssetStoreClient.AbortLargeFilesUpload();
         }
     }
     else if (this.m_AssetsState == AssetStorePackageController.AssetsState.BuildingPackage)
     {
         GUILayout.Label(GUIUtil.StatusWheel, new GUILayoutOption[0]);
         GUILayout.Label("Please wait - building package", new GUILayoutOption[0]);
         GUILayout.FlexibleSpace();
     }
     else
     {
         Color  color = GUI.color;
         string text  = "No assets selected";
         if (this.m_LocalRootPath != null)
         {
             if (!this.IsValidRelativeProjectFolder(this.m_LocalRootPath))
             {
                 GUI.color = Color.red;
             }
             text = " " + this.m_LocalRootPath;
         }
         GUILayout.Label(text, new GUILayoutOption[0]);
         GUI.color = color;
         GUILayout.FlexibleSpace();
     }
 }
示例#11
0
    public void AutoSetSelected(AssetStoreManager assetStoreManager)
    {
        if (this.Dirty)
        {
            return;
        }
        this.SelectedPackage = null;
        List <Package>  list        = new List <Package>();
        IList <Package> allPackages = assetStoreManager.packageDataSource.GetAllPackages();

        foreach (Package current in allPackages)
        {
            list.Add(current);
        }
        list.RemoveAll((Package pc) => string.IsNullOrEmpty(pc.RootGUID) || pc.RootGUID != AssetStorePackageController.GetLocalRootGUID(pc));
        if (list.Count == 1)
        {
            this.SelectedPackage = list[0];
            return;
        }
        if (list.Count == 0)
        {
            foreach (Package current2 in allPackages)
            {
                list.Add(current2);
            }
        }
        list.RemoveAll((Package pc) => pc.RootPath == null || (Application.dataPath != pc.ProjectPath && !Directory.Exists(Application.dataPath + pc.RootPath)));
        if (list.Count == 1)
        {
            this.SelectedPackage = list[0];
            return;
        }
        if (list.Count == 0)
        {
            return;
        }
        foreach (Package current3 in list)
        {
            if (current3.RootPath != null && Directory.Exists(Application.dataPath + current3.RootPath) && Application.dataPath == current3.ProjectPath)
            {
                this.SelectedPackage = current3;
                return;
            }
        }
        if (this.SelectedPackage != null)
        {
            return;
        }
        foreach (Package current4 in list)
        {
            if (current4.RootPath != null && Directory.Exists(Application.dataPath + current4.RootPath))
            {
                this.SelectedPackage = current4;
                return;
            }
        }
        if (this.SelectedPackage != null)
        {
            return;
        }
        foreach (Package current5 in list)
        {
            if (current5.ProjectPath != null && current5.ProjectPath == Application.dataPath)
            {
                this.SelectedPackage = current5;
                break;
            }
        }
    }
示例#12
0
 static AssetStorePackageController()
 {
     s_Instance = new AssetStorePackageController();
 }
示例#13
0
    /// <summary>
    /// Upload a package, using the specified options.
    /// </summary>
    /// <param name="username">The username credentials to use for package uploading.</param>
    /// <param name="password">The password credentials to use for package uploading.</param>
    /// <param name="packageName">The package name. The package must be set to draft status in the Publisher Administration.</param>
    /// <param name="rootPath">The root path of the package (relative to Application.dataPath). If null, use the project Assets folder.</param>
    /// <param name="mainAssets">An array of the main assets for the package (relative to Application.dataPath). If null, do not upload or change any main assets.</param>
    /// <param name="loginTimeout">The maximum amount of time to wait (in seconds) when logging in. Defaults to 90 seconds. Must be within 2 and 36000 seconds. Login is attempted twice.</param>
    /// <param name="metadataTimeout">The maximum amount of time to wait (in seconds) when getting metadata. Defaults to 600 seconds. Must be within 2 and 36000 seconds.</param>
    /// <param name="uploadTimeout">The maximum amount of time to wait (in seconds) when uploading. Defaults to 36000 seconds. Must be within 2 and 36000 seconds.</param>
    public static void UploadAssetStorePackage(string username, string password, string packageName, string rootPath = null, string[] mainAssets = null, int loginTimeout = 90, int metadataTimeout = 600, int uploadTimeout = 36000, bool skipProjectSettings = false, bool actuallyUpload = false, string outputPath = "")
    {
        if (string.IsNullOrEmpty(username))
        {
            throw new ArgumentNullException("username");
        }

        if (string.IsNullOrEmpty(password))
        {
            throw new ArgumentNullException("password");
        }

        if (string.IsNullOrEmpty(packageName))
        {
            throw new ArgumentNullException("packageName");
        }

        s_Username            = username;
        s_Password            = password;
        s_PackageName         = packageName;
        s_RootPath            = rootPath;
        s_MainAssets          = mainAssets;
        s_LoginTimeout        = Mathf.Clamp(loginTimeout, 2, 36000);
        s_MetadataTimeout     = Mathf.Clamp(metadataTimeout, 2, 36000);
        s_UploadTimeout       = Mathf.Clamp(uploadTimeout, 2, 36000);
        s_SkipProjectSettings = skipProjectSettings;

        Finish();

#if !UNITY_5_5_OR_NEWER
        if (Application.webSecurityEnabled)
        {
            Debug.Log("[Asset Store Batch Mode] Switching from Web Player platform...");

            EditorUserBuildSettings.SwitchActiveBuildTarget(EditorUserBuildSettings.selectedStandaloneTarget);
        }
#endif

        Debug.Log("[Asset Store Batch Mode] Logging into the Asset Store...");

        AssetStoreClient.LoginWithCredentials(s_Username, s_Password, false, OnLogin);

        if (!WaitForUpdate(ref s_LoginDone, s_LoginTimeout))
        {
            Finish();

            // Try again
            s_LoginDone = false;
            AssetStoreClient.LoginWithCredentials(s_Username, s_Password, false, OnLogin);

            if (!WaitForUpdate(ref s_LoginDone, s_LoginTimeout))
            {
                Finish();
                return;
            }
        }

        AssetStoreAPI.GetMetaData(s_PublisherAccount, s_PackageDataSource, OnGetMetadata);

        Debug.Log("[Asset Store Batch Mode] Getting package metadata...");

        if (!WaitForUpdate(ref s_GetMetadataDone, s_MetadataTimeout))
        {
            Finish();
            return;
        }

        var packages = s_PackageDataSource.GetAllPackages();
        var package  = packages.FirstOrDefault(p => p.Name == s_PackageName && p.Status == Package.PublishedStatus.Draft);

        if (package == null)
        {
            Debug.LogError("[Asset Store Batch Mode] Draft package: " + s_PackageName + " not found!");
            Finish();
            return;
        }

        // Validate root project folder
        var projectFolder = Path.Combine(Application.dataPath, s_RootPath ?? string.Empty);

        // Convert to unix path style
        projectFolder = projectFolder.Replace("\\", "/");

        if (!IsValidProjectFolder(projectFolder))
        {
            Debug.LogError("[Asset Store Batch Mode] Project folder is invalid");
            Finish();
            return;
        }

        // Set root asset path
        var localRootPath = SetRootPath(package, projectFolder);

        // Set main assets
        if (MainAssetsUtil.CanGenerateBundles)
        {
            // TODO: Set main assets
        }

        // Verify content
        var checkContent = CheckContent(package, localRootPath);
        if (!string.IsNullOrEmpty(checkContent))
        {
            Debug.LogError("[Asset Store Batch Mode] " + checkContent);
            Finish();
            return;
        }

        var draftAssetsPath = GetDraftAssetsPath(localRootPath);

        Export(package, localRootPath, draftAssetsPath, outputPath);

        if (actuallyUpload)
        {
            // Upload assets
            AssetStoreAPI.UploadAssets(
                package,
                AssetStorePackageController.GetLocalRootGUID(package),
                localRootPath,
                Application.dataPath,
                draftAssetsPath,
                OnAssetsUploaded, null);

            Debug.Log("[Asset Store Batch Mode] Uploading asset...");

            if (!WaitForUpdate(ref s_AssetsUploadedDone, s_UploadTimeout))
            {
                Finish();
                return;
            }

            if (MainAssetsUtil.CanGenerateBundles)
            {
                // TODO: Upload main assets
            }

            Debug.Log("[Asset Store Batch Mode] Asset successfully uploaded");
        }
        Finish();
    }
示例#14
0
 public MainAssetsUploadHelper(AssetStorePackageController assetStorePackageController, List <string> mainAssets, Action <string> onUploadAssetBundlesFinished)
 {
     this.m_AssetStorePackageController  = assetStorePackageController;
     this.m_OnUploadAssetBundlesFinished = onUploadAssetBundlesFinished;
     this.m_MainAssets = mainAssets;
 }