//void Awake() //{ // if (weiXinLoad.show == true) // { // GameObject.Find("Canvas_laod").SetActive(false); // } //} void Start() { ResouseManager.Instance.Start(); Screen.sleepTimeout = (int)SleepTimeout.NeverSleep; instance = this; login_effect = GameObject.Find("Main Camera").GetComponent <AudioSource>(); Music_Control.music_effect(login_effect); main_image = GameObject.Find("main").GetComponent <Button>(); main_image.enabled = false; GameObject.Find("gongGao").GetComponent <Button>().onClick.AddListener(() => method("Notice", Vector3.one, true)); GameObject touObj = GameObject.Find("tourist"); GameObject weChatObj = GameObject.Find("weChat"); #if UNITY_IOS if (weiXinLoad.instance.AndroidFunction == false) { if (UnitySendMessageToiOS.Instante().checkInstallWeChat() != 0) { weChatObj.transform.localScale = Vector3.zero; touObj.transform.localPosition = Vector3.Lerp(touObj.transform.localPosition, weChatObj.transform.localPosition, 0.5f); } } #elif UNITY_ANDROID { weChatObj.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f); } #endif touObj.GetComponent <Button>().onClick.AddListener(delegate() { loadGameScene(false, true, false); }); //游客登陆 weChatObj.GetComponent <Button>().onClick.AddListener(delegate() { loadGameScene(false, false, true); }); //微信登陆 main_image.onClick.AddListener(close_Account); }
/// <summary> /// 截图 /// </summary> /// <returns></returns> IEnumerator getTexture2d(int type) { string filename = "wxshare.png"; string destination = isAndroidPlatform()?"/sdcard/DCIM/Camera":Application.persistentDataPath; //"/sdcard/DCIM"; if (!Directory.Exists(destination)) //判断目录是否存在,不存在则会创建目录 { Directory.CreateDirectory(destination); } Path_save = destination + "/" + filename; //文件路径 if (!File.Exists(Path_save)) { Camera.main.cullingMask = 1 << 5; yield return(new WaitForEndOfFrame()); if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)//判断是否为Android平台 { Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); //截取屏幕 texture.Apply(); byte[] bytes = texture.EncodeToPNG(); //转为字节数组 System.IO.File.WriteAllBytes(Path_save, bytes); //存图片 } Camera.main.cullingMask = -1; } #if UNITY_ANDROID weiXinLoad.androidObject.Call("sharepic", new object[] { Path_save, type }); #endif #if UNITY_IPHONE UnitySendMessageToiOS.Instante().shareToiOS(Path_save, type); #endif }
/// <summary> /// 匿名方法 /// </summary> /// <param name="name"></param> public void lamada(string name) { Transform transf = buttonBehind.transform.Find(name); if (name.Contains("customServe")) { transf.localPosition = new Vector3(transf.localPosition.x, transf.localPosition.y, 0); } else { transf.localScale = Vector3.one; } #if UNITY_IOS if (transf.name.Contains("customServe")) { if (UnitySendMessageToiOS.Instante().checkInstallWeChat() != 0 && weiXinLoad.instance.AndroidFunction == false) { Transform transf2 = transf.GetChild(3).GetChild(1); for (int i = 2; i < 6; ++i) { transf2.GetChild(i).GetChild(1).localScale = Vector3.zero; } } } #endif RootCanvas.find("backGround").transform.localScale = Vector3.one;//显示阴影背景 }
public void connectnet(bool isAccountLand, bool isYouKe, bool isWeiXin) { httpConnect.isLand = true;//登陆则改为true if (isYouKe) { //httpConnect.GET(this, httpConnect.URL + "/user/loginByDeviceId?deviceId=8888", null, userLand, httpError);//实现游客登陆,得到token号,连接到服务器 + SystemInfo.deviceUniqueIdentifier httpConnect.GET(this, httpConnect.URL + "/user/loginByDeviceId?deviceId=" + SystemInfo.deviceUniqueIdentifier, null, userLand, httpError);// 实现游客登陆,得到token号,连接到服务器 + SystemInfo.deviceUniqueIdentifier m_state = login_state.visitor; } if (isWeiXin) { #if UNITY_ANDROID weiXinLoad.androidObject.Call("LoginWeiXin"); httpConnect.isLand = true;//登陆则改为true #endif #if UNITY_IPHONE if (UnitySendMessageToiOS.Instante().wxLogon() == 0) { print("登陆成功"); } else { print("请安装或更微信"); } #endif m_state = login_state.wechat; } }
private void Start() { encoded = new Texture2D(420, 420); instant = this; //shops = GameObject.Find("shop_Panel").transform; image_qr_code = GameObject.FindGameObjectWithTag("QR_code").GetComponent <Image>(); GameObject.Find("ppusSure").GetComponent <Button>().onClick.AddListener(delegate() { btnSafeMoney(true); }); //存入保险柜 GameObject.Find("ppopSure").GetComponent <Button>().onClick.AddListener(delegate() { btnSafeMoney(false); }); //取出保险柜 GameObject.Find("getYanZhengMa").GetComponent <Button>().onClick.AddListener(btnMobileSendMsg); GameObject.Find("gameMoneyFreshen").GetComponent <Button>().onClick.AddListener(btnGameMoneyFreshen); //刷新保险柜 GameObject.Find("tuiGuangYuan").GetComponent <Button>().onClick.AddListener(birth_QRcode); GameObject fenxianghaoyouObj = GameObject.Find("fenxianghaoyou"); GameObject fenxiangpengyouquanObj = GameObject.Find("fenxiangpengyouquan"); #if UNITY_IOS if (weiXinLoad.instance.AndroidFunction == false) { if (UnitySendMessageToiOS.Instante().checkInstallWeChat() != 0) { fenxianghaoyouObj.transform.localScale = Vector3.zero; fenxiangpengyouquanObj.transform.localScale = Vector3.zero; } } #endif fenxianghaoyouObj.GetComponent <Button>().onClick.AddListener(() => screenshot(0)); fenxiangpengyouquanObj.GetComponent <Button>().onClick.AddListener(() => screenshot(1)); GameObject.Find("fenxianglianjie").GetComponent <Button>().onClick.AddListener(sharepage); // GameObject.Find("mobileBind_Close").GetComponent<Button>().onClick.AddListener(clear); GameObject.Find("mobileBindleSure").GetComponent <Button>().onClick.AddListener(() => btnMobileBind(false)); //发送绑定消息 GameObject.Find("mobileUnBindleSure").GetComponent <Button>().onClick.AddListener(() => btnMobileBind(true)); //发送解绑消息 }
IEnumerator HttpPostForYZ() { //通知iOS if (pingZeng != null && oriderID != null) { UnitySendMessageToiOS.Instante().showorHideHud("0"); string url = httpConnect.URL + "/pay/applePaycallback"; WWWForm form = new WWWForm(); form.AddField("voucher", pingZeng); form.AddField("orderId", oriderID); form.AddField("type", environment); byte[] byteArr = form.data; Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("token", netConnect.token); WWW wWW = new WWW(url, byteArr, header); yield return(wWW); if (wWW == null) { //Debug.Log("支付验证没有成功"); postError(wWW.text); } else { postBack(wWW.text); } } }
static public UnitySendMessageToiOS Instante() { if (intance == null) { intance = new UnitySendMessageToiOS(); } return(intance); }
/// <summary> /// 支付方法 /// </summary> /// <param name="type"></param> void OnPay(string type) { #if UNITY_ANDROID weiXinLoad.androidObject.Call("singlePay", goldID, type, terminalId, token); #elif UNITY_IOS UnitySendMessageToiOS.Instante().rechargeToiOS(type, terminalId, goldID, token, appleID); #endif }
/// <summary> /// 复制并打开微信 /// </summary> /// <param name="number"></param> void platform(string number) { #if UNITY_ANDROID weiXinLoad.androidObject.Call("openwx", number); #endif #if UNITY_IPHONE UnitySendMessageToiOS.Instante().copyText(number, ""); #endif }
/// <summary> /// 复制文字 /// </summary> /// <param name="word"></param> public void Android_copy(string word) { string text = GameObject.Find(word).GetComponent <Text>().text; #if UNITY_ANDROID weiXinLoad.androidObject.Call("Android_copy", text); #endif #if UNITY_IPHONE UnitySendMessageToiOS.Instante().copyText(text, "复制成功!"); #endif }
void Start() { instance = this; #if UNITY_ANDROID androidObject.Call("getVersionCode"); #endif #if UNITY_IPHONE UnitySendMessageToiOS.Instante().getVersion(); #endif }
void postBack(string str) { Debug.Log("PostBackStr:" + str); JsonData js = JsonMapper.ToObject(str); if ((string)js["code"] == "0") { //向ios传递参数关闭界面 UnitySendMessageToiOS.Instante().showorHideHud("购买成功:" + (string)js["data"] + "金币"); } else { //Debug.Log("没有查询到结果code:"+(string)js["code"]); UnitySendMessageToiOS.Instante().showorHideHud("购买不成功"); } }