在Windows Phone中解析Unity崩溃

时间:2015-04-30 07:47:02

标签: windows-phone-8 parse-platform crash windows-store

我已经完成了Unity游戏,我希望在Google Play,Windows Phone Store和Windows 8商店中发布。我使用的是最后一个版本的Parse for Unity SDK(1.4.1)以及最后一个版本的Unity Editor(4.6.4p4),包括最后一个补丁。

我在游戏中实现的Parse实现完美适用于: - Unity Editor(所有平台) - Android(在两台设备上部署apk) - Android(将游戏发布为alpha,将其安装在+8设备中) - Windows Phone 8(所有Windows Phone模拟器 - 8.0和8.1 - x86) - Windows Phone 8(使用Visual Studio 2012 for Windows Phone和Visual Studio 2013社区 - ARM在设备上进行调试)

它的作用是: - Windows Phone 8(部署为Beta版) - Windows Phone 8(部署为隐藏版本)

每当我尝试使用Parse SDK的任何功能时游戏崩溃,都不会引发任何异常,Windows Phone 8商店没有给我任何关于任何崩溃的信息......看起来像装配加载问题......

我不知道发生了什么,这个问题阻止我发布我的游戏,想想我疯了......

所以,我已经制作了一个简单的虚拟应用程序来测试我的解析实现,并且......它有同样的问题...它很简单:只有一个游戏对象有&#34 ;解析初始化行为"附加(设置了AppId和.NET键)和一个非常简单的脚本:

    using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.IO;
using System.Text;
using System;
using System.Linq;
using Parse;
using System.Threading.Tasks;


// Demo application script
public class AppScript : MonoBehaviour
{
    public static string userName = "Caldofran";
    public static string userPass = "Password5";
    public static string userEmail = "caldofran@email.com";
    public static string errAsincrono = "";
    public static string log = "";

    public static bool bLogin = false;
    public static bool bSignUp = false;

    // Use this for initialization
    void Start () {

        //Application.runInBackground = true;

    }


    GUIStyle ts = new GUIStyle();

void OnGUI()
    {
            if (GUI.Button(new Rect(10, 100, 100, 30), "Sign Up"))
                SignUp(userName,userPass, userEmail);

            if (GUI.Button(new Rect(10, 150, 100, 30), "Login"))
                Login(userName, userPass);


                if (GUI.Button(new Rect(10, 200, 100, 30), "Logout"))
                    Logout();

        if (GUI.Button(new Rect(10, 300, 100, 30), "Clear Texts"))
        {
            errAsincrono = "";
            log = "";
        }


            int left = Screen.width - 110;

            string usrParse = "";

            if (AppScript.IsLoggedInParse())
                usrParse = ParseUser.CurrentUser.Username;

            ts.normal.textColor = Color.red;

            GUI.BeginGroup(new Rect(300, 5, 600, 500));
            GUI.Box(new Rect(0, 0, 400, 300), "");
            //GUILayout.Label("P: " + mensajeGUI);
        GUILayout.Label("User Config: " + userName, ts);
        GUILayout.Label("Pass config: " + userPass, ts);
        GUILayout.Label("email config: " + userEmail, ts);
        GUILayout.Label("Logged in parse: " + AppScript.IsLoggedInParse().ToString(), ts);
            GUILayout.Label("Parse logged user: " + usrParse, ts);
        GUILayout.Label("Last msg: " + errAsincrono, ts);
        GUILayout.Label("Last Log: " + log, ts);

            GUI.EndGroup();
    }   

    // Update is called once per frame
    void Update () {


        if (bLogin)
        {
            bLogin = false;
            log += " Login Update text";
        }

        if (bSignUp)
        {
            bSignUp = false;
            log += " SignUp Update text";
        }


    }



    #region Parse

    public static bool IsLoggedInParse()
    {
        bool retorno = false;
        if ((ParseUser.CurrentUser != null) && (ParseUser.CurrentUser.IsAuthenticated))
            retorno = true;

        return retorno;
    }

    public static void SignUp(string userName, string passWord, string email)
    {
        var user = new ParseUser()
        {
            Username = userName,
            Password = passWord
        };
        if (string.IsNullOrEmpty(email))
            user.Email = "";
        else
            user.Email = email;

        try
        {
            Task signUpTask = user.SignUpAsync().ContinueWith(t=>
            {
                if (t.IsFaulted || t.IsCanceled)
                {
                    // The login failed. Check the error to see why.
                    foreach(var e in t.Exception.InnerExceptions) {
                        ParseException parseException = (ParseException) e;
                        log += parseException.Message + ": CODE: " +  parseException.Code.ToString();
                    }
                    errAsincrono = t.Exception.Message;
                }
                else
                {
                    // Signup was successful.
                    log = "Welcome " + userName;
                    bSignUp = true;
                }
            });
        }
        catch (Exception ex)
        {
            errAsincrono =  "Error: " + ex.Message;
        }
    }

    public static void Login(string user, string pass)
    {
        try
        {
            ParseUser.LogInAsync(user, pass).ContinueWith(t =>
             {
                 if (t.IsFaulted || t.IsCanceled)
                 {
                     // The login failed. Check the error to see why.
                    foreach(var e in t.Exception.InnerExceptions) {
                        ParseException parseException = (ParseException) e;
                        log += parseException.Message + ": CODE: " +  parseException.Code.ToString();
                    }
                    errAsincrono = t.Exception.Message;
                 }
                 else
                 {
                     // Login was successful.
                    log = "Welcome back " + userName;
                    AppScript.bLogin = true;
                 }
             });
        }
        catch (Exception ex)
        {
            errAsincrono =  "Error: " + ex.Message;
        }
    }

    public static void ResetPassword(string email)
    {
        if (IsLoggedInParse())
        {
            Task requestPasswordTask = ParseUser.RequestPasswordResetAsync(email);
            log = "Pass reset ok";
        }
    }

    public static void Logout()
    {

        if (IsLoggedInParse())
        {
            ParseUser.LogOutAsync();
            log = "Logged out ";
        }
    }

    #endregion


}

有人可以试试吗?我做错了什么?为什么这段代码几乎总是在Windows Phone中运行(在商店中发布)?

我已经阅读过Unity错误,它只影响到iOS:http://forum.unity3d.com/threads/unity-5-parse-ios-nsurlerrordomain-error-1012.308569/ 此错误(使用WWW通过SSL)会影响Windows Phone应用程序吗?

1 个答案:

答案 0 :(得分:0)

就我而言,使用Parse SDK 1.6.1 for Windows。 设置Password属性会抛出ArgumentException。 原因在于Master构建配置和.NET Native工具链。

解决方案1:
取消选中"使用.NET Native工具链编译"在Project的Build设置中。

解决方案2:
创建ParseUser的子类并定义" new"属性用户名和密码。