Exemple #1
0
        static IEnumerator WritePackagesListAndFinalizeBuild(string dependenciesFilePath)
        {
            var request = UnityEditor.PackageManager.Client.List(false, false);

            while (!request.IsCompleted)
            {
                yield return(null);
            }
            string templatePackageID = GetTemplatePackageID();

            if (string.IsNullOrEmpty(templatePackageID))
            {
                templatePackageID = $"{Application.productName}@{Application.version}";
            }

            using (StreamWriter streamWriter = new StreamWriter(dependenciesFilePath, false))
            {
                request.Result
                .Select(pkg => $"{pkg.name}@{pkg.version}")
                // We probably don't have the package.json of the used template available,
                // so add the information manually
                .Concat(new[] { templatePackageID })
                .Distinct()
                .ToList()
                .ForEach(streamWriter.WriteLine);
            }
            PublisherWindow windowInstance = PublisherWindow.FindInstance();

            windowInstance?.OnBuildCompleted(windowInstance.Store.state.buildOutputDir);
        }
Exemple #2
0
            void Start()
            {
                PublisherState currentStep = PublisherUtils.GetCurrentPublisherState(PublisherWindow.FindInstance());

                Debug.Log(currentStep);
                switch (currentStep)
                {
                case PublisherState.Idle:
                    //your code here
                    break;

                case PublisherState.Login:
                    //your code here
                    break;

                case PublisherState.Zip:
                    //your code here
                    break;

                case PublisherState.Upload:
                    //your code here
                    break;

                case PublisherState.Process:
                    //your code here
                    break;

                default:
                    break;
                }
            }
        /// <summary>
        /// Processes the state of the app according to an action
        /// </summary>
        /// <param name="old">old state</param>
        /// <param name="action">dispatched action</param>
        /// <returns>Returns an updated AppState</returns>
        public static AppState Reducer(AppState old, object action)
        {
            switch (action)
            {
            case BuildFinishAction build:
                return(old.CopyWith(
                           buildOutputDir: build.outputDir,
                           buildGUID: build.buildGUID
                           ));

            case ZipPathChangeAction zip:
                return(old.CopyWith(
                           zipPath: zip.zipPath,
                           step: PublisherState.Zip
                           ));

            case UploadStartAction upload:
                AnalyticsHelper.UploadStarted();
                return(old.CopyWith(step: PublisherState.Upload));

            case QueryProgressAction query:

                return(old.CopyWith(
                           step: PublisherState.Process,
                           key: query.key
                           ));

            case UploadProgressAction upload:
                PublisherWindow.FindInstance()?.OnUploadProgress(upload.progress);
                return(old);

            case QueryProgressResponseAction queryResponse:
                PublisherState?step = null;
                if (queryResponse.response.progress == 100)
                {
                    step = PublisherState.Idle;
                }

                PublisherWindow.FindInstance()?.OnProcessingProgress(queryResponse.response.progress);
                return(old.CopyWith(url: queryResponse.response.url, step: step));

            case TitleChangeAction titleChangeAction: return(old.CopyWith(title: titleChangeAction.title));

            case DestroyAction destroyAction: return(new AppState(buildOutputDir: old.buildOutputDir, buildGUID: old.buildGUID));

            case OnErrorAction errorAction: return(old.CopyWith(errorMsg: errorAction.errorMsg));

            case StopUploadAction stopUploadAction: return(new AppState(buildOutputDir: old.buildOutputDir, buildGUID: old.buildGUID));

            case NotLoginAction login: return(old.CopyWith(step: PublisherState.Login));

            case LoginAction login: return(old.CopyWith(step: PublisherState.Idle));
            }
            return(old);
        }
Exemple #4
0
            void Start()
            {
                PublisherWindow publisherWindow = PublisherWindow.FindInstance();

                if (!publisherWindow)
                {
                    return;
                }
                publisherWindow.Dispatch(new OnErrorAction {
                    errorMsg = "Error: you're too awesome to proceed!"
                });
            }
Exemple #5
0
        /// <summary>
        /// Called right after a build process ends
        /// </summary>
        /// <param name="report">A summary of the build process</param>
        public void OnPostprocessBuild(BuildReport report)
        {
            BuildSummary summary = report.summary;

            if (summary.platform != BuildTarget.WebGL)
            {
                return;
            }

            string buildOutputDir = summary.outputPath;
            string buildGUID      = summary.guid.ToString();

            PublisherUtils.AddBuildDirectory(buildOutputDir);

            PublisherWindow windowInstance = PublisherWindow.FindInstance();

            windowInstance?.Store.Dispatch(new BuildFinishAction
            {
                outputDir = buildOutputDir,
                buildGUID = buildGUID
            });

            WriteMetadataFilesAndFinalizeBuild(summary.outputPath, buildGUID);
        }
Exemple #6
0
 /// <summary>
 /// Gets the URL of the last build that was published during the current session.
 /// Only valid as long as the PublisherWindow stays open.
 /// </summary>
 /// <remarks>
 /// If this is empty, no build has been published.
 /// </remarks>
 /// <example>
 /// <code source="./Examples/PublisherExamples.cs" region="GetUrlOfLastPublishedBuild" title="GetUrlOfLastPublishedBuild"/>
 /// </example>
 /// <param name="instance">The instance of an open PublisherWindow</param>
 /// <returns>Returns the URL of the last build that was published during the current session.</returns>
 public static string GetUrlOfLastPublishedBuild(PublisherWindow instance)
 {
     return(instance.Store.state.url);
 }
Exemple #7
0
 /// <summary>
 /// Gets the current PublisherState of a PublisherWindow instance
 /// </summary>
 /// <remarks>
 /// Use this to detect a change in the current step and react accordingly
 /// (I.E: use it to understand if the user started the publishing process)
 /// </remarks>
 /// <example>
 /// <code source="./Examples/PublisherExamples.cs" region="GetCurrentPublisherState" title="GetCurrentPublisherState"/>
 /// </example>
 /// <param name="instance">The instance of an open PublisherWindow</param>
 /// <returns>Returns the current PublisherState of a PublisherWindow instance</returns>
 public static PublisherState GetCurrentPublisherState(PublisherWindow instance)
 {
     return(instance.Store.state.step);
 }
Exemple #8
0
            void Start()
            {
                string latestBuildURL = PublisherUtils.GetUrlOfLastPublishedBuild(PublisherWindow.FindInstance());

                Debug.Log(latestBuildURL);
            }