Ejemplo n.º 1
0
        public static void SetFolderAsBackend()
        {
            var path = GetSelectedDirectoryPath();

            if (path == null)
            {
                Debug.LogError("Selected asset is not a folder");
                return;
            }

            if (path.StartsWith("Assets/"))
            {
                path = path.Substring("Assets/".Length);
            }

            var preferences = UnisavePreferences.LoadOrCreate();

            preferences.BackendFolder = path;
            preferences.Save();

            Uploader
            .GetDefaultInstance()
            .UploadBackend(
                verbose: true,
                useAnotherThread: true
                );
        }
        private void TokensSlide()
        {
            TutorialGUI.Paragraph(
                "Copy the game token and editor key you will see after " +
                "game creation into these fields and click the button."
                );

            TutorialGUI.Form(() => {
                if (preferences == null)
                {
                    preferences = UnisavePreferences.LoadOrCreate();
                }

                preferences.GameToken = EditorGUILayout.TextField(
                    "Game token", preferences.GameToken
                    );
                preferences.EditorKey = EditorGUILayout.TextField(
                    "Editor key", preferences.EditorKey
                    );

                if (GUILayout.Button("Save preferences & upload the backend"))
                {
                    preferences.BackendFolder = BackendFolderPath;
                    preferences.Save();

                    Uploader
                    .GetDefaultInstance()
                    .UploadBackend(
                        verbose: true,
                        useAnotherThread: true
                        );
                }
            });
        }
Ejemplo n.º 3
0
 void RunManualCodeUpload()
 {
     Uploader
     .GetDefaultInstance()
     .UploadBackend(
         verbose: true,
         useAnotherThread: true                         // yes, here we can run in background
         );
 }
        /// <summary>
        /// Performs automatic backend upload if enabled
        /// </summary>
        private static void PerformAutomaticUploadIfEnabled()
        {
            var uploader = Uploader.GetDefaultInstance();

            if (uploader.AutomaticUploadingEnabled)
            {
                uploader.UploadBackend(
                    verbose: true, // here we ARE verbose, since we're building
                    useAnotherThread: false
                    );
            }
        }
        /// <summary>
        /// Called often, whenever code in the Unity project changes.
        /// It recalculates the backend hash and if it changes and automatic
        /// upload is enabled, it will perform the automatic upload.
        /// </summary>
        public static void OnAssemblyCompilationFinished()
        {
            var uploader = Uploader.GetDefaultInstance();

            bool upload = uploader.RecalculateBackendHash();

            if (upload && uploader.AutomaticUploadingEnabled)
            {
                uploader.UploadBackend(
                    verbose: false,
                    useAnotherThread: false
                    );
            }
        }
        /// <summary>
        /// Checks that the backend hash matches the reality and
        /// if so, registers the build. Else prints warning.
        /// </summary>
        private static void TryToRegisterTheBuild(BuildReport report)
        {
            // check that the backendHash in preferences is up to date
            bool uploadNeeded = Uploader.GetDefaultInstance()
                                .RecalculateBackendHash();

            if (uploadNeeded)
            {
                Debug.LogWarning(
                    "[Unisave] This backend has not yet been uploaded, " +
                    "therefore build registration is being skipped. " +
                    "Enable automatic backend upload or upload the backend " +
                    "manually before you build your game to resolve this issue."
                    );
                return;
            }

            // register the build
            BuildRegistrator
            .GetDefaultInstance()
            .RegisterBuild(report);
        }