Exemplo n.º 1
0
    void DrawULogin()
    {
        if (subStep == 0)
        {
            DrawText("Now that you have all necessary, it's time to set up the ULogin files, first thing that you need to do is upload the php scripts in your web hosting directory," +
                     "these php scripts allow the communication from the game client to your server and the server handle with the Database stuff with the info receive from the client, but before that you need " +
                     "set some info in one of the php scripts.");
            DrawText("<b>Open</b> the script called <b>bl_Common.php</b> (on the PHP folder of ULogin)");
            DrawImage(GetServerImage(7));
            DownArrow();
            DrawText("In this scripts you need set the information of your database, that is used in order to access to the database for read and write when we required it, for obtain the information" +
                     " of the database varies of hosting on hosting, but in Awardspace you can get in: Hosting Tools -> MySQL DataBase -> (wait until load finish) -> click on the button under <b>Options</b>" +
                     " -> Information -> database information will display like this: ");
            DrawImage(GetServerImage(8));
            DownArrow();
            DrawText("Now in <b>bl_Common.php</b> you need set the database information like this");
            DrawHorizontalColumn("HOST_NAME", "The name of your host, get it from the database info in the hosting page");
            DrawHorizontalColumn("DATA_BASE_NAME", "The name the database, get it from the database info in the hosting page");
            DrawHorizontalColumn("DATA_BASE_USER", "The user name of the database, in Awardspace this is the same as the database name");
            DrawHorizontalColumn("DATA_BASE_PASSWORLD", "The password that you set when create the database");
            DrawHorizontalColumn("SECRET_KEY", "Set a custom 'password' key, that just work as a extra layer of security to prevent others can execute the php code, is <b>Highly recommended that you set your own secret key</b>, just make sure to remember it since you will need it in the next step.");
            DrawHorizontalColumn("ADMIN_EMAIL", "Your server email from where 'Register confirmation' will be send (Only require if you want use confirmation for register), <b>NOTE:</b> this email need to be configure in your hosting, in Awardspace you can create a " +
                                 "email account in <b>Hosting Tools -> E-mail Account</b>.");
            DrawText("So after you set all the info, your script should look like this (with your own info of course)");
            DrawImage(GetServerImage(21));
            DrawText("Don't forget to save the changes in the script.");
        }
        else if (subStep == 1)
        {
            /* if (fileUploader == null) fileUploader = new ULoginFileUploader(this);
             *
             * fileUploader.DrawGUI();*/

            DrawText("Now the next step is upload the server side scripts (.php, .sql and .xml) to your server domain directory.\n\nLets explain first in what consist a directory first, very short, let say your registered domain is <color=#79D3FFFF>myexampledomain.com</color>, that is the root of your domain address/URL, now you can create subfolders in that domain to extend the address, so if you create a folder called <i>phpfiles</i> then the address to point to that folder will be <color=#79D3FFFF>myexampldomain.com/phpfiles/</color> if you create another folder inside this you simple add the folder name plus a right-slash at the end.");

            DrawHyperlinkText("Now to manage your folders/domain directory and upload files to it you need an FTP Client, since some web hosting file uploaders don't support nested folders uploads we have to use <b>FileZilla FTP Client</b> to upload our files to our server, FileZilla is free software, you can download it here: <link=https://filezilla-project.org/>https://filezilla-project.org/</link> or using your preferred FTP Client program.\n\n<b>Download the FTP Client</b> not the FTP Server.\n\nOnce you download it -> install it following the installation wizard of the program -> then <b>Open</b> it.\n\nNow to be able to upload the files using this tools you need to set your FTP Credentials, all web hostings provide these credentials in their panel/dashboard, in Awardspace you can find these credentials in: <b>Hosting Tools -> FTP Manager</b>");
            DrawServerImage(16);
            DownArrow();
            DrawText("There you will see a form to create a FTP account, fill the required info and click on <b>Create FTP Account</b> button");
            DrawServerImage(17);
            DownArrow();
            DrawText("After this below that box you'll see the FTP Account section, there you should see the FTP account that you just create, click on the <i><b>settings</b></i> button on the right side of your FTP account -> then select the <b>Information</b> tab, there you will see your FTP account credentials with which you can access to your server:");
            DrawServerImage(18);
            DrawText("Now open FileZilla and at the top of the menu you will see the fields to insert your FTP credentials, insert the credentials showing in your hosting, in Awardspace, they are the ones that you just open above, once you insert the credentials click on the <b>Quickconnect</b> button, if the credentials are correct you should see a message like <i><b>Directory listing of \"/\" successful</b></i>, if that's so then you are ready to upload the files.");
            DrawServerImage(19);
            DownArrow();
            DrawText("So now on the FileZilla in the <b>Remote Site side panel</b> you should see a directory folder with at least a folder in it, open the folder <b>that has your domain name</b> -> now with the root directory open you have two options: upload the scripts files right there in the root or created a sub directory to be more organized, I recommend create a subfolder , for it simple right click on the window -> Create directory -> in the popup window that will appear set the folder name as you want, for this tutorial I will create two nested folders: <b>mygame -> php</b> <i>where I'll upload my files)</i>");
            DrawAnimatedImage(0);
            DrawText("With the created folder open you have to upload the ULogin Pro server files, for it in the Unity Editor go to the folder located at: <i><b>Assets -> Addons -> ULoginSystemPro -> Content -> Scripts-> Php</b></i> select one of the script on that folder -> Right Mouse Click over it -> Show on Explorer.");
            DrawServerImage(15, TextAlignment.Center);
            DrawText("Now in the OS window explorer <b>select all the files including the phpseclib folder</b> <i><size=10><color=#76767694>(without the .meta files)</color></size></i> and drag them in the <b>Remote Site</b> panel on <b>FileZilla</b>");
            DrawAnimatedImage(1);
            DownArrow();
            DrawText("Once all scripts are uploaded, copy the URL from the <b>Remote Site</b> directory field <i>(on FileZilla)</i>");
            DrawServerImage(20);
            DrawText("This is just the directory to your files folder container, you have to format it to a working URL <i>(add the HTTP prefix)</i>, for it simple paste the copied url bellow and click on <b>Format</b> button, after formated it -> click on the <b>Assign URL</b> button.");

            /* DrawServerImage(14, TextAlignment.Center);
             *
             * DrawText("In the new page you should see a directory panel with at least a folder in it, open the folder <b>that has your domain name</b> -> now with the root directory open you have two options: upload the scripts files right there in the root or created a sub directory to be more organized, I recommend create a subfolder , for it simple click on the button Create and in the popup window that will appear set the folder name as you want, for this tutorial I will call it as: <b>php</b> -> after creating the folder open it and click on the <b>Upload</b> button -> in the popup window that will show, drag all the scripts of the PHP folder from ULogin Pro as follow:\n\nIn the Unity Editor go to the folder located at: <i>Assets->Addons->ULoginSystemPro->Content->Scripts->Php</i> select one of the script on that folder -> Right Mouse Click over it -> Show on Explorer.\n");
             * DrawServerImage(15, TextAlignment.Center);
             * DownArrow();
             * DrawText("In your PC/Mac window explorer that will open select <b>ALL</b> the scripts <b>except</b> for the ones that ends with .meta, then drag all those in the Awardspace popup panel and click on the <b>Upload</b> button.\n");
             * DrawImage(GetServerImage(6));
             * DownArrow();
             * DrawText("Once all scripts are uploaded, copy the URL from the panel field <i>(<b>NOT</b> the browser search field)</i>");
             * DrawImage(GetServerImage(10));
             * DownArrow();
             * DrawText("Now this is just the directory to your files folder container, you have to convert to a working URL <i>(add the HTTP prefix)</i>, for it simple paste the copied url bellow and click on <b>Format</b> button, after formated click on the <b>Assign URL</b> button.");*/

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(100);
                if (string.IsNullOrEmpty(formatedURL))
                {
                    unformatedURL = EditorGUILayout.TextField(unformatedURL);
                    GUI.enabled   = !string.IsNullOrEmpty(unformatedURL);
                    if (GUILayout.Button("Format", EditorStyles.toolbarButton, GUILayout.Width(100)))
                    {
                        string url = unformatedURL;
                        if (url.StartsWith("/"))
                        {
                            url = url.Remove(0, 1);
                            url = $"http://www.{url}";
                        }
                        else if (!url.StartsWith("http"))
                        {
                            url = $"http://www.{url}";
                        }

                        if (!url.EndsWith("/"))
                        {
                            url += "/";
                        }
                        formatedURL = url;
                        GUI.FocusControl(null);
                        Repaint();
                    }
                }
                else
                {
                    GUILayout.Label(EditorGUIUtility.IconContent("Collab").image, GUILayout.Width(20));
                    formatedURL = EditorGUILayout.TextField(formatedURL);
                    GUI.enabled = !string.IsNullOrEmpty(formatedURL);
                    if (GUILayout.Button("Assign URL", EditorStyles.toolbarButton, GUILayout.Width(100)))
                    {
                        bl_LoginProDataBase.Instance.PhpHostPath = formatedURL;
                        EditorUtility.SetDirty(bl_LoginProDataBase.Instance);
                        Selection.activeObject = bl_LoginProDataBase.Instance;
                        EditorGUIUtility.PingObject(bl_LoginProDataBase.Instance);
                    }
                }
                GUI.enabled = true;
                GUILayout.Space(100);
            }
            GUILayout.EndHorizontal();
            DownArrow();
            DrawHyperlinkText("Now in the Inspector Window of the Unity Editor you should see the fields of <link=asset:Assets/Addons/ULoginSystemPro/Content/Resources/LoginDataBasePro.asset>LoginDataBasePro</link> <i>(otherwise click the button bellow)</i>, if everything work correctly you should see your URL assigned in the <b>PhpHostPath</b> field.\n\n-Remember from the last step the <b>SecretKey</b> that was in <b>bl_Common.php -> SECRET_KEY</b>, if you have change it in <b>bl_Common.php</b> you have to set the same Key in the field <b>Secret Key</b> of <link=asset:Assets/Addons/ULoginSystemPro/Content/Resources/LoginDataBasePro.asset>LoginDataBasePro</link>.");
            DrawImage(GetServerImage(11));
            if (DrawButton("LoginDataBasePro"))
            {
                Selection.activeObject = bl_LoginProDataBase.Instance;
                EditorGUIUtility.PingObject(bl_LoginProDataBase.Instance);
            }
        }
        else if (subStep == 2)
        {
            DrawText("Now you need set up the tables in your database, for this we'll use SQL, you can do that manually or automatically," +
                     "for do it manually you can use some database tool like PhpMyAdmin and run the SQL query in their sql panel or you can do it here.");
            DownArrow();
            DrawText("First lets check that the tables has not been created yet, click on the button bellow to check the tables.");
            GUILayout.Space(5);
            bool isLURL = bl_LoginProDataBase.Instance.PhpHostPath.Contains("lovatto");
            if (isLURL)
            {
                GUILayout.Label("<color=red>You're still using the lovatto studio url which is for demonstration only, please use your own url to continue.</color>");
            }
            GUI.enabled = (checkID == 0 && !isLURL);
            if (DrawButton("Check Tables"))
            {
                WWWForm wf = new WWWForm();
                wf.AddField("type", 3);
                www.SendRequest(bl_LoginProDataBase.Instance.GetUrl(bl_LoginProDataBase.URLType.Creator), wf, CheckResult);
                checkID = 1;
            }
            GUI.enabled = true;
            if (checkID == 1)
            {
                GUILayout.Label("LOADING...");
            }
            else if (checkID == 2)
            {
                GUILayout.Label("RESULT: " + checkLog);
            }
            else if (checkID >= 3)
            {
                GUI.enabled = (checkID == 3);
                DrawText("Ok, we have checked and tables are not created yet, so we can do it now, click on the button bellow to create tables");
                GUILayout.Space(5);
                if (DrawButton("Create Tables"))
                {
                    /* WWWForm wf = new WWWForm();
                     * wf.AddField("type", 4);
                     * www.SendRequest(bl_LoginProDataBase.Instance.GetUrl(bl_LoginProDataBase.URLType.Creator), wf, CheckCreation);*/
                    EditorCoroutines.StartBackgroundTask(DoCreateTables());
                    checkID = 4;
                }
                GUI.enabled = true;
                if (checkID == 4)
                {
                    GUILayout.Label("LOADING...");
                }
                if (checkID == 5)
                {
                    DrawText("Done!, Tables has been created successfully.");
                }
                else if (checkID == 6)
                {
                    DrawText("Couldn't create tables error: <color=red>" + checkLog + "</color>");
                }
            }
        }
        else if (subStep == 3)
        {
            DrawText("Done!, you have set up your database and are ready to use ULogin System!");
            DownArrow();
            DrawText("So let me explain some the rest of options in <b>LoginDataBasePro</b>");
            DrawHorizontalColumn("Update IP", "ULogin collect the IP of the register user in order to block their IP if they get banned in game, if you enable this ULogin will check the IP each time" +
                                 " that the user log-in so always keep the store IP update");
            DrawHorizontalColumn("Detect Ban", "Basically is = to say: you wanna use Ban Features.");
            DrawHorizontalColumn("Require Email Verification", "After register a account user is required to verify his email in order to log-in?");
            DrawHorizontalColumn("Check Ban In Mid", "Check if the player has not been banned each certain amount of time, if this is false that check will only be fire when player log-in");
            DrawHorizontalColumn("Can Register Same Email", "Can a email be use to register different accounts?");
        }
    }