• 大小: 79KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: Java
  • 标签: Unity  

资源简介

Unity微信支付,Unity工程项目,仅供学习如需要java端请留言

资源截图

代码片段和文件信息

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System.Text;
using UnityEngine.UI;
public class Test : MonoBehaviour {
    AndroidJavaobject javaActive;
    public Text text;
    public InputField inputf;
    // Use this for initialization
    [System.Serializable]
    public class ModelTest
    {
        public string prepayid;
        public string noncestr;
        public string timestamp;
        public string sign;
    }

    private void Start()
    {
        AndroidJavaClass javaClass = new AndroidJavaClass(“com.unity3d.player.UnityPlayer“);
        javaActive = javaClass.GetStaticject>(“currentActivity“);
        Debug.Log(javaActive);
    }
    public void Button1() {       
        object[] objs = new object[] { inputf.text “商品描述“  “https://www.baidu.com“ “Main Camera“ “回调函数“ };
         javaActive.Call(“LocationPayReq“ objs);


        //object[] objs = new object[] { “aaaaa“ };

       // print(javaActive.Call(“aaa“ objs));

    }

    public void Button2()
    {
        StartCoroutine(test());
    }

     IEnumerator test()
    {

        UnityWebRequest www = UnityWebRequest.Get(“http://accounts.zyqpyx.com/api/login/pay“);
        yield return www.SendWebRequest();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.LogError(www.error);
        }
        else
        {
            //Debug.Log(www.downloadHandler.text);

            ModelTest obj = JsonUtility.FromJson(www.downloadHandler.text);
            Debug.Log(“ss“+obj.sign);

            object[] objs = new object[] { obj.prepayid obj.noncestr obj.timestampobj.sign “Main Camera“ “回调函数“ };
            javaActive.Call(“WeiChatPayReq“ objs);
        }

    }

    public void 回调函数(string s)
    {
        print(s);
        if (s==“0“)
        {
            print(“支付成功“);
            text.text = “支付成功“;
        }
        else if(s == “-2“)
        {
            print(“支付取消“);
            text.text = “支付取消“;
        }
        else
        {
            print(“支付失败“);
            text.text = “支付失败“;
        }
        
    }

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

}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-05 16:18  unitywxpay\
     目录           0  2018-01-05 16:18  unitywxpay\Assets\
     文件       35722  2018-01-05 16:17  unitywxpay\Assets\1.unity
     文件         196  2018-01-04 18:01  unitywxpay\Assets\1.unity.meta
     目录           0  2018-01-05 16:18  unitywxpay\Assets\Plugins\
     文件         213  2018-01-04 17:41  unitywxpay\Assets\Plugins.meta
     目录           0  2018-01-05 16:18  unitywxpay\Assets\Plugins\Android\
     文件         213  2018-01-04 17:41  unitywxpay\Assets\Plugins\Android.meta
     文件         893  2018-01-05 10:37  unitywxpay\Assets\Plugins\Android\AndroidManifest.xml
     文件         199  2018-01-04 17:41  unitywxpay\Assets\Plugins\Android\AndroidManifest.xml.meta
     文件       56552  2018-01-05 15:19  unitywxpay\Assets\Plugins\Android\app-debug.aar
     文件         573  2018-01-05 13:01  unitywxpay\Assets\Plugins\Android\app-debug.aar.meta
     文件        2399  2018-01-05 16:12  unitywxpay\Assets\Test.cs
     文件         284  2018-01-04 17:57  unitywxpay\Assets\Test.cs.meta
     目录           0  2018-01-05 16:18  unitywxpay\ProjectSettings\
     文件         357  2018-01-04 17:39  unitywxpay\ProjectSettings\AudioManager.asset
     文件         114  2018-01-04 17:39  unitywxpay\ProjectSettings\ClusterInputManager.asset
     文件         763  2018-01-04 17:39  unitywxpay\ProjectSettings\DynamicsManager.asset
     文件         138  2018-01-04 17:39  unitywxpay\ProjectSettings\EditorBuildSettings.asset
     文件         589  2018-01-04 17:39  unitywxpay\ProjectSettings\EditorSettings.asset
     文件        2290  2018-01-04 17:44  unitywxpay\ProjectSettings\GraphicsSettings.asset
     文件        5793  2018-01-04 17:39  unitywxpay\ProjectSettings\InputManager.asset
     文件        1308  2018-01-04 17:39  unitywxpay\ProjectSettings\NavMeshAreas.asset
     文件         151  2018-01-04 17:39  unitywxpay\ProjectSettings\NetworkManager.asset
     文件        1400  2018-01-04 17:39  unitywxpay\ProjectSettings\Physics2DSettings.asset
     文件       17898  2018-01-05 16:17  unitywxpay\ProjectSettings\ProjectSettings.asset
     文件          28  2018-01-04 17:39  unitywxpay\ProjectSettings\ProjectVersion.txt
     文件        4864  2018-01-04 17:39  unitywxpay\ProjectSettings\QualitySettings.asset
     文件         378  2018-01-04 17:39  unitywxpay\ProjectSettings\TagManager.asset
     文件         202  2018-01-04 17:39  unitywxpay\ProjectSettings\TimeManager.asset
     文件         812  2018-01-04 17:39  unitywxpay\ProjectSettings\UnityConnectSettings.asset
............此处省略2个文件信息

评论

共有 条评论