question

sezerbulanik avatar image
sezerbulanik asked

project merge

LOGİN STAGE CS.

public class PlayfabAuth : MonoBehaviour
{
    public InputField Username;
    public InputField Password;
    public string LevelToload;
    //public GetPlayerCombinedInfoRequestParams info;
    //public int Gold = 0;
    //public Text GoldText;
    public void Login()
    {
       LoginWithPlayFabRequest request = new LoginWithPlayFabRequest();
        //request.InfoRequestParameters=info;
        request.Username = Username.text;
        request.Password = Password.text;
        PlayFabClientAPI.LoginWithPlayFab(request, result =>
        {
            //Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
          
           Alerts a = new Alerts();
            StartCoroutine(a.CreateNewAlert(Username.text + "You have logged in!"));
           SceneManager.LoadScene(LevelToload);
          
        }, error =>
        {
           Debug.LogError(error.ErrorMessage);
            {
                Alerts a = new Alerts();
                StartCoroutine(a.CreateNewAlert(error.ErrorMessage));
            }
        });

    }

________________________________________________________________________________________
THIS IS OTHER SCENE CS. HOW TO COMBINE THE TWO



public class MPManager : MonoBehaviourPunCallbacks
{
    //public string LevelToload;
    public items[] items;
    //public InputField Username;
    //public InputField Password;
    public GameObject[] EnableOnLogin;
    public GameObject NewsPanel;
    public GameObject NewsView;
    public GetPlayerCombinedInfoRequestParams info;
    public Text GoldText;
    public int Gold = 0;
    public GameObject[] EnableObjectsOnConnect;
    public GameObject[] DislabeObjectsOnConnect;
   
    
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
        LoginWithPlayFabRequest LoginRequest = new LoginWithPlayFabRequest();
        //LoginRequest.Username = Username.text;
        //LoginRequest.Password = Password.text;
        LoginRequest.InfoRequestParameters = info;
       PlayFabClientAPI.LoginWithPlayFab(LoginRequest, result =>
       {
            Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
          // Alerts a = new Alerts();
           //StartCoroutine(a.CreateNewAlert(Username.text + "You have logged in!"));
           //SceneManager.LoadScene(LevelToload);
       }, error => { Debug.LogError(error.ErrorMessage);{
              // Alerts a = new Alerts();
               //StartCoroutine(a.CreateNewAlert(error.ErrorMessage));
           } });
        foreach (GameObject obj in EnableOnLogin)
        {
            obj.SetActive(true);
        }
        



1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image Sarah Zhang commented ·

Could you provide your specific needs and what results do you want to achieve?

0 Likes 0 ·

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

I’m not very sure how you want to merge these two code files. But generally, the clients just need to log in once in one game session. If you only want to get the player’s virtual currency in the second code file, API GetUserInventory can be called for it. Log in API just should be used for login, in the API LoginWithPlayFab,fields of username and password are required, they are unable to be null when you call LoginWithPlayFab.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.