我是全新的,无论如何我已经下载了unity的样本文件,我已经在常量文件中传递了API密钥和秘密密钥。
当我在unity编辑器中运行文件时,我得到了许多按钮,我试图点击(创建用户),但我得到了这个错误
App42Exception: EmailAddress is Not Validcom.shephertz.app42.paas.sdk.csharp.util.Util。ThrowExceptionIfEmailNotValid(系统。对象obj,系统。字符串名称)com.shephertz.app42.paas.sdk.csharp.user.UserService。CreateUser(系统。String uName, System。字符串pwd, System。字符串emailAddress, App42CallBackUserTest。OnGUI () (at Assets/scripts/UserTest.cs:49)
======================================
I have change
公共string emailId = ";//创建用户的EmailId
constant.cs脚本文件
,这应该没有错误。好吧,我试过了,我仍然得到相同的错误。
======================================
你知道我在哪里可以找到一个示例文件来创建一个用户,其中包含三个输入字段来放置电子邮件,用户和密码以及一个按钮来创建用户。我想要一个样本统一文件,包含所有需要这样做的代码,我唯一要修改的是秘密和API密钥。
我只是想知道这是如何工作的,我发现SDK复杂的样本文件。所以我想要一个示例文件,有"创建用户"在Unity (c#)中使用它。
我试图在unity中创造一款简单的2D游戏,要求用户创建一个帐户(用户名,电子邮件,密码),但我没有找到足够的教程和说明来做到这一点。
在App42的文档中,如果你不从"入门"开始,你会错过很多东西。
如果你想创建用户,首先你应该导入
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.user;
那么我用了一个简单的代码
public class App42Manager : MonoBehaviour {
private const string apiKey = "******";
private const string secretKey = "*****";
//Service for creating, authenticating, deleting, updating User.
private UserService userService;
//User object that keeps informations about user.
public static User user = new User();
string username = "";
string password = "";
string email = "";
void Start () {
App42API.Initialize(apiKey,secretKey);
userService = App42API.BuildUserService();
}
// call this function when user enter all informations and click button
void CreateUser(string usrnm,string psswrd, string eml)
{
username = usrnm;
password = psswrd;
email = eml;
//You can write your own conditions here.
if(!username.Equals("") && !password.Equals("") && !email.Equals("")
userService.CreateUser(username,password,email,CreateUserCallBack());
}
}
public class CreateUserCallBack : App42CallBack
{
public void OnSuccess(object response)
{
User user = (User)response;
/* This will create user in App42 cloud and will return User object */
Debug.Log("CreateUser: userName is" + user.GetUserName());
Debug.Log("CreateUser: email is" + user.GetEmail());
App42Manager.user = this.user;
}
public void OnException(System.Exception e)
{
Debug.Log("CreateUser: Exception : " + e);
}
}