Beispiel #1
0
    void EditGameGUI()
    {
        if (GUILayout.Button("Back"))
        {
            menuState    = MenuState.selectgame;
            editGameInfo = null;
        }

        if (editGameInfo == null || editGameID != editGameInfo.ID)
        {
            editGameInfo = null; lastMetaDownload = 0; metaIsUploaded = false;
            foreach (GameInfo info in gameList)
            {
                if (info.ID == editGameID)
                {
                    editGameInfo = info.Clone();
                    break;
                }
            }
        }
        if (editGameInfo == null)
        {
            return;
        }
        if (lastMetaDownload == 0 || lastMetaDownload != editGameInfo.ID)
        {
            lastMetaDownload = editGameInfo.ID;
            DownloadEditMetaData();
            metaIsUploaded = IsMetaDataOK(editGameInfo) == "";
        }
        EditorGUILayout.Separator();

        GUILayout.Label("How to upload your game?", "boldLabel");
        GUILayout.Label("1) Submit the required metadata.", "miniLabel");
        GUILayout.Label("2) Select and upload the required promotional images.", "miniLabel");
        GUILayout.Label("3) Press publish!", "miniLabel");
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();


        GUILayout.Label("Add your game:", "boldLabel");
        showStepOne = EditorGUILayout.Foldout(showStepOne, "1) Meta data:");
        if (showStepOne)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(40);
            GUILayout.BeginVertical();

            GUILayout.Label("The game description etc. After completing this information you'll be able to upload your game.", "miniLabel");
            EditorGUILayout.Separator();


            editGameInfo.title           = EditorGUILayout.TextField("Title:", editGameInfo.title);
            editGameInfo.gameCategory    = (WooglieCategories)EditorGUILayout.EnumPopup("Category:", editGameInfo.gameCategory);
            editGameInfo.gameState       = (WooglieGameState)EditorGUILayout.EnumPopup("State:", editGameInfo.gameState);
            editGameInfo.streamWebplayer = EditorGUILayout.Toggle("Stream webplayer:", editGameInfo.streamWebplayer);

            editGameInfo.gameWidth  = EditorGUILayout.IntField("Width", editGameInfo.gameWidth);
            editGameInfo.gameHeight = EditorGUILayout.IntField("Height", editGameInfo.gameHeight);

            editGameInfo.gameTags = EditorGUILayout.TextField("Tags:", editGameInfo.gameTags);
            //editGameInfo.gameWords = EditorGUILayout.TextField("+-5 words description:", editGameInfo.gameWords);

            editGameInfo.gameShort = EditorGUILayout.TextField("Short description:", editGameInfo.gameShort);
            GUILayout.Label("Controls:");
            editGameInfo.gameControls = EditorGUILayout.TextArea(editGameInfo.gameControls, GUILayout.Height(60));
            GUILayout.Label("Long description:");
            editGameInfo.gameLong = EditorGUILayout.TextArea(editGameInfo.gameLong, GUILayout.Height(100));

            //LIMIT
            editGameInfo.gameWidth  = Mathf.Clamp(editGameInfo.gameWidth, 100, 925);
            editGameInfo.gameHeight = Mathf.Clamp(editGameInfo.gameHeight, 100, 600);
            editGameInfo.title      = CapString(editGameInfo.title, 100);
            editGameInfo.gameWords  = CapString(editGameInfo.gameWords, 35);

            string err = IsMetaDataOK(editGameInfo);
            if (err != "")
            {
                GUI.color = Color.red;
                GUILayout.Label("Missing information: " + IsMetaDataOK(editGameInfo), "miniLabel");
                GUI.color = Color.white;
            }
            else
            {
                if (GUILayout.Button("Update metadata"))
                {
                    //SAVE META
                    bool wasOK = SaveMetaData(editGameInfo);
                    if (wasOK)
                    {
                        metaIsUploaded = IsMetaDataOK(editGameInfo) == "";
                        if (metaIsUploaded)
                        {
                            showStepOne = false;
                            showStepTwo = true;
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }


        showStepTwo = EditorGUILayout.Foldout(showStepTwo, "2) Upload images");
        if (showStepTwo)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(40);
            GUILayout.BeginVertical();

            if (!metaIsUploaded)
            {
                GUI.color = Color.red;
                GUILayout.Label("You can not yet upload the webplayer and images:\n- Upload your metadata first.", "miniLabel");
                GUI.color = Color.white;
            }
            else
            {
                GUILayout.Label("When you press publish, the game will be build and the images and game will be uploaded to Wooglie.com.", "miniLabel");

                if (textureIcon == null && settings.GetString("promoImagesIcon", "") != "")
                {
                    textureIcon = (Texture2D)AssetDatabase.LoadAssetAtPath(settings.GetString("promoImagesIcon", ""), typeof(Texture2D));
                }
                if (textureFeature == null && settings.GetString("promoImagesFeatured", "") != "")
                {
                    textureFeature = (Texture2D)AssetDatabase.LoadAssetAtPath(settings.GetString("promoImagesFeatured", ""), typeof(Texture2D));
                }


                GUILayout.BeginHorizontal();
                textureIcon = (Texture2D)EditorGUILayout.ObjectField("Icon:", textureIcon, typeof(Texture2D), false, GUILayout.Width(200));
                GUILayout.Label("Main icon\n100x100 ", "miniLabel");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();



                GUILayout.BeginHorizontal();
                textureFeature = (Texture2D)EditorGUILayout.ObjectField("*Feature:", textureFeature, typeof(Texture2D), false, GUILayout.Width(200));
                GUILayout.Label("Used when featured\n600x280\n*This image is optional", "miniLabel");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (GUI.changed)
                {
                    if (textureIcon != null)
                    {
                        string imgPath = AssetDatabase.GetAssetPath(textureIcon);
                        if (imgPath == "")
                        {
                            //string str = "(width:" + textureIcon.width + " height:" + textureIcon.height + ")";
                            textureIcon = null;
                            //EditorUtility.DisplayDialog("Error", "The image you selected does not match the required size (width: 100 height: 100), you select an image with the following sizes: "+str, "OK");
                        }
                        else
                        {
                            settings.SetString("promoImagesIcon", imgPath);
                        }
                    }
                    if (textureFeature != null)
                    {
                        string imgPath = AssetDatabase.GetAssetPath(textureFeature);
                        if (imgPath == "")
                        {
                            textureIcon = null;
                        }
                        else
                        {
                            settings.SetString("promoImagesFeatured", imgPath);
                        }
                    }
                }

                if (GUILayout.Button("Upload promo images"))
                {
                    //SAVE META
                    if (UploadFiles())
                    {
                        if (editGameInfo.uploadedAllImages)
                        {
                            showStepTwo   = false;
                            showStepThree = true;
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
        showStepThree = EditorGUILayout.Foldout(showStepThree, "3) Upload game");
        if (showStepThree)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(40);
            GUILayout.BeginVertical();

            if (editGameInfo.uploadedAllImages)
            {
                if (isUnityPRO)
                {
                    GUILayout.Label("You can simply use the button below to complete\n" +
                                    "your Wooglie submission. The tool will automatically build the game using your current\n" +
                                    "build scenes. Furthermore the WooglieAPI script will be added to your first screen to ensure no\n" +
                                    "other websites can copy your game.", "miniLabel");

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20);
                    if (GUILayout.Button("Upload game!", GUILayout.Width(100)))
                    {
                        startPublish = true;
                    }

                    GUILayout.EndHorizontal();
                }
                else
                {
                    /*   GUILayout.Label("Because you're using Unity FREE(Indie), you cant upload in one click;\nYou'll need to manually build a .unity3d webplayer and upload it using the form below.\nNote that the build NEEDS to include the WoogliePiracyProtection script, use the button below to add it to your project(or to test if it is in).", "miniLabel");
                     *
                     * GUILayout.Space(10);
                     *
                     * GUILayout.BeginHorizontal();
                     * GUILayout.Space(20);
                     * if (GUILayout.Button("Add/Test Wooglie script", GUILayout.Width(200)))
                     * {
                     *     testedScriptPresence = AddWooglieScript(true);
                     * }
                     *
                     * GUILayout.EndHorizontal();
                     *
                     * if (testedScriptPresence)
                     * {
                     *     GUILayout.Label("Upload webplayer:", "boldLabel");
                     *
                     *     if (!File.Exists(uploadFilePath)) uploadFilePath = "";
                     *     GUILayout.BeginHorizontal();
                     *     GUILayout.Space(20);
                     *     GUILayout.Label("Path: " + uploadFilePath, GUILayout.Width(200));
                     *     if (GUILayout.Button("Select a .unity3d webplayer", GUILayout.Width(200)))
                     *     {
                     *         uploadFilePath = EditorUtility.OpenFilePanel("Select a unity3d webplayer", "", "unity3d");
                     *     }
                     *     GUILayout.EndHorizontal();
                     *
                     *     if (uploadFilePath != "")
                     *     {
                     *         GUILayout.BeginHorizontal();
                     *         GUILayout.Space(20);
                     *         if (GUILayout.Button("Upload game!", GUILayout.Width(100)))
                     *         {
                     *             uploadIndieGame = "file:///" + uploadFilePath;
                     *         }
                     *         GUILayout.EndHorizontal();
                     *
                     *     }
                     * }*/
                }
                GUILayout.Space(10);
                GUILayout.Label("Privacy notice: Please note that with uploading your game you will also submit your\nUnity version and the build size log of the webplayer (if present).", "miniLabel");
            }
            else
            {
                GUI.color = Color.red;
                GUILayout.Label("You can not yet upload the webplayer:\n- Upload your images first.", "miniLabel");
                GUI.color = Color.white;
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
    }