//打开密码 public void OnPasswordBtnClick() { try { MobileFunction.PopUpPasswordDialog("btn Click"); } catch (System.Exception ex) { } //passwordBtn.gameObject.SetActive(false); //passwordPanel.gameObject.SetActive(true); //取消识别 删除所有target }
//添加好友 public void OnAddFriendBtnClick() { App.MgrAudio.MultPlay("Open3"); string userId = m_data.videoList[selectedNumber].userId; GameObject.FindObjectOfType <UIManager>().DebugToUI("Add Friend: " + userId); try { MobileFunction.SendFriendRequest(userId); } catch (System.Exception ex) { //GameObject.FindObjectOfType<UIManager>().DebugToUI(ex.ToString()); } }
//本地对象 的uid 就是pwd public void ReloadLocalVideoTargetData(string id) { MobileFunction.DebugByAndroid("重新加载本地对象: " + id); for (int i = 0; i < videoTargetControllers.Count; i++) { if (videoTargetControllers[i].m_data.id == id) { App.MgrPost.LoadLocalTarget(videoTargetControllers[i].m_data.targetUid, ReloadLocalDataHandle, () => { MobileFunction.DebugByAndroid("密码错误"); }); MobileFunction.DebugByAndroid("获取到该对象"); } } MobileFunction.DebugByAndroid("没有获取到该对象"); }
IEnumerator SaveMp4(string url) { Debug.Log(url); MobileFunction.DebugByAndroid(url); //string fileName = url.Remove (0, url.Length - 40); string fileName = GetNameFromUrl(url); if (downloadList.Contains(fileName)) { yield break; } if (File.Exists(path + "/" + fileName)) { yield break; } downloadList.Add(fileName); //string str = path.Replace(@"/", @"\"); WWW www2 = new WWW(url); //定义www为WWW类型并且等于所下载下来的WWW中内容。 while (!www2.isDone) { yield return(www2); } //返回所下载的www的值 if (www2.error != null) { Debug.Log("error:" + www2.error); } try { FileStream fs = new FileStream(path + "/" + fileName, FileMode.Create, FileAccess.Write); fs.Write(www2.bytes, 0, www2.bytes.Length); fs.Close(); downloadList.Remove(fileName); } catch (IOException e) { print(e); } }
IEnumerator IE_DownloadLocalARImg(string url) { string fileName = GetNameFromUrl(url); path = Application.persistentDataPath; if (File.Exists(path + "/" + fileName)) { yield break; } else { if (downloadList.Contains(fileName)) { yield break; } downloadList.Add(fileName); WWW www2 = new WWW(url); //定义www为WWW类型并且等于所下载下来的WWW中内容。 yield return(www2); //返回所下载的www的值 if (www2.error != null) { Debug.Log("error:" + www2.error); } Texture2D newTexture = www2.texture; byte[] pngData = newTexture.EncodeToPNG(); try { File.WriteAllBytes(path + "/" + fileName, pngData); Debug.Log(path + "/" + fileName); MobileFunction.DebugByAndroid(path + "/" + fileName); } catch (IOException e) { print(e); } downloadList.Remove(fileName); } }
void OnTargetFound(TargetAbstractBehaviour behaviour) { //取消脱卡 cloudArManager.SetToCardMode(); try { if (isCloud) { MobileFunction.OnCloudIdentifySuccess(m_data.videoList[selectedNumber].userId, m_data.videoList[selectedNumber].isVertical); } else { MobileFunction.OnLocalIdentifySuccess(m_data.videoList[selectedNumber].userId, m_data.videoList[selectedNumber].isVertical); } } catch (System.Exception ex) { //GameObject.FindObjectOfType<UIManager>().DebugToUI(ex.ToString()); } }
//添加视频 public void OnAddVideBtnClick() { App.MgrAudio.MultPlay("Open3"); //string targetId = m_data.targetUid; string userId = m_data.id; GameObject.FindObjectOfType <UIManager>().DebugToUI("Add Video: " + userId); try { if (isCloud) { MobileFunction.AddVideoIntoCloudSpace(userId); } else { MobileFunction.AddVideoIntoLocalSpace(userId); } } catch (System.Exception ex) { //GameObject.FindObjectOfType<UIManager>().DebugToUI(ex.ToString()); } }
IEnumerator IE_LoadImageWithUrl(Image image, string url) { Debug.Log(url); //string fileName = url.Remove(0, url.Length - 40); string fileName = GetNameFromUrl(url); if (useMinimumPic) { fileName += "!unity"; } if (File.Exists(path + "/" + fileName)) { WWW www = new WWW("file://" + path + "/" + fileName); Debug.Log(path + "/" + fileName); MobileFunction.DebugByAndroid(path + "/" + fileName); yield return(www); if (www.error != null) { Debug.Log("error" + www.error); } if (www.isDone && www.error == null) { Texture2D tex2d = www.texture; Sprite s = Sprite.Create(tex2d, new Rect(0, 0, tex2d.width, tex2d.height), new Vector2(0.5f, 0.5f)); image.sprite = s; } yield break; } else { if (downloadList.Contains(fileName)) { yield break; } downloadList.Add(fileName); WWW www2 = new WWW(url); //定义www为WWW类型并且等于所下载下来的WWW中内容。 yield return(www2); //返回所下载的www的值 if (www2.error != null) { Debug.Log("error:" + www2.error); } Texture2D newTexture = www2.texture; image.sprite = Sprite.Create(newTexture, new Rect(0, 0, newTexture.width, newTexture.height), new Vector2(0.5f, 0.5f)); byte[] pngData = newTexture.EncodeToPNG(); try { File.WriteAllBytes(path + "/" + fileName, pngData); Debug.Log(path + "/" + fileName); MobileFunction.DebugByAndroid(path + "/" + fileName); } catch (IOException e) { print(e); } downloadList.Remove(fileName); } }
IEnumerator LoadLocalImageTarget(string pwd, System.Action <VideoTargetDate> handle, System.Action errorHandle) { Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Content-Type", "application/json"); //headers.Add("token", App.MgrConfig._token); JsonData data = new JsonData(); data["password"] = pwd; data["id"] = App.MgrConfig._id; //byte[] bs = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToJson()); byte[] bs = System.Text.Encoding.UTF8.GetBytes(data.ToJson()); Debug.Log(data.ToJson()); WWW www = new WWW(App.MgrConfig._Server + "AR/local", bs, headers); yield return(www); Debug.Log(www.text); string m_info = string.Empty; if (www.error != null) { m_info = www.error; Debug.Log(m_info); yield return(null); } if (www.isDone && www.error == null) { Debug.Log(www.text); m_info = www.text.ToString(); yield return(m_info); Debug.Log(m_info); JsonData jd = JsonMapper.ToObject(m_info); if (!jd["msg"].ToString().Equals("识别成功")) { Debug.Log("密码错误"); MobileFunction.DebugByAndroid("密码错误"); errorHandle(); yield break; } //Debug.Log (jd.ToString ()); string s = jd["data"]["timesImgSrc"].ToString(); string id = jd["data"]["id"].ToString(); s = App.MgrDownload.DownloadLocalARImg(s); VideoTargetDate _data = new VideoTargetDate(pwd, "", id, s); jd = jd["data"]["timeLineVideoList"]; for (int i = 0; i < jd.Count; i++) { VideoTargetCell cell = new VideoTargetCell( jd[i]["createDate"].ToString(), jd[i]["user"]["nickName"].ToString(), jd[i]["timeVideoSrc"].ToString(), jd[i]["user"]["userLogo"].ToString(), jd[i]["user"]["id"].ToString(), jd[i]["user"]["isFriend"].ValueAsBoolean(), jd[i]["isVertical"].ToString() ); _data.videoList.Add(cell); } Debug.Log(_data.videoList.Count); try { MobileFunction.DebugByAndroid("视频数量: " + _data.videoList.Count); } catch (Exception ex) { } yield return(new WaitForSeconds(1f)); if (handle != null) { handle(_data); } } }
public void SetServer(string server) { App.MgrConfig._Server = server; MobileFunction.DebugByAndroid("currentServer=" + App.MgrConfig._Server); }
public void SetPhone(string phone) { App.MgrConfig._phone = phone; MobileFunction.DebugByAndroid("currentPhone=" + App.MgrConfig._phone); }
/// <summary> /// 设置token /// </summary> /// <param name="token">Token.</param> public void SetToken(string token) { App.MgrConfig._token = token; MobileFunction.DebugByAndroid("currentToken=" + App.MgrConfig._token); }
/// <summary> /// 设置id /// </summary> /// <param name="id">Identifier.</param> public void SetId(string id) { App.MgrConfig._id = id; MobileFunction.DebugByAndroid("currentId=" + App.MgrConfig._id); }
//退出 public void OnQuitBtnClick() { //Application.Quit(); MobileFunction.QuitUnity(); }