/**************************** summary: ****************************/ using Blue; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIAnchorsPanel : UIPanelBase { private Transform m_Content; private GameObject m_AnchorPrefab; private Toggle m_AnchorBtn; private Dictionary m_dicAnchors; protected override void OnAwake() { base.OnAwake(); m_Content = CacheTransform.Find("UIAnchors/Scroll View/Viewport/UIAnchorlContent"); m_AnchorPrefab = CacheTransform.Find("UIAnchors/AnchorBtn").gameObject; m_AnchorBtn = m_AnchorPrefab.GetComponent(); } protected override void OnShow(object param) { base.OnShow(param); } public override void Hide() { base.Hide(); } public void SetAnchor(Dictionary dicAnchors) { GameObject btnItem; m_dicAnchors = dicAnchors; foreach (var item in dicAnchors) { btnItem = Instantiate(m_AnchorBtn, m_Content).gameObject; btnItem.transform.localScale = new Vector3(1, 1, 1); btnItem.transform.localRotation = Quaternion.identity; btnItem.gameObject.SetActive(true); btnItem.GetComponent().SetData(item.Value.gameObject,item.Key); } } public void SaveAnchors( string name ) { Anchor anchor = null; GameObject anchorObj = null; foreach (var item in m_dicAnchors) { if (item.Value.name == name) { anchor = item.Key; anchorObj = item.Value.gameObject; } } if (anchor == null) return; SendSaveAnchor data = new SendSaveAnchor(); data.id = anchor.id; data.objectTransform = anchor.objectTransform; string sendData = JsonConvert.SerializeObject(data); Debug.Log("更新景点数据: " + sendData); HttpTool.Instance.PostTest("/picture/update", sendData, SaveCallBack); } private void SaveCallBack(string message) { if(message == "UnityWebRequest Error") { InstantiateCommand Command = new InstantiateCommand( InstantiateSystem.Instance.BlueObject.WarningPopUp, InstantiateSystem.Instance.BlueObject.NetErrorText); CommandSystem.Instance.Send(Command); return; } Debug.Log("SaveCallBack: " + message); JObject jObject = JObject.Parse(message); string str = jObject["message"].ToString(); if(str!="更新成功") { InstantiateCommand Command =new InstantiateCommand( InstantiateSystem.Instance.BlueObject.WarningPopUp, InstantiateSystem.Instance.BlueObject.NetErrorText); CommandSystem.Instance.Send(Command); return; } UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.SaveSpoitDataEnd); ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str; } }