question

rosscogamesbusiness avatar image
rosscogamesbusiness asked

How do I fix this error regarding PlayFabAuthManager in the Unity PlayFab SDK?

I am trying to make a user account system for my Unity3D game. I have the basics of the UI all done, I just need the functionality to work. When I try to use "PlayFabAuthManager" following the "Unity Player Login" tutorial on YouTube, I get this error:

"error CS0246: The type or namespace name `PlayFabAuthManager' could not be found. Are you missing an assembly reference?"


Here is the YouTube video: https://www.youtube.com/watch?v=QPRqaRQ4K7g&t=1362s


Here is my code: (the problem is around line 63, and repeats on lines 154 and 160)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using PlayFab;
using PlayFab.ClientModels;
using PlayFab.Events;


public class Register : MonoBehaviour {


	public GameObject username;
	public GameObject email;
	public GameObject password;
	public GameObject confPassword;


	public string Username;
	public string Email;
	public string Password;
	public string ConfPassword;


	public string form;
	private bool emailValid = true;


	public string path = @"C:\AccountInformation\";


	public string key;


	public Text LogInErrorText;


	public enum LinkTypes {
		PlayFab = 0,
		Facebook = 1,
		Google = 2,
		Steam = 3,
		Kongregate = 4,
		Custm = 5,
		Ios = 6,
		Android = 7,
		None = -1
	};


	public string TitleId;


	public static UserAccountInfo AccountInfo;


	public WebRequestType PlayFabRequestType = WebRequestType.HttpWebRequest;


	public delegate void PlatformCheckCompleteHandler (LinkTypes linkType);
	public static event PlatformCheckCompleteHandler OnPlatformCheckComplete;


	public delegate void PlayFabReturnPlayerCheckCompleteHandler (LinkTypes linkType);
	public static event PlayFabReturnPlayerCheckCompleteHandler OnReturnPlayerCheckComplete;


	public delegate void PlayFabAuthenticationCompleteHandler (LinkTypes linkType, LoginResult result);
	public static event PlayFabAuthenticationCompleteHandler OnPlayFabAuthComplete;


	public delegate void PlayFabAuthenticationErrorHandler (LinkTypes linkType, LoginResult result);
	public static event PlayFabAuthenticationErrorHandler OnPlayFabAuthError;


	public static PlayFabAuthManager Instance { get; private set; }


	void Start () {
		
	}


	void Update () {
		Username = username.GetComponent<InputField> ().text;
		Password = password.GetComponent<InputField> ().text;
		Email = email.GetComponent<InputField> ().text;
		ConfPassword = confPassword.GetComponent<InputField> ().text;
		PlayFabSettings.TitleId = TitleId;
	}


	public void RegisterButton () {
		Debug.Log ("Attempting");
		bool UN = false;
		bool EM = false;
		bool PW = false;
		bool CPW = false;


		if (Username == "") {
			Debug.Log ("Username field empty");
		} else {
			if (File.Exists (path + Username + ".txt")) {
				Debug.Log ("Username taken");
			} else {
				UN = true;
			}
		}


		if (Password == "") {
			Debug.Log ("Password field empty");
		} else {
			key = Password;
			//Password = Encrypt (Password);
			PW = true;
		}


		if (ConfPassword == "") {
			Debug.Log ("Confirm pass field empty");
		} else {
			if (ConfPassword != Password) {
				Debug.Log ("Passwords don't match");
			} else {
				CPW = true;
			}
		}


		if (Email == "") {
			Debug.Log ("Email field empty");
		} else {
			if (Email.Contains ("@") && Email.Contains (".")) {
				Email = Encrypt (Email);
				EM = true;
			} else {
				Debug.Log ("Email address invalid format");
			}
		}


		if (UN == true && EM == true && PW == true && CPW == true) {
			/*string info = (Username + "\n" + Password + "\n" + Email);
			File.WriteAllText (path + Username + ".txt", info);*/


			RegisterAccount ();
		}
	}


	private string Encrypt (string pass) {
		System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
		byte[] bs = System.Text.Encoding.UTF8.GetBytes(pass);
		bs = x.ComputeHash(bs);
		System.Text.StringBuilder s = new System.Text.StringBuilder();
		foreach (byte b in bs) {
			s.Append(b.ToString("x2").ToLower());
		}
		return s.ToString();
	}


	public void RegisterAccount () {
		var loginRequest = new LoginWithPlayFabRequest () {
			TitleId = PlayFabSettings.TitleId,
			Username = Username,
			Password = Password
		};


		PlayFabClientAPI.LoginWithPlayFab (loginRequest, (result) => {
			LoginRegisterSuccess (result.PlayFabId);
		}, (error) => {
			LogInErrorText.text = error.ErrorMessage;
			LogInErrorText.gameObject.SetActive(true);
			PlayFabErrorHandler.HandlePlayFabError(error);


		});
	}


	public void LoginRegisterSuccess (string PlayFabId){
		PlayFab.PlayFabAuthManager.PlayFabId = PlayFabId;
		LogInErrorText.gameObject.SetActive (false);
	}
}
unity3dphotonAuthentication
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.

rosscogamesbusiness avatar image rosscogamesbusiness commented ·

Update: lines 79, 182, and 190, not the other three lines I specified.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

That specific error means that something's invalid in the project setup. A few questions:

What version of the SDK are you using?

How are you setting up your project - do you clone the SDK, download as a Zip, etc.?

If you Clone the SDK (do not unpack the Unitypackage, as that would then duplicate files) and move over only your game's files, are you able to build?

2 comments
10 |1200

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

rosscogamesbusiness avatar image rosscogamesbusiness commented ·

I am using the latest SDK version (2.29.171016), I downloaded the SDK and the Editor Extensions as the .unitypackage files. I am able to build without the SDK and have done in the past.

0 Likes 0 ·
brendan avatar image brendan rosscogamesbusiness commented ·

And if you start a new project, clone the SDK but do not unpack the unitypackage, and move over your game files, does that build?

0 Likes 0 ·

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.