public static string OnGUI_ScriptFlags(string symbols, bool forBuild)
    {
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        GUILayoutHelpers.CenterLabel("Script Options");
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        string newSymbols = string.Empty;

        foreach (var flag in flags)
        {
            if (!(forBuild && flag.hiddenInBuild))
            {
                var b = EditorGUILayout.Toggle(new GUIContent(flag.name, flag.description), IsDefined(symbols, flag.value));
                if (b)
                {
                    if (newSymbols.Length > 0)
                    {
                        newSymbols += ';' + flag.value;
                    }
                    else
                    {
                        newSymbols = flag.value;
                    }
                }
            }
        }

        return(newSymbols);
    }
Exemplo n.º 2
0
        void OnGUI_BuildPlatforms()
        {
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayoutHelpers.CenterLabel("Platforms");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            foreach (var p in PLATFORMS)
            {
                var b = EditorGUILayout.Toggle(p.name, p.shouldBuild);
                if (b != p.shouldBuild)
                {
                    p.shouldBuild = b;
                    EditorPrefs.SetBool("steambuild_" + p.name, b);
                }
            }
        }
Exemplo n.º 3
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            GUILayoutHelpers.HorzLine();

            {
                var s = BuildOptionsWindow.OnGUI_ScriptFlags(scriptFlags, true);
                if (s != scriptFlags)
                {
                    EditorPrefs.SetString("steamscriptflags", s);
                    scriptFlags = s;
                }
            }

            GUILayoutHelpers.HorzLine();

            OnGUI_BuildPlatforms();

            GUILayoutHelpers.HorzLine();

#if PERFORCE
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayoutHelpers.CenterLabel("Perforce");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            {
                var s = EditorGUILayout.TextField("P4 Directory", p4path);
                if (s != p4path)
                {
                    EditorPrefs.SetString("p4path", s);
                    p4path = s;
                }

                s = EditorGUILayout.TextField("P4 Server", p4server);
                if (s != p4server)
                {
                    EditorPrefs.SetString("p4server", s);
                    p4server = s;
                }

                s = EditorGUILayout.TextField("P4 User", p4user);
                if (s != p4user)
                {
                    EditorPrefs.SetString("p4user", s);
                    p4user = s;
                }

                s = EditorGUILayout.PasswordField("P4 Password", p4pass);
                if (s != p4pass)
                {
                    EditorPrefs.SetString("p4pass", s);
                    p4pass = s;
                }

                s = EditorGUILayout.TextField("P4 Workspace", p4client);
                if (s != p4client)
                {
                    EditorPrefs.SetString("p4client", s);
                    p4client = s;
                }
            }

            GUILayoutHelpers.HorzLine();
#endif

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayoutHelpers.CenterLabel("Steam");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            {
                var i = 0;
                while ((branch != BRANCHES[i]) && (i < BRANCHES.Length))
                {
                    ++i;
                }

                if (i >= BRANCHES.Length)
                {
                    i = 0;
                }

                var s = EditorGUILayout.Popup("Set Live", i, BRANCHES);
                if (s != i)
                {
                    branch = BRANCHES[s];
                    EditorPrefs.SetString("steambranch", branch);
                }
            }

            {
                var s = EditorGUILayout.TextField("Steam Login", steamLogin);
                if (s != steamLogin)
                {
                    EditorPrefs.SetString("steamlogin", s);
                    steamLogin = s;
                }
            }

            {
                var s = EditorGUILayout.PasswordField("Steam Password", steamPassword);
                if (s != steamPassword)
                {
                    EditorPrefs.SetString("steampass", s);
                    steamPassword = s;
                }
            }

            GUILayoutHelpers.HorzLine();

            bool build = false;

            if (GUILayout.Button("Build (testing only!)..."))
            {
                build = true;
            }

            bool publish = false;

            if (GUILayout.Button("Build and Publish..."))
            {
                publish = true;
                build   = true;
            }

            //if (GUILayout.Button("Retry Publish (careful!)...")) {
            //	publish = true;
            //}

            EditorGUILayout.EndVertical();

            string oldScriptFlags = null;

            if (build || publish)
            {
#if PERFORCE
                if (string.IsNullOrEmpty(p4path) || string.IsNullOrEmpty(p4server) || string.IsNullOrEmpty(p4user) || string.IsNullOrEmpty(p4pass) || string.IsNullOrEmpty(p4client))
                {
                    EditorUtility.DisplayDialog("Error", "Please fill in the perforce fields to build for Steam.", "OK");
                    return;
                }
#endif
                oldScriptFlags = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
            }

            if (build && publish)
            {
                var progress = new EditorProgressBar("Building...", 2);
                var r        = CheckForPrereqs() && Build();
                if (r)
                {
                    progress.Step("Publishing...");
                    r = Publish();
                    progress.Step(null);
                }
                else
                {
                    progress.Close();
                }

                if (r)
                {
                    EditorUtility.DisplayDialog("Success", "Build and publish completed successfully.", "OK");
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Build failed.", "OK");
                }
            }
            else if (build)
            {
                var progress = new EditorProgressBar("Building...", 1);
                var r        = CheckForPrereqs() && Build();
                progress.Step(null);
                if (r)
                {
                    EditorUtility.DisplayDialog("Success", "Build completed successfully.", "OK");
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Build failed.", "OK");
                }
            }
            else if (publish)
            {
                var progress = new EditorProgressBar("Publishing...", 1);
                var r        = CheckForPrereqs();
                if (r)
                {
                    progress.Step("Publishing...");
                    r = Publish();
                    progress.Step(null);
                }
                else
                {
                    progress.Close();
                }

                if (r)
                {
                    EditorUtility.DisplayDialog("Success", "Publish completed successfully.", "OK");
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Publish failed.", "OK");
                }
            }

            if (build || publish)
            {
                if (oldScriptFlags != PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone))
                {
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, oldScriptFlags);
                }
            }
        }