예제 #1
0
    void loginWindow(int id)
    {
        GUI.Label(new Rect(10, 20, 100, 30), "User Name");
        username = GUI.TextField(new Rect(10, 40, 180, 30), username);
        GUI.Label(new Rect(10, 90, 100, 30), "Password");
        password = GUI.PasswordField(new Rect(10, 110, 180, 30), password, '*');
        if (GUI.Button(new Rect(10, 150, 80, 30), "Cancel"))
        {
            isLogin = false;
        }
        if (GUI.Button(new Rect(100, 150, 80, 30), "Login"))
        {
            int connect_result = EmotivCloudClient.EC_Connect();
            if (connect_result == EmotivCloudClient.EC_OK)
            {
                var login_result = EmotivCloudClient.EC_Login(username, password);
                if (login_result == EmotivCloudClient.EC_OK)
                {
                    Debug.Log("login success");
                    EmotivCloudClient.EC_GetUserDetail(ref userCloudId);
                    Debug.Log("user cloud id: " + userCloudId.ToString());
                    nProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudId);
                    Debug.Log("number profiles: " + nProfile.ToString());
                    profiles = new List <PROFILE>();
                    for (var i = 0; i < nProfile; i++)
                    {
                        //Debug.Log("delete profile: ");
                        //var _id = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        //EmotivCloudClient.EC_DeleteUserProfile(userCloudId, _id);

                        int ii = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        EmotivCloudClient.Plugin_EC_ProfileNameAtIndex(userCloudId, 0);
                        PROFILE t = new PROFILE();
                        t.id   = EmotivCloudClient.EC_ProfileIDAtIndex(userCloudId, i);
                        t.name = EmotivCloudClient.Plugin_EC_ProfileNameAtIndex(userCloudId, i);
                        profiles.Add(t);
                        Debug.Log("profile name: " + profiles[i].name + " profile id: " + profiles[i].id.ToString());
                    }
                    isLogin = false;
                }

                else
                {
                    Debug.Log("cannot login, error: " + login_result.ToString());
                }
            }
            else
            {
                Debug.Log("cannot connect to emotiv cloud, error: " + connect_result.ToString());
            }
        }
        if (userCloudId != -1) //logged in
        {
            if (GUI.Button(new Rect(10, 150, 80, 30), "Load Profile"))
            {
            }
        }
    }
예제 #2
0
        static void SavingLoadingFunction(int mode)
        {
            int getNumberProfile = EmotivCloudClient.EC_GetAllProfileName(userCloudID);

            if (mode == 0)
            {
                int profileID = EmotivCloudClient.EC_GetProfileId(userCloudID, profileName);

                if (profileID >= 0)
                {
                    Console.WriteLine("Profile with " + profileName + " is existed");
                    if (EmotivCloudClient.EC_UpdateUserProfile(userCloudID, engineUserID, profileID, profileName))
                    {
                        Console.WriteLine("Updating finished");
                    }
                    else
                    {
                        Console.WriteLine("Updating failed");
                    }
                }
                else if (EmotivCloudClient.EC_SaveUserProfile(userCloudID, (int)engineUserID, profileName, EmotivCloudClient.profileFileType.TRAINING))
                {
                    Console.WriteLine("Saving finished");
                }
                else
                {
                    Console.WriteLine("Saving failed");
                }

                Thread.Sleep(5000);
                return;
            }
            if (mode == 1)
            {
                if (getNumberProfile > 0)
                {
                    if (EmotivCloudClient.EC_LoadUserProfile(userCloudID, engineUserID, EmotivCloudClient.EC_ProfileIDAtIndex(userCloudID, 0), version))
                    {
                        Console.WriteLine("Loading finished");
                    }
                    else
                    {
                        Console.WriteLine("Loading failed");
                    }
                }

                Thread.Sleep(5000);
                return;
            }
        }