GameManager.cs 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287
  1. using LitJson;
  2. using Newtonsoft.Json;
  3. using OpenCVForUnity.CoreModule;
  4. using OpenCVForUnity.ImgcodecsModule;
  5. using OpenCVForUnity.ImgprocModule;
  6. using OpenCVForUnity.UnityUtils;
  7. using SC.XR.Unity;
  8. using SC.XR.Unity.Module_InputSystem;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.IO;
  13. using System.Threading;
  14. using TriLibCore;
  15. using Unity.VisualScripting;
  16. using UnityEngine;
  17. using UnityEngine.UI;
  18. using XRTool.Util;
  19. /*
  20. * 半自动交付/自动交付
  21. * 景点、触发范围、水晶点应保持顺序对应
  22. * 当前场景下景点名称不应重复
  23. * 同一景点下素材名称不应重复
  24. * ListShowObjs/ListColliderBoxs/ListCrystals半自动时在场景中推拽,全自动时全部由代码生成
  25. *
  26. * 新增锚点列表
  27. * 锚点识别图Vuforia XML和DAT文件
  28. * 各个锚点的位置信息
  29. *
  30. * 每次打开都下载vuforia文件
  31. * 自动加载生成ImageTarget
  32. *
  33. */
  34. public class GameManager : MonoSingleton<GameManager>
  35. {
  36. public Text text;
  37. public GameObject Map;
  38. /// <summary>
  39. /// 景点ID与对应的素材组合
  40. /// </summary>
  41. [SerializeField, Tooltip("景点对应的物体及景点下的素材")]
  42. private Dictionary<int, ObjectValue> ObjectValues = new Dictionary<int, ObjectValue>();
  43. public List<ObjectValue> ColliderObjectValues = new List<ObjectValue>();
  44. [Header("Spoit")]
  45. [Tooltip("景点对应的显示物体")]
  46. public List<Transform> ListShowObjs;
  47. [Tooltip("景点对应的显示物体,本地添加物体")]
  48. public List<Transform> ListLocalShowObjs;
  49. public bool isShowLoacalShowObjs = false;
  50. [Tooltip("景点对应的物体触发范围")]
  51. public List<Transform> ListColliderBoxs;
  52. private List<MeshRenderer> ListColiderBoxs_Mesh;
  53. [Tooltip("景点对应的水晶点")]
  54. public List<Transform> ListCrystals;
  55. [Tooltip("景点对应的显示物体父物体")]
  56. public Transform ObjsParent;
  57. [Tooltip("触发器父物体")]
  58. public Transform CollidersParent;
  59. [Tooltip("水晶点父物体")]
  60. public Transform CrystalsParent;
  61. [Tooltip("锚点父物体")]
  62. public Transform AnchorsParent;
  63. public GameObject ColliderItem;
  64. public GameObject CrystalItem;
  65. [Space(20)]
  66. [Tooltip("是否显示路径")]
  67. public bool IsShowLuJIng = true;
  68. [Tooltip("是否为编辑模式")]
  69. public bool IsEditor = true;
  70. [Tooltip("是否是全自动显示景点")]
  71. public bool IsAuto = true;
  72. [SerializeField, Tooltip("路径控制器")]
  73. private RouteCtr RouteCtr;
  74. [SerializeField, Tooltip("素材编辑器")]
  75. private EditorPanel m_EditorPanel;
  76. [SerializeField, Tooltip("计算人物在地图上的位置")]
  77. [Header("MinMap")]
  78. private CalMap m_CalMap;
  79. [SerializeField, Tooltip("小地图信息")]
  80. private MinMap m_MinMap;
  81. [Header("Setting")]
  82. [SerializeField, Tooltip("设置面板")]
  83. private SettingPanel m_SettingPanel;
  84. [SerializeField, Tooltip("编辑器面板")]
  85. private Transform m_EditorCanvas;
  86. [SerializeField, Tooltip("设置按钮")]
  87. private Transform m_SetBtn;
  88. [Header("地图比例")]
  89. public Transform PointA;
  90. public Transform PointB;
  91. public Transform PointC;
  92. public Transform PointD;
  93. public bool isStart; // 场景四个点已经确定
  94. public Vector2 WebMapSize;
  95. public Vector2 MapSize;
  96. public Vector2 MinMapSize = new Vector2(320, 135);
  97. public string MapPicUrl;
  98. [Header("展厅")]
  99. public GameObject MRZhanTing;
  100. public bool isPlayMRZhanTing;
  101. public IrobotMove m_IroBot;
  102. [Header("Player")]
  103. public PlayerTrigger Player;
  104. [Header("Head")]
  105. public Transform m_head;
  106. [Header("虚拟导游")]
  107. public List<IrobotMove> Irobots;
  108. /// <summary>
  109. /// 是否在触发区域内
  110. /// </summary>
  111. private bool m_IsTriggerExiting;
  112. /// <summary>
  113. /// 是否在触发区域内
  114. /// </summary>
  115. ///
  116. public GameObject arcamre;
  117. public GameObject immser;
  118. public bool IsTriggerExiting
  119. {
  120. get { return m_IsTriggerExiting; }
  121. set { m_IsTriggerExiting = value; }
  122. }
  123. /// <summary>
  124. /// 是否可以开始编辑素材
  125. /// </summary>
  126. private bool m_IsStartEditor;
  127. /// <summary>
  128. /// 是否可以开始编辑素材
  129. /// </summary>
  130. public bool IsStartEditor
  131. {
  132. get { return m_IsStartEditor; }
  133. set { m_IsStartEditor = value; }
  134. }
  135. /// <summary>
  136. /// 素材加载完成,素材prefab生成完成,开始进入运行状态
  137. /// </summary>
  138. public bool m_IsRuning;
  139. /// <summary>
  140. /// 素材加载完成,素材prefab生成完成,开始进入运行状态
  141. /// </summary>
  142. public bool IsRuning
  143. {
  144. get { return m_IsRuning; }
  145. set { m_IsRuning = value; }
  146. }
  147. /// <summary>
  148. /// 当前触发物体的下标
  149. /// </summary>
  150. private int m_SpoitIndex;
  151. /// <summary>
  152. /// 当前触发物体的下标
  153. /// </summary>
  154. public int SpoitIndex
  155. {
  156. get { return m_SpoitIndex; }
  157. set { m_SpoitIndex = value; }
  158. }
  159. /// <summary>
  160. /// 2.0 场景数据
  161. /// </summary>
  162. public UserSceneItem m_scene;
  163. /// <summary>
  164. /// 当前场景数据
  165. /// </summary>
  166. public SceneValue m_SceneValue;
  167. /// <summary>
  168. /// 当前场景数据
  169. /// </summary>
  170. public SceneValue SceneValue
  171. {
  172. get { return m_SceneValue; }
  173. set { m_SceneValue = value; }
  174. }
  175. /// <summary>
  176. /// 当前场景中的景点信息
  177. /// </summary>
  178. private List<SpoitValue> m_SpoitValues;
  179. /// <summary>
  180. /// 当前场景中的景点信息
  181. /// </summary>
  182. public List<SpoitValue> SpoitValues
  183. {
  184. get { return m_SpoitValues; }
  185. set { m_SpoitValues = value; }
  186. }
  187. /// <summary>
  188. /// 景点详情数据
  189. /// </summary>
  190. private Dictionary<int, SpoitValueDetail> m_SpoitsValueDetail;
  191. /// <summary>
  192. /// 景点详情数据
  193. /// </summary>
  194. public Dictionary<int, SpoitValueDetail> SpoitsValueDetail
  195. {
  196. get { return m_SpoitsValueDetail; }
  197. set { m_SpoitsValueDetail = value; }
  198. }
  199. public UIAnchorsPanel m_UIAnchorsPanel;
  200. private Dictionary<Anchor, MeshRenderer> m_AnchorValue;
  201. public Dictionary<Anchor, MeshRenderer> AnchorValue
  202. {
  203. get { return m_AnchorValue; }
  204. set { m_AnchorValue = value; }
  205. }
  206. private Dictionary<Anchor, GameObject> m_AnchorChild;
  207. public Dictionary<Anchor,GameObject> AnchorChild
  208. {
  209. get { return m_AnchorChild; }
  210. set { m_AnchorChild = value; }
  211. }
  212. public Toggle EditorToggle;
  213. private void Awake()
  214. {
  215. // Debug.unityLogger.logEnabled = false;
  216. }
  217. public Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>> allOldobjs = new Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>>();
  218. public Dictionary<string, Dictionary<string, Dictionary<string, GameObject>>> allobjs = new Dictionary<string, Dictionary<string, Dictionary<string, GameObject>>>();
  219. public Thread thread;
  220. private ThreadStart tstart;
  221. public Dictionary<long, GameObject> textureThread = new Dictionary<long, GameObject>();
  222. public Queue<Dictionary<string, Action>> TheadAcitons = new Queue<Dictionary<string, Action>>();
  223. public Queue<long> TheadAcitonsId = new Queue<long>();
  224. public Queue<Action> TheadBackAcitons = new Queue<Action>();
  225. List<long> removeLong = new List<long>();
  226. bool isBack;
  227. public long theadID;
  228. public long AddThead(Action a, Action b)
  229. {
  230. theadID++;
  231. Dictionary<string, Action> dic = new Dictionary<string, Action>();
  232. dic.Add("Thead", a);
  233. dic.Add("callBack", b);
  234. TheadAcitons.Enqueue(dic);
  235. TheadAcitonsId.Enqueue(theadID);
  236. return theadID;
  237. }
  238. private void subThread()
  239. {
  240. Dictionary<string, Action> dic;
  241. long id;
  242. while (true)
  243. {
  244. Thread.Sleep(100);
  245. try
  246. {
  247. if (TheadAcitons.Count > 0 && !isBack)
  248. {
  249. dic = TheadAcitons.Dequeue();
  250. id = TheadAcitonsId.Dequeue();
  251. if (!removeLong.Contains(id))
  252. {
  253. dic["Thead"].Invoke();
  254. if (dic["callBack"] != null && !removeLong.Contains(id))
  255. {
  256. isBack = true;
  257. TheadBackAcitons.Enqueue(dic["callBack"]);
  258. }
  259. }
  260. }
  261. else if (TheadAcitons.Count <= 0)
  262. {
  263. if (removeLong.Count > 0)
  264. removeLong = new List<long>();
  265. if (textureThread.Count > 0)
  266. textureThread = new Dictionary<long, GameObject>();
  267. }
  268. }
  269. catch
  270. {
  271. isBack = false;
  272. Debug.Log("22222222222");
  273. }
  274. }
  275. }
  276. public bool isShowDownTip;
  277. private void Start()
  278. {
  279. ///神奇代码 但是不能删除 删除子线程使用opencv会闪退
  280. try
  281. {
  282. Texture2D texture2D = Resources.Load("touxiang") as Texture2D;
  283. Mat imgMat = new Mat(texture2D.height, texture2D.width, CvType.CV_8UC4);
  284. Utils.texture2DToMat(texture2D, imgMat);
  285. // Destroy(texture2D);
  286. imgMat.release();
  287. }
  288. catch { }
  289. this.gameObject.AddComponent<TimerMgr>();
  290. // PlayerPrefs.DeleteAll();
  291. isStart = false;
  292. m_SpoitsValueDetail = new Dictionary<int, SpoitValueDetail>();
  293. m_AnchorValue = new Dictionary<Anchor, MeshRenderer>();
  294. m_AnchorChild = new Dictionary<Anchor, GameObject>();
  295. SceneValue = null;
  296. m_IsStartEditor = false;
  297. m_IsRuning = false;
  298. m_SetBtn.gameObject.SetActive(false);
  299. //CalMapSize();
  300. SpoitIndex = -1;
  301. SpoitValues = new List<SpoitValue>();
  302. if (m_EditorPanel == null)
  303. {
  304. m_EditorPanel = GameObject.FindObjectOfType<EditorPanel>();
  305. }
  306. if (!IsAuto)
  307. {
  308. //GetObjectValue();
  309. //CreateSpoitValue();
  310. }
  311. else
  312. {
  313. ListShowObjs = new List<Transform>();
  314. ListColliderBoxs = new List<Transform>();
  315. ListColiderBoxs_Mesh = new List<MeshRenderer>();
  316. ListCrystals = new List<Transform>();
  317. // ListLocalShowObjs = new List<Transform>();
  318. }
  319. m_MinMap.gameObject.SetActive(false);
  320. Map.SetActive(false);
  321. var t = TimerMgr.Instance.CreateTimer(()=> {
  322. if(isShowDownTip)
  323. {
  324. Debug.Log("HJJ 判断正在下载");
  325. if (downLoadCount == 0)
  326. {
  327. downLoadCount = COSDownLoad.showDownEndLoadCount;
  328. Debug.Log("HJJ 判断正在下载downLoadCount==0");
  329. }
  330. if (COSDownLoad.showDownLoadCount > COSDownLoad.showDownEndLoadCount)
  331. {
  332. Debug.Log("HJJ 判断正在下载COSDownLoad.showDownLoadCount > COSDownLoad.showDownEndLoadCount");
  333. string str = string.Format("{0}/{1}正在下载,{2}%", (COSDownLoad.showDownEndLoadCount - downLoadCount), COSDownLoad.showDownLoadCount - downLoadCount, COSDownLoad.showDownLoadPre.ToString("F2"));
  334. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.download);
  335. ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str;
  336. }
  337. else
  338. {
  339. Debug.Log("HJJ 判断正在下载downLoadCount != 0");
  340. TimerMgr.Instance.CreateTimer(()=> {
  341. if (COSDownLoad.showDownLoadCount > COSDownLoad.showDownEndLoadCount)
  342. {
  343. }else
  344. {
  345. // UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
  346. downLoadCount = 0;
  347. DownloadResManager.Instance.Save();
  348. isShowDownTip = false;
  349. }
  350. },1f);
  351. }
  352. if(COSDownLoad.showDownLoadCount==0&& downLoadCount ==0)
  353. {
  354. Debug.Log("HJJ 判断正在下载COSDownLoad.showDownLoadCount==0&& downLoadCount ==0");
  355. Debug.Log("DGJ updateEnd ");
  356. // UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
  357. isShowDownTip = false;
  358. }
  359. }
  360. },1,-1);
  361. tstart = new ThreadStart(subThread);
  362. thread = new Thread(tstart);
  363. thread.Start();
  364. StartCoroutine(startSendPos());
  365. }
  366. IEnumerator startSendPos()
  367. {
  368. while(true)
  369. {
  370. if (Player != null && GameManager.Instance.isStart)
  371. {
  372. float rot = Player.transform.localEulerAngles.y - 180;
  373. var pos = new Vector3(GameManager.Instance.MinMapSize.x - Math.Abs(Player.transform.localPosition.x) / GameManager.Instance.MapSize.x * GameManager.Instance.MinMapSize.x, -Math.Abs(Player.transform.localPosition.z) / GameManager.Instance.MapSize.y * GameManager.Instance.MinMapSize.y, 0);
  374. JsonData data = new JsonData();
  375. data["sn"] = SendSN.GetSN();
  376. data["position"] = new JsonData();
  377. data["position"]["x"] = 1-(pos.x / GameManager.Instance.MinMapSize.x);
  378. data["position"]["y"] = 1+(pos.y / GameManager.Instance.MinMapSize.y);
  379. //send.sn = API_GSXR_Slam.SlamManager.plugin.SN;
  380. ;
  381. MQTTClient.Instance.PublicPosScene(SceneChoose.Sid.ToString(), data.ToJson());
  382. }
  383. yield return new WaitForSeconds(3f);
  384. }
  385. }
  386. int downLoadCount = 0;
  387. private void LateUpdate()
  388. {
  389. if (TheadBackAcitons != null && TheadBackAcitons.Count > 0)
  390. {
  391. try
  392. {
  393. TheadBackAcitons.Dequeue().Invoke();
  394. }
  395. catch
  396. {
  397. }
  398. isBack = false;
  399. }
  400. // if (API_GSXR_Slam.GSXR_Get_Head() != null && m_IsRuning)
  401. // {
  402. // m_SetBtn.transform.LookAt(OpenXRCamera.Instance.head);
  403. // m_SetBtn.transform.localEulerAngles = new Vector3(0, m_SetBtn.transform.localEulerAngles.y+180, 0);
  404. //m_SetBtn.transform.position = API_GSXR_Slam.GSXR_Get_Head().localPosition + Player.transform.forward * 1.3f+ new Vector3(0, 1f, 0);
  405. //m_SetBtn.transform.localPosition = API_GSXR_Slam.GSXR_Get_Head().localPosition + Player.transform.forward * 1.3f + new Vector3(0, 1f, 0);
  406. // m_SetBtn.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward * 1.3f + new Vector3(-0.2f, 1f, 0);
  407. // }
  408. if (avplayer && !avplayer.IsPlaying()&& !TemplateVideo.isPlayLock)
  409. {
  410. Debug.Log("HJJVideo 创建锁解开 并且播放完毕");
  411. TemplateVideo.isPlaying = false;
  412. avplayer = null;
  413. }
  414. if (TemplateVideo.temQueue.Count>0&&!TemplateVideo.isPlaying &&!TemplateVideo.isPlayLock)
  415. {
  416. Debug.Log("HJJVideo 开始播放");
  417. TemplateVideo.isPlaying = true;
  418. TimerMgr.Instance.CreateTimer(()=> {
  419. Debug.Log("HJJVideo 播放的创建锁 创建锁解开");
  420. TemplateVideo.isPlayLock = false;
  421. },3);
  422. TemplateVideo video = TemplateVideo.temQueue.Dequeue();
  423. #if !UNITY_EDITOR
  424. if (!video.localSavePath.Contains("file"))
  425. video.m_Video.SetUrl("file://" + video.localSavePath);
  426. #endif
  427. video.m_Video.transform.GetComponent<VideoPlayBtn>().m_IsPlaying = false;
  428. video.m_Video.transform.GetComponent<VideoPlayBtn>().PlayVideoAuto();
  429. avplayer = video.m_Video;
  430. }
  431. if(ModelItem.loadAB.Count>0&&!ModelItem.isLoad)
  432. {
  433. ModelItem mi = ModelItem.loadAB.Dequeue();
  434. if (IsAB(mi))
  435. {
  436. ModelItem.isLoad = true;
  437. AssetBundle assetBundle = AssetBundle.LoadFromMemory(mi.abByte);
  438. Debug.Log(mi.abByte.Length);
  439. mi.prefabModel.GetComponent<TemplateModel>().LoadModel(assetBundle);
  440. }else
  441. {
  442. Debug.Log("HJJ fileName==2=>" + mi.DownloadPath);
  443. mi.prefabModel.GetComponent<TemplateModel>().TriLibModel();
  444. }
  445. }
  446. }
  447. public bool IsAB(ModelItem mi)
  448. {
  449. bool finish = false;
  450. Debug.Log("HJJ fileName===>" + mi.DownloadPath);
  451. if (mi.DownloadPath.Contains(".ghb") || !mi.DownloadPath.Contains("."))
  452. {
  453. finish = true;
  454. }
  455. return finish;
  456. }
  457. float lockTime = 0;
  458. public AVProVideoPlayer avplayer;
  459. public void Init()
  460. {
  461. }
  462. private void InitCrystals()
  463. {
  464. for (int i = 0; i < ListCrystals.Count; i++)
  465. {
  466. ListCrystals[i].gameObject.SetActive(true);
  467. }
  468. }
  469. private void InitBoxColliders()
  470. {
  471. for (int i = 0; i < ListColliderBoxs.Count; i++)
  472. {
  473. ListColliderBoxs[i].gameObject.SetActive(true);
  474. }
  475. }
  476. public void IntoScene()
  477. {
  478. Map.SetActive(true);
  479. //GameObject.Instantiate(Resources.Load<GameObject>("ARCamera"));
  480. //ImageTargetManager.Instance.LoadVuforiaDat();
  481. //API_GSXR_Slam.GSXR_Get_Head().localPosition = new Vector3(23.57f, 2.5f, 16.74f);
  482. //API_GSXR_Slam.GSXR_Get_Head().localEulerAngles = new Vector3(0, -35.9f, 0);
  483. StartCoroutine(StartScene(isPlayMRZhanTing));
  484. HttpSocket.Instance.SendIpToElectric();
  485. if(!UserInfo.Instance.is20)
  486. MQTTClient.Instance.StartSendCameraPos();
  487. }
  488. public void saveOldData()
  489. {
  490. allOldobjs = new Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>>();
  491. foreach (var i in allobjs.Keys)
  492. {
  493. allOldobjs.Add(i, new Dictionary<string, Dictionary<string, PosRotScalePatch>>());
  494. foreach (var j in allobjs[i].Keys)
  495. {
  496. allOldobjs[i].Add(j, new Dictionary<string, PosRotScalePatch>());
  497. foreach (var k in allobjs[i][j].Keys)
  498. {
  499. PosRotScalePatch p = new PosRotScalePatch();
  500. p.PosPatch = allobjs[i][j][k].transform.localPosition;
  501. p.RotPatch = allobjs[i][j][k].transform.localEulerAngles;
  502. p.ScalePatch = allobjs[i][j][k].transform.localScale;
  503. allOldobjs[i][j].Add(k, p);
  504. }
  505. }
  506. }
  507. }
  508. public void refOldData()
  509. {
  510. foreach (var i in allobjs.Keys)
  511. {
  512. foreach (var j in allobjs[i].Keys)
  513. {
  514. foreach (var k in allobjs[i][j].Keys)
  515. {
  516. allobjs[i][j][k].transform.localPosition = allOldobjs[i][j][k].PosPatch;
  517. allobjs[i][j][k].transform.localEulerAngles = allOldobjs[i][j][k].RotPatch;
  518. allobjs[i][j][k].transform.localScale = allOldobjs[i][j][k].ScalePatch;
  519. }
  520. }
  521. }
  522. }
  523. IEnumerator StartScene( bool isPlayMRZhanTing)
  524. {
  525. yield return new WaitForSeconds(0.5f);
  526. if(isPlayMRZhanTing)
  527. {
  528. //if (!string.IsNullOrWhiteSpace(DataManager.Instance.CurrentScene.sandTable))
  529. //{
  530. MRZhanTing.gameObject.SetActive(true);
  531. MRZhanTing.transform.position = API_GSXR_Slam.GSXR_Get_Head().position + API_GSXR_Slam.GSXR_Get_Head().forward + new Vector3(0, -0.7f, 0);
  532. MRZhanTing.transform.localEulerAngles = new Vector3(0, API_GSXR_Slam.GSXR_Get_Head().eulerAngles.y, 0);
  533. yield return new WaitForSeconds(18f);
  534. MRZhanTing.gameObject.SetActive(false);
  535. //}
  536. }
  537. m_SettingPanel.gameObject.SetActive(true);
  538. m_EditorPanel.Init();
  539. m_SettingPanel.Init();
  540. if (RouteCtr.CurrentPoints.Count > 0)
  541. {
  542. Player.MovePoints = RouteCtr.CurrentPoints;
  543. //判断选择那个虚拟导游
  544. //int id = ChooseIroBot();
  545. //if (id < 3)
  546. //{
  547. //m_IroBot = Irobots[id - 1];
  548. m_IroBot.gameObject.SetActive(true);
  549. m_IroBot.Points = RouteCtr.CurrentPoints;
  550. yield return new WaitForSeconds(5f);
  551. //}
  552. }
  553. IsRuning = true;
  554. m_SetBtn.gameObject.SetActive(true);
  555. InitCrystals();
  556. InitBoxColliders();
  557. }
  558. private int ChooseIroBot()
  559. {
  560. int id = 3;
  561. var navlines = DataManager.Instance.CurrentScene.navLines;
  562. if (navlines.Count > 0)
  563. {
  564. id = navlines[0].guideMod;
  565. }
  566. return id;
  567. }
  568. /// <summary>
  569. /// 若为半自动显示素材,需要获取景点物体来为ObjectValues赋值
  570. /// </summary>
  571. private void GetObjectValue()
  572. {
  573. //for (int i = 0; i < ListShowObjs.Count; i++)
  574. //{
  575. // var spoit = ListShowObjs[i];
  576. // List<ObjectValue> values = new List<ObjectValue>();
  577. // ObjectValue objectValue = new ObjectValue(i, -1, spoit.name, spoit.gameObject, spoit.localPosition, spoit.localEulerAngles, spoit.localScale);
  578. // var editors = spoit.GetComponentsInChildren<EditorEventHandler>();
  579. // for (int j = 1; j < editors.Length; j++)
  580. // {
  581. // var obj = editors[j];
  582. // ObjectValue value = new ObjectValue(j, i, obj.name, obj.gameObject, obj.transform.localPosition, obj.transform.localEulerAngles, obj.transform.localScale);
  583. // objectValue.ChildrenObj.Add(value);
  584. // }
  585. // values.Add(objectValue);
  586. // ObjectValues.Add(i, values);
  587. //}
  588. }
  589. /// <summary>
  590. /// 半自动时创建景点信息
  591. /// </summary>
  592. //private void CreateSpoitValue()
  593. //{
  594. // if (SpoitValues == null)
  595. // {
  596. // SpoitValues = new List<SpoitValue>();
  597. // }
  598. // SpoitValues.Clear();
  599. // foreach (int id in ObjectValues.Keys)
  600. // {
  601. // var item = ObjectValues[id];
  602. // SpoitValue spoit = new SpoitValue();
  603. // spoit.id = item[0].ID;
  604. // spoit.name = item[0].matName;
  605. // for (int i = 0; i < item.Count; i++)
  606. // {
  607. // var objs = item[i];
  608. // MaterialObl materialObl = new MaterialObl();
  609. // materialObl.id = objs.ID;
  610. // materialObl.name = objs.matName;
  611. // materialObl.type = 0;
  612. // OjectTransform ojectTransform = new OjectTransform(objs.Object.transform.localPosition, objs.Object.transform.localEulerAngles, objs.Object.transform.localScale);
  613. // for (int m = 0; m < objs.ChildrenObj.Count; m++)
  614. // {
  615. // var obj = objs.ChildrenObj[i];
  616. // MaterialObjValue mat = new MaterialObjValue();
  617. // mat.name = obj.matName;
  618. // mat.type = 0;
  619. // mat.objectTransform = new OjectTransform(obj.Object.transform.localPosition, obj.Object.transform.localEulerAngles, obj.Object.transform.localScale);
  620. // materialObl.materialList.Add(mat);
  621. // }
  622. // spoit.material.Add(materialObl);
  623. // SpoitValues.Add(spoit);
  624. // }
  625. // }
  626. //}
  627. #region 设置功能
  628. public bool needSavePosRotScale = true;
  629. public void OnEditorBtnValueChanged(bool ison)
  630. {
  631. m_EditorCanvas.gameObject.SetActive(ison);
  632. m_IsStartEditor = ison;
  633. for (int i = 0; i < ListColiderBoxs_Mesh.Count; i++)
  634. {
  635. ListColiderBoxs_Mesh[i].enabled = ison;
  636. }
  637. if (ison)
  638. {
  639. if (needSavePosRotScale)
  640. {
  641. GetPosRotScale(); // 获取所有物体位置旋转缩放
  642. needSavePosRotScale = false;
  643. }
  644. m_EditorCanvas.position = OpenXRCamera.Instance.head.position + Player.transform.forward + new Vector3(0, 0.5f, 0);
  645. m_EditorCanvas.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
  646. CommandSystem.Instance.Send( new EditorSettingCommand(true){ } );
  647. CommandSystem.Instance.Send( new Patch_VideoCommand(true){ } );
  648. }
  649. else
  650. {
  651. m_EditorCanvas.position = OpenXRCamera.Instance.head.position + new Vector3(0, 100, 0);
  652. if (SpoitIndex >= 0 && !IsTriggerExiting)
  653. {
  654. ListShowObjs[SpoitIndex].gameObject.SetActive(false);
  655. if (isShowLoacalShowObjs)
  656. ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
  657. ListCrystals[SpoitIndex].gameObject.SetActive(true);
  658. m_EditorPanel.ClosePanel();
  659. SpoitIndex = -1;
  660. }
  661. CommandSystem.Instance.Send( new EditorSettingCommand(false){ } );
  662. CommandSystem.Instance.Send( new Patch_VideoCommand(false){ } );
  663. }
  664. }
  665. public SCToggleSwitch3D sc3D20zuJD;
  666. public SCToggleSwitch3D sc3D20zuEditor;
  667. public SCToggleSwitch3D sc3Dopen20zu;
  668. public static bool m_IsStartEditorJD;
  669. public void open20zuJD(bool ison)
  670. {
  671. m_IsStartEditorJD = ison;
  672. if (!ison)
  673. {
  674. // save20All();
  675. }else
  676. {
  677. sc3D20zuEditor.isOn = false;
  678. sc3Dopen20zu.isOn = false;
  679. }
  680. SaveButton.SetActive(ison);
  681. }
  682. public static bool m_IsStartEditorzu;
  683. public void open20zu(bool ison)
  684. {
  685. m_IsStartEditorzu = ison;
  686. if (!ison)
  687. {
  688. // save20All();
  689. }
  690. else
  691. {
  692. sc3D20zuJD.isOn = false;
  693. sc3D20zuEditor.isOn = false;
  694. }
  695. SaveButton.SetActive(ison);
  696. }
  697. public static bool m_IsStart20Editor;
  698. //2.0编辑模式 保存
  699. public void open20Editor(bool ison)
  700. {
  701. m_IsStart20Editor = ison;
  702. if(!ison)
  703. {
  704. // save20All();
  705. }
  706. else
  707. {
  708. sc3D20zuJD.isOn = false;
  709. sc3Dopen20zu.isOn = false;
  710. }
  711. SaveButton.SetActive(ison);
  712. }
  713. public GameObject SaveButton;
  714. public void save20All()
  715. {
  716. //if (!m_IsStartEditor)
  717. // {
  718. List<SendSaveDataNew> saveData = new List<SendSaveDataNew>();
  719. foreach (var i in UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].SpotsList.Keys)
  720. {
  721. SpotsItem sp = UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].SpotsList[i.ToString()];
  722. SendSaveDataNew data = new SendSaveDataNew();
  723. data.position = sp.position;
  724. data.triggerImageId = sp.triggerImageId;
  725. data.id = int.Parse(sp.id);
  726. data.name = sp.name;
  727. data.projectId = int.Parse(UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].id);
  728. List<MaterialOblNew> MaterialObllsit = new List<MaterialOblNew>();
  729. foreach (var z in sp.modelList.Keys)
  730. {
  731. ObjectTransform objt2 = new ObjectTransform();
  732. if(sp.isInitModel)
  733. {
  734. objt2.nowPos = sp.modelList[z].Model.transform.localPosition;
  735. objt2.nowRot = sp.modelList[z].Model.transform.localEulerAngles;
  736. objt2.nowScale = sp.modelList[z].Model.transform.localScale;
  737. }else
  738. {
  739. objt2 = sp.modelList[z].objectTransform;
  740. }
  741. sp.modelList[z].objectTransform = objt2;
  742. List<MaterialObjValueNew> materialList = new List<MaterialObjValueNew>();
  743. for (int j = 0; j < sp.modelList[z].materialList.Count; j++)
  744. {
  745. ObjectTransform objt3 = new ObjectTransform();
  746. if (sp.isInitModel)
  747. {
  748. objt3.nowPos = sp.modelList[z].materialList[j].prefabModel.transform.localPosition;
  749. objt3.nowRot = sp.modelList[z].materialList[j].prefabModel.transform.localEulerAngles;
  750. objt3.nowScale = sp.modelList[z].materialList[j].prefabModel.transform.localScale;
  751. }
  752. else
  753. {
  754. objt3 = sp.modelList[z].materialList[j].objectTransform;
  755. }
  756. sp.modelList[z].materialList[j].objectTransform = objt3;
  757. MaterialObjValueNew mov = new MaterialObjValueNew();
  758. mov.uid = sp.modelList[z].materialList[j].uid;
  759. mov.id = sp.modelList[z].materialList[j].id;
  760. mov.fileId = sp.modelList[z].materialList[j].fileId;
  761. mov.type = sp.modelList[z].materialList[j].type;
  762. mov.textContent = sp.modelList[z].materialList[j].textContent.ToString();
  763. mov.textPosition = sp.modelList[z].materialList[j].textPosition.ToString();
  764. mov.textBJ = sp.modelList[z].materialList[j].TextBJ.ToString();
  765. mov.downloadPath = sp.modelList[z].materialList[j].DownloadPath.ToString();
  766. mov.localSavePath = sp.modelList[z].materialList[j].localSavePath.ToString();
  767. mov.name = sp.modelList[z].materialList[j].name;
  768. mov.template = sp.modelList[z].materialList[j].template;
  769. mov.objectTransform = sp.modelList[z].materialList[j].objectTransform;
  770. materialList.Add(mov);
  771. }
  772. MaterialOblNew obj = new MaterialOblNew();
  773. obj.id = sp.modelList[z].id;
  774. obj.name = sp.modelList[z].name;
  775. obj.objectTransform = sp.modelList[z].objectTransform;
  776. obj.describe = sp.modelList[z].describe;
  777. obj.select = true;// sp.modelList[z].select;
  778. obj.type = sp.modelList[z].type;
  779. obj.materialList = materialList;
  780. MaterialObllsit.Add(obj);
  781. }
  782. data.material = MaterialObllsit;
  783. ObjectTransform objt = new ObjectTransform();
  784. objt.nowPos = sp.SpotsObj.transform.localPosition;
  785. objt.nowRot = sp.SpotsObj.transform.localEulerAngles;
  786. objt.nowScale = sp.SpotsObj.transform.localScale;
  787. data.spoittf = objt;
  788. //data.triggerRange = spoit.SpoitTransform[0];
  789. saveData.Add(data);
  790. }
  791. string sendData = JsonConvert.SerializeObject(saveData);
  792. //string sendData = JsonMapper.ToJson(saveData);
  793. Debug.Log("更新景点数据: " + sendData);
  794. HttpTool.Instance.PostTest(HttpAction.viewpoint_update, sendData, (string str) => {
  795. JsonData jd = JsonMapper.ToObject(str);
  796. if(jd["message"].ToString()=="success")
  797. {
  798. InstantiateCommand Command = new InstantiateCommand(
  799. InstantiateSystem.Instance.BlueObject.WarningPopUp,
  800. InstantiateSystem.Instance.BlueObject.SuccessText);
  801. CommandSystem.Instance.Send(Command);
  802. }else
  803. {
  804. InstantiateCommand Command = new InstantiateCommand(
  805. InstantiateSystem.Instance.BlueObject.WarningPopUp,
  806. InstantiateSystem.Instance.BlueObject.NetErrorText);
  807. CommandSystem.Instance.Send(Command);
  808. }
  809. Debug.Log("保存回调===》" + str);
  810. });
  811. // }
  812. }
  813. public void OnSettingBtnValueChanged(bool ison)
  814. {
  815. m_SettingPanel.gameObject.SetActive(ison);
  816. if (ison)
  817. {
  818. Debug.Log(OpenXRCamera.Instance.head.forward);
  819. m_SettingPanel.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward;
  820. m_SettingPanel.transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
  821. }
  822. }
  823. public void OnAnchorBtnValueChanged(bool ison)
  824. {
  825. foreach (var item in m_AnchorValue)
  826. {
  827. item.Value.enabled = ison;
  828. }
  829. //foreach (var item in m_AnchorChild)
  830. //{
  831. // item.Value.SetActive(ison);
  832. //}
  833. if(ison)
  834. {
  835. m_UIAnchorsPanel.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward + new Vector3(0, 0.5f, 0);
  836. m_UIAnchorsPanel.transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
  837. }
  838. else
  839. {
  840. m_UIAnchorsPanel.transform.position = OpenXRCamera.Instance.head.position + new Vector3(0, 100, 0);
  841. }
  842. }
  843. public void GetPosRotScale()
  844. {
  845. saveOldData();
  846. return;
  847. PosRotScale.PosRotScalePatchList.Clear();
  848. for (int i = 0; i < GameManager.Instance.ObjsParent.childCount; i++)
  849. {
  850. if (i != 0)
  851. {
  852. for (int j = 0; j < GameManager.Instance.ObjsParent.GetChild(i).childCount; j++)
  853. {
  854. for (int k = 0; k < GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).childCount; k++)
  855. {
  856. PosRotScalePatch PosRotScalePatch = new PosRotScalePatch();
  857. PosRotScalePatch.PosPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
  858. PosRotScalePatch.RotPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
  859. PosRotScalePatch.ScalePatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
  860. PosRotScale.PosRotScalePatchList.Add(PosRotScalePatch);
  861. }
  862. }
  863. }
  864. }
  865. }
  866. #endregion
  867. #region 获取景点信息--素材编辑模式下
  868. /// <summary>
  869. /// 获取当前景点对应的物体信息
  870. /// </summary>
  871. /// <param name="spoitID"></param>
  872. /// <returns></returns>
  873. public ObjectValue GetSpoitObjs(int spoitID)
  874. {
  875. if (ObjectValues.ContainsKey(spoitID))
  876. {
  877. return ObjectValues[spoitID];
  878. }
  879. else
  880. {
  881. return null;
  882. }
  883. }
  884. /// <summary>
  885. /// 初始化数据
  886. /// 素材编辑模式下
  887. /// </summary>
  888. /// <param name="matObjs"></param>
  889. public void InitSpoitObjs()
  890. {
  891. m_EditorPanel.InitObjTransForm();
  892. }
  893. /// <summary>
  894. /// 保存数据
  895. /// 素材编辑模式下
  896. /// </summary>
  897. /// <param name="matObjs"></param>
  898. public void SaveSpoitObjs()
  899. {
  900. m_EditorPanel.SaveObjTransForm();
  901. }
  902. public void SaveAnchorObjs( string name)
  903. {
  904. foreach (var item in AnchorValue) // 保存所有锚点
  905. {
  906. item.Key.objectTransform.SavePos(item.Value.transform.localPosition, item.Value.transform.localEulerAngles, item.Value.transform.localScale);
  907. }
  908. // 锚点发送后台
  909. m_UIAnchorsPanel.SaveAnchors(name);
  910. }
  911. #endregion
  912. #region 创建水晶点、触发器范围、显示物体
  913. public IEnumerator CreateScene(SceneValue scene)
  914. {
  915. SceneValue = scene;
  916. if (m_MinMap.Map.sprite == null)
  917. {
  918. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), "正在获取地图信息");
  919. GetMinMap(scene ,null);
  920. }
  921. else
  922. {
  923. yield return StartCoroutine(StartCreateScene(scene));
  924. }
  925. yield return new WaitForSeconds(1f);
  926. MoveScenePatch();
  927. }
  928. private void MoveScenePatch()
  929. {
  930. Vector3 temp = ObjsParent.parent.localPosition;
  931. temp.z += MapSize.y;
  932. ObjsParent.parent.localPosition = temp;
  933. }
  934. private IEnumerator StartCreateScene(SceneValue scene)
  935. {
  936. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), "正在初始化景点");
  937. if (scene.navLines != null && scene.navLines.Count > 0)
  938. SetRouteValue(scene.navLines);
  939. else
  940. Debug.LogError(" 当前场景未设置路径");
  941. Debug.Log("DGJ ====> " + JsonConvert.SerializeObject(scene));
  942. if (scene.listSpoit != null && scene.listSpoit.Count > 0)
  943. yield return StartCoroutine(SetSpoitValue(scene.listSpoit));
  944. else
  945. Debug.LogError(" 当前场景未创建景点");
  946. if (scene.listPicture != null && scene.listPicture.Count > 0)
  947. SetAnchor(scene.listPicture);
  948. else
  949. Debug.LogError(" 当前场景未创建锚点");
  950. //设置小地图景点
  951. // m_CalMap.SettingMapPoint(ListCrystals);
  952. yield return null;
  953. //UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.download);
  954. // DownloadManager.Instance.UpdataData();
  955. UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
  956. IntoScene();
  957. }
  958. Action<bool> GetMinMapBack;
  959. /// <summary>
  960. /// 获取小地图
  961. /// </summary>
  962. public void GetMinMap( SceneValue scene ,Action<bool> getBack)
  963. {
  964. GetMinMapBack = getBack;
  965. //DownloadData data1 = new DownloadData();
  966. //string filename = Path.GetFileName(MapPicUrl);
  967. //data1.name = filename;
  968. //data1.type = 1;
  969. //data1.downloadPath = MapPicUrl;
  970. ////data1.updateTime = (int)SceneValue.updateTime;
  971. //data1.localSavePath = DownloadManager.Instance.LocaDataPath + "/map/" + filename;
  972. if(scene.width>0 &&scene.length>0)
  973. {
  974. Debug.Log("playerPos===>" + isStart);
  975. //Debug.Log(scene.width + " " + scene.length);
  976. isStart = true;
  977. PointB.position = Vector3.zero;
  978. PointB.eulerAngles = Vector3.zero;
  979. PointA.position = PointB.position + new Vector3(0, 0, scene.width);
  980. PointA.eulerAngles = Vector3.zero;
  981. PointC.position = PointB.position + new Vector3(scene.length, 0, 0);
  982. PointC.eulerAngles = Vector3.zero;
  983. PointD.position = PointB.position + new Vector3(scene.length, 0, scene.width);
  984. PointD.eulerAngles = Vector3.zero;
  985. m_CalMap.SettingMapPoint(ListCrystals);
  986. }
  987. DownLoadMaterial downLoadMaterial = new DownLoadMaterial();
  988. downLoadMaterial.downLoadPath = MapPicUrl;
  989. downLoadMaterial.localLoadPath = Application.persistentDataPath + "/Material/" + MapPicUrl;
  990. downLoadMaterial.updataTime = scene.updateTime;
  991. downLoadMaterial.type = "-1";
  992. Debug.Log("Hjj 开始获取地图大小==》");
  993. MsgHandler.AddListener(downLoadMaterial.downLoadPath, HandleMsg);
  994. DownloadResManager.Instance.DownLoad(downLoadMaterial);
  995. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), "准备下载素材");
  996. GameManager.Instance.isShowDownTip = true;
  997. DownloadResManager.Instance.StartDownLoad();
  998. }
  999. public static MatOfByte filePathToMatByte(byte[] bytes)
  1000. {
  1001. MatOfByte matOfByte = new MatOfByte(bytes);
  1002. //Imgcodecs.imdecode
  1003. return matOfByte;
  1004. }
  1005. /// <summary>
  1006. /// OpenCV生成图片缩略图
  1007. /// </summary>
  1008. /// <param name="path">文件路径</param>
  1009. /// <param name="zoom">缩放值</param>
  1010. /// <returns></returns>
  1011. public static Mat zoomByteByOpenCV(byte[] path)
  1012. {
  1013. MatOfByte matbytes = filePathToMatByte(path);
  1014. Mat mat = Imgcodecs.imdecode(matbytes, -1);
  1015. float zoom = 1;
  1016. float sint = 2048f;
  1017. if (mat.cols() > sint)
  1018. {
  1019. zoom = (float)(sint / mat.cols());
  1020. }
  1021. if (mat.rows() * zoom > sint)
  1022. {
  1023. zoom = (float)(sint / (float)(mat.rows() * zoom));
  1024. }
  1025. //Debug.Log(mat.cols());
  1026. //Debug.Log(mat.rows());
  1027. //压缩图片
  1028. Size size = new Size(mat.cols() * zoom, mat.rows() * zoom);
  1029. Mat zoomMat = new Mat(size, CvType.CV_8UC4);
  1030. Imgproc.resize(mat, zoomMat, size);
  1031. ////BGR 转RGB
  1032. Mat imgRGBMat = new Mat(zoomMat.cols(), zoomMat.rows(), CvType.CV_8UC4);
  1033. Imgproc.cvtColor(zoomMat, imgRGBMat, Imgproc.COLOR_BGR2RGB);
  1034. //RefreshEvent?.Invoke();
  1035. zoomMat.release();
  1036. mat.release();
  1037. matbytes.release();
  1038. return imgRGBMat;
  1039. //return mat;
  1040. }
  1041. public static Texture2D TextureByMat(Mat imgRGBMat)
  1042. {
  1043. //Debug.Log(imgRGBMat.cols());
  1044. //Debug.Log(imgRGBMat.rows());
  1045. Texture2D _tex = new Texture2D(imgRGBMat.cols(), imgRGBMat.rows(), TextureFormat.RGB24, false);
  1046. Utils.fastMatToTexture2D(imgRGBMat, _tex);
  1047. return _tex;
  1048. }
  1049. private void HandleMsg(Msg msg)
  1050. {
  1051. Debug.Log("Hjj 获取地图大小==》");
  1052. // MsgHandler.RemoveListener()
  1053. if(msg.Value!=null)
  1054. {
  1055. Texture2D tex = new Texture2D(1, 1);
  1056. OpenCVForUnity.CoreModule.Mat _mat = null;
  1057. GameManager.Instance.AddThead(() =>
  1058. {
  1059. Debug.Log("加載完成222222222222222222");
  1060. _mat = zoomByteByOpenCV((byte[])msg.Value);
  1061. }, () =>
  1062. {
  1063. Debug.Log("加載完成111111111111");
  1064. tex = TextureByMat(_mat);
  1065. // Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one * 0.5f);
  1066. Sprite sprite = Sprite.Create(tex, new UnityEngine.Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
  1067. m_MinMap.Map.sprite = sprite;
  1068. //m_MinMap.Map.SetNativeSize();
  1069. float width = tex.width;
  1070. float height = tex.height;
  1071. if (width > height)
  1072. {
  1073. width = width / height;
  1074. height = 1;
  1075. }
  1076. else
  1077. {
  1078. height = height / width;
  1079. width = 1;
  1080. }
  1081. MinMapSize = new Vector2(width * 150, height * 150);
  1082. CalMapSize();
  1083. m_MinMap.Map.GetComponent<RectTransform>().sizeDelta = new Vector2(width * 150, height * 150);
  1084. //获取网页端
  1085. WebMapSize = new Vector2((float)tex.width, (float)tex.height);
  1086. if (SceneValue != null)
  1087. {
  1088. // StartCreateScene(SceneValue);
  1089. }
  1090. GetMinMapBack?.Invoke(true);
  1091. });
  1092. }else
  1093. {
  1094. GetMinMapBack?.Invoke(false);
  1095. }
  1096. }
  1097. /// <summary>
  1098. /// 设置景点素材信息
  1099. /// </summary>
  1100. /// <param name="spoits"></param>
  1101. public IEnumerator SetSpoitValue(List<SpoitValue> spoits)
  1102. {
  1103. SpoitValue spoitValue;
  1104. for (int i = 0; i < spoits.Count-1; i++)
  1105. {
  1106. spoitValue = null;
  1107. for (int j = 0; j < spoits.Count-1-i; j++)
  1108. {
  1109. if(spoits[j].id>spoits[j+1].id)
  1110. {
  1111. spoitValue = spoits[j];
  1112. spoits[j] = spoits[j+1];
  1113. spoits[j+1] = spoitValue;
  1114. }
  1115. }
  1116. }
  1117. SpoitValues.Clear();
  1118. for (int i = 0; i < spoits.Count; i++)
  1119. {
  1120. var spoit = spoits[i];
  1121. SpoitValue spoit1 = spoit;
  1122. CreateCrystalAndTrigger(spoit);
  1123. yield return StartCoroutine(CreateMaterial(spoit));
  1124. spoits[i] = SV;
  1125. }
  1126. for (int i = 0; i < ListColiderBoxs_Mesh.Count; i++)
  1127. {
  1128. ListColiderBoxs_Mesh[i].enabled = false;
  1129. }
  1130. SpoitValues.AddRange(spoits);
  1131. SceneValue.listSpoit = SpoitValues;
  1132. DataManager.Instance.Spoits = SpoitValues;
  1133. }
  1134. /// <summary>
  1135. /// 创建水晶点和触发器
  1136. /// </summary>
  1137. private void CreateCrystalAndTrigger(SpoitValue spoit)
  1138. {
  1139. var spoitPos = Vector3.zero;
  1140. if (spoit.SpoitTransform!=null&&spoit.SpoitTransform.Count > 0)
  1141. {
  1142. Debug.LogFormat("{0}{1}", spoit.name, " DGJ ===> 景点存在");
  1143. SpoitPos trans = spoit.SpoitTransform[0];
  1144. spoitPos = new Vector3((float)trans.pointRelativeX / WebMapSize.x * MapSize.x, -1f, MapSize.y - ((float)trans.pointRelativeY) / WebMapSize.y * MapSize.y);
  1145. //创建水晶点
  1146. var obj = Instantiate(CrystalItem, CrystalsParent);
  1147. CommandSystem.Instance.Send(
  1148. new InstantiateGOCommand(InstantiateSystem.Instance.BlueObject.SpoitName, obj.gameObject)
  1149. );
  1150. obj.name = spoit.name;
  1151. obj.transform.localPosition = spoitPos;
  1152. ListCrystals.Add(obj.transform);
  1153. var spoitobj = CreateSpoit(spoit, spoitPos);
  1154. ListShowObjs.Add(spoitobj.transform);
  1155. ObjectValue spoitvalue = new ObjectValue(spoit.id, -1, spoitobj.name, spoitobj);
  1156. ObjectValues.Add(spoit.id, spoitvalue);
  1157. ////创建触发器
  1158. //if (SpoitsValueDetail.ContainsKey(spoit.id))
  1159. //{
  1160. // var spoitdetail = SpoitsValueDetail[spoit.id];
  1161. // var range = spoitdetail.triggerRange;
  1162. // if (range.areaRelativeH == 0 && range.areaRelativeW == 0 && range.areaRelativeX == 0 && range.areaRelativeY == 0)
  1163. // {
  1164. // }
  1165. // else
  1166. // {
  1167. // trans = range;
  1168. // }
  1169. //}
  1170. //var tiggerpos = new Vector3((float)trans.areaRelativeX / WebMapSize.x * MapSize.x, -0.5f, -(float)trans.areaRelativeY / WebMapSize.y * MapSize.y);
  1171. var tiggerpos = new Vector3((float)(trans.areaRelativeX + trans.areaRelativeW / 2) / WebMapSize.x * MapSize.x, -0.5f, MapSize.y - (float)(trans.areaRelativeY + trans.areaRelativeH / 2) / WebMapSize.y * MapSize.y);
  1172. var tiggerRange = new Vector3((float)trans.areaRelativeW / WebMapSize.x * MapSize.x, 0.1f,(float)trans.areaRelativeH / WebMapSize.y * MapSize.y);
  1173. Debug.LogError($"名称:{spoit.name}+宽:{trans.areaRelativeW},长:{trans.areaRelativeH}");
  1174. var triggerobj = Instantiate(ColliderItem, CollidersParent);
  1175. triggerobj.name = spoit.name;
  1176. triggerobj.transform.localPosition = tiggerpos;
  1177. triggerobj.transform.localScale = tiggerRange;
  1178. //triggerobj.AddComponent<EditorEventHandler>().IsClickEditor = true;
  1179. ObjectValue boxvalue = new ObjectValue(spoit.id, -1, triggerobj.name, triggerobj);
  1180. ColliderObjectValues.Add(boxvalue);
  1181. ListColliderBoxs.Add(triggerobj.transform);
  1182. ListColiderBoxs_Mesh.Add(triggerobj.GetComponent<MeshRenderer>());
  1183. }
  1184. else
  1185. {
  1186. Debug.LogFormat("{0}{1}", spoit.name, "景点不存在");
  1187. }
  1188. }
  1189. public Dictionary<int, Vector3> spoitposDic = new Dictionary<int, Vector3>();
  1190. public Dictionary<int, GameObject> spoitposObjDic = new Dictionary<int, GameObject>();
  1191. public float wutiH=1.5f;
  1192. private GameObject CreateSpoit(SpoitValue spoit, Vector3 spoitPos)
  1193. {
  1194. //生成景点父物体
  1195. GameObject spoitObj = new GameObject(spoit.name);
  1196. spoitObj.transform.SetParent(ObjsParent.transform);
  1197. spoitObj.AddComponent<EditorEventHandler>().IsClickEditor = false;
  1198. spoitposObjDic.Add(spoit.id, spoitObj);
  1199. /*
  1200. //为景点位置信息赋值
  1201. if (spoit.spoitTf.startPos == Vector3.zero && spoit.spoitTf.nowPos == Vector3.zero)
  1202. {*/
  1203. spoitposDic.Add(spoit.id, new Vector3(spoitPos.x, wutiH, spoitPos.z));
  1204. spoitObj.transform.localPosition = new Vector3(spoitPos.x, wutiH, spoitPos.z)+ spoit.spoitTf.nowPos;
  1205. Debug.Log("最新保存====》獲取的POS" + new Vector3(spoitPos.x, wutiH, spoitPos.z));
  1206. Debug.Log("最新保存====》獲取的偏移POS" + spoit.spoitTf.nowPos);
  1207. Debug.Log("最新保存====》獲取的物體Pos" + spoitObj.transform.localPosition);
  1208. spoitObj.transform.localRotation = Quaternion.identity;
  1209. spoitObj.transform.localEulerAngles = spoit.spoitTf.nowRot;
  1210. spoitObj.transform.localScale = new Vector3(1, 1, 1);
  1211. if(spoit.spoitTf.nowScale!=Vector3.zero)
  1212. {
  1213. spoitObj.transform.localScale = spoit.spoitTf.nowScale;
  1214. }
  1215. spoit.spoitTf.SetStartValue(spoitObj.transform.localPosition, spoitObj.transform.localEulerAngles, spoitObj.transform.localScale);
  1216. /* }
  1217. else
  1218. {
  1219. spoitObj.transform.localPosition = spoit.spoitTf.nowPos;
  1220. spoitObj.transform.localEulerAngles = spoit.spoitTf.nowRot;
  1221. spoitObj.transform.localScale = spoit.spoitTf.nowScale;
  1222. }*/
  1223. return spoitObj;
  1224. }
  1225. SpoitValue SV;
  1226. /// <summary>
  1227. /// 创建整体素材
  1228. /// 一个景点下应只有一个父物体,其他素材都在父物体下
  1229. /// </summary>
  1230. private IEnumerator CreateMaterial(SpoitValue spoit)
  1231. {
  1232. if(!ObjectValues.ContainsKey(spoit.id))
  1233. {
  1234. SV = new SpoitValue();
  1235. }
  1236. else
  1237. {
  1238. var spoitValues = ObjectValues[spoit.id];
  1239. var spoitObj = spoitValues.Object;
  1240. Debug.Log("DGJ ===> 创建整体素材 "+ spoit.material.Count);
  1241. SyncSpoit syncSpoit = new SyncSpoit();
  1242. syncSpoit.spoitId = spoit.name;
  1243. syncSpoit.spoitObj = spoitObj;
  1244. MultiPlayerManager.Instance.dicSpoitValue.Add(spoit.name, syncSpoit);
  1245. if(!UserInfo.Instance.is20)
  1246. //生成素材组合
  1247. for (int i = 0; i < spoit.material.Count; i++)
  1248. {
  1249. //素材整体
  1250. MaterialObl material = spoit.material[i];
  1251. //Debug.Log(spoit.material[i].name);
  1252. //素材组物体
  1253. GameObject matObj = new GameObject(material.name);
  1254. matObj.transform.SetParent(spoitValues.Object.transform);
  1255. matObj.transform.localPosition = Vector3.zero;
  1256. matObj.transform.localEulerAngles = Vector3.zero;
  1257. matObj.transform.localScale = new Vector3(1, 1, 1);
  1258. material.objectTransform.SetStartValue(matObj.transform.localPosition, matObj.transform.localEulerAngles, matObj.transform.localScale);
  1259. //素材组合对应ObjectValue的
  1260. ObjectValue spoitValue = new ObjectValue(i, spoit.id, material.name, matObj);
  1261. //素材组合下的单个素材ObjectValue
  1262. List<ObjectValue> objsvalue = null;
  1263. MaterialObl newmaterial = material;
  1264. //生成素材组合的ObjectValue,是对应景点的
  1265. switch (material.type)
  1266. {
  1267. case (int)MaterialType.None:
  1268. break;
  1269. case (int)MaterialType.Image:
  1270. case (int)MaterialType.Video:
  1271. case (int)MaterialType.Model:
  1272. case (int)MaterialType.Text:
  1273. case (int)MaterialType.LocaImage:
  1274. Debug.Log("DGJ ===> LocalImage " + material.name);
  1275. objsvalue = CreateSuCaiObj(spoit,material, matObj, out newmaterial);
  1276. break;
  1277. case (int)MaterialType.Image_Video_Text:
  1278. Debug.Log("DGJ ===> Image_Video_Text " + material.name);
  1279. objsvalue = CreateImage_Video_Text(spoit,material, matObj, out newmaterial);
  1280. break;
  1281. case (int)MaterialType.Model_Text:
  1282. Debug.Log("DGJ ===> Model_Text " + material.name);
  1283. objsvalue = CreateModel_Text(spoit,material, matObj, out newmaterial);
  1284. break;
  1285. default:
  1286. break;
  1287. }
  1288. spoit.material[i] = newmaterial;
  1289. spoitValue.ChildrenObj.AddRange(objsvalue);
  1290. spoitValues.ChildrenObj.Add(spoitValue);
  1291. Debug.Log("DGJ ===> 创建整体素材 " + spoitValues.ChildrenObj.Count);
  1292. }
  1293. SV = spoit;
  1294. if (ObjectValues.ContainsKey(spoit.id))
  1295. {
  1296. ObjectValues[spoit.id] = spoitValues;
  1297. }
  1298. else
  1299. {
  1300. ObjectValues.Add(spoit.id, spoitValues);
  1301. }
  1302. spoitObj.gameObject.SetActive(false);
  1303. }
  1304. yield return null;
  1305. }
  1306. /// <summary>
  1307. /// 编辑面板添加素材
  1308. /// </summary>
  1309. /// <param name="material"></param>
  1310. public void AddMaterial(MaterialObl material)
  1311. {
  1312. if (SpoitIndex < 0)
  1313. {
  1314. return;
  1315. }
  1316. MaterialObl newmaterial = new MaterialObl();
  1317. newmaterial = material;
  1318. var spoit = SpoitValues[SpoitIndex];
  1319. var spoitValues = ObjectValues[spoit.id];
  1320. var spoitObj = spoitValues.Object;
  1321. //素材组物体
  1322. GameObject matObj = new GameObject(newmaterial.name + "-" + spoit.material.Count.ToString());
  1323. newmaterial.name = matObj.name;
  1324. matObj.transform.SetParent(spoitValues.Object.transform);
  1325. if (!material.select)
  1326. {
  1327. matObj.transform.localPosition = Vector3.zero;
  1328. matObj.transform.localEulerAngles = Vector3.zero;
  1329. matObj.transform.localScale = new Vector3(1, 1, 1);
  1330. newmaterial.objectTransform.SetStartValue(matObj.transform.localPosition, matObj.transform.localEulerAngles, matObj.transform.localScale);
  1331. }
  1332. else
  1333. {
  1334. matObj.transform.localPosition = newmaterial.objectTransform.nowPos;
  1335. matObj.transform.localEulerAngles = newmaterial.objectTransform.nowRot;
  1336. matObj.transform.localScale = newmaterial.objectTransform.nowScale;
  1337. }
  1338. //素材组合对应ObjectValue的
  1339. ObjectValue spoitValue = new ObjectValue(spoit.material.Count, spoit.id, newmaterial.name, matObj);
  1340. //素材组合下的单个素材ObjectValue
  1341. List<ObjectValue> objsvalue = null;
  1342. //生成素材组合的ObjectValue,是对应景点的
  1343. switch (material.type)
  1344. {
  1345. case (int)MaterialType.None:
  1346. break;
  1347. case (int)MaterialType.Image:
  1348. case (int)MaterialType.Video:
  1349. case (int)MaterialType.Model:
  1350. case (int)MaterialType.Text:
  1351. case (int)MaterialType.LocaImage:
  1352. objsvalue = CreateSuCaiObj(spoit, newmaterial, matObj, out newmaterial);
  1353. break;
  1354. case (int)MaterialType.Image_Video_Text:
  1355. objsvalue = CreateImage_Video_Text(spoit,newmaterial, matObj, out newmaterial);
  1356. break;
  1357. case (int)MaterialType.Model_Text:
  1358. objsvalue = CreateModel_Text(spoit, newmaterial, matObj, out newmaterial);
  1359. break;
  1360. default:
  1361. break;
  1362. }
  1363. newmaterial.select = true;
  1364. spoit.material.Add(newmaterial);
  1365. spoitValue.ChildrenObj.AddRange(objsvalue);
  1366. spoitValues.ChildrenObj.Add(spoitValue);
  1367. if (ObjectValues.ContainsKey(spoit.id))
  1368. {
  1369. ObjectValues[spoit.id] = spoitValues;
  1370. }
  1371. else
  1372. {
  1373. ObjectValues.Add(spoit.id, spoitValues);
  1374. }
  1375. SpoitValues[SpoitIndex] = spoit;
  1376. //更新编辑面板Ui
  1377. UpdateEditorUI();
  1378. }
  1379. /// <summary>
  1380. /// 创建 1图片 2视频 3模型 4文字
  1381. /// </summary>
  1382. /// <param name="type">素材类型</param>
  1383. /// <param name="material">素材数据</param>
  1384. /// <param name="spoit">景点</param>
  1385. /// <returns></returns>
  1386. private List<ObjectValue> CreateSuCaiObj(SpoitValue spoitjd, MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
  1387. {
  1388. List<ObjectValue> objects = new List<ObjectValue>();
  1389. List<MaterialObjValue> objs = material.materialList;
  1390. newmaterial = material;
  1391. //for (int i = 0; i < objs.Count; i++)
  1392. //{
  1393. // Debug.Log(objs[i].localSavePath);
  1394. //}
  1395. for (int i = 0; i < objs.Count; i++)
  1396. {
  1397. var mat = objs[i];
  1398. GameObject go = null;
  1399. switch (mat.type)
  1400. {
  1401. case (int)MaterialType.None:
  1402. break;
  1403. case (int)MaterialType.Image:
  1404. var pImage = ResMgr.Instance.Load<GameObject>("Template/Prefab/Image");
  1405. go = Instantiate(pImage, spoit.transform);
  1406. var imageitem = go.AddComponent<TemplateImage>();
  1407. go.SetActive(true);
  1408. imageitem.SetData(mat, material.updateTime);
  1409. break;
  1410. case (int)MaterialType.Video:
  1411. var pVideo = ResMgr.Instance.Load<GameObject>("Template/Prefab/Video");
  1412. go = Instantiate(pVideo, spoit.transform);
  1413. var videoitem = go.AddComponent<TemplateVideo>();
  1414. videoitem.autoplay = material.autoplay;
  1415. go.SetActive(true);
  1416. videoitem.SetData(mat, material.updateTime);
  1417. break;
  1418. case (int)MaterialType.Model:
  1419. var pModel = ResMgr.Instance.Load<GameObject>("Template/Prefab/Model");
  1420. go = Instantiate(pModel, spoit.transform);
  1421. var modelitem = go.AddComponent<TemplateModel>();
  1422. go.SetActive(true);
  1423. modelitem.SetData(mat, material.updateTime);
  1424. Debug.Log(modelitem.Data.localLoadPath);
  1425. break;
  1426. case (int)MaterialType.Text:
  1427. var pText = ResMgr.Instance.Load<GameObject>("Template/Prefab/Text");
  1428. go = Instantiate(pText, spoit.transform);
  1429. var textitem = go.AddComponent<TemplateText>();
  1430. go.SetActive(true);
  1431. textitem.SetData(mat, material.updateTime);
  1432. break;
  1433. case (int)MaterialType.LocaImage:
  1434. var pLocaImage = ResMgr.Instance.Load<GameObject>("Template/Prefab/Image");
  1435. go = Instantiate(pLocaImage, spoit.transform);
  1436. var locaImageitem = go.AddComponent<TemplateImage>();
  1437. go.SetActive(true);
  1438. locaImageitem.SetLocaImageData(mat);
  1439. break;
  1440. default:
  1441. break;
  1442. }
  1443. if (go != null)
  1444. {
  1445. if (!GameManager.Instance.allobjs.ContainsKey(spoitjd.id.ToString()))
  1446. {
  1447. GameManager.Instance.allobjs.Add(spoitjd.id.ToString(), new Dictionary<string, Dictionary<string, GameObject>>());
  1448. }
  1449. if (!GameManager.Instance.allobjs[spoitjd.id.ToString()].ContainsKey(material.id.ToString()))
  1450. {
  1451. GameManager.Instance.allobjs[spoitjd.id.ToString()].Add(material.id.ToString(), new Dictionary<string, GameObject>());
  1452. }
  1453. if (!GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].ContainsKey(mat.id.ToString()))
  1454. {
  1455. GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].Add(mat.id.ToString(), go);
  1456. }
  1457. else
  1458. {
  1459. GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()][mat.id.ToString()] = go;
  1460. }
  1461. go.name = string.IsNullOrWhiteSpace(mat.name) ? spoit.name + "-" + i.ToString() : mat.name;
  1462. mat.name = go.name;
  1463. go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
  1464. if (material.select)
  1465. {
  1466. go.transform.localPosition = mat.ObjectTransform.nowPos;
  1467. go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
  1468. go.transform.localScale = mat.ObjectTransform.nowScale;
  1469. }
  1470. else
  1471. {
  1472. go.transform.localEulerAngles = Vector3.zero;
  1473. go.transform.localScale = new Vector3(1, 1, 1);
  1474. if (mat.type != (int)MaterialType.Text)
  1475. {
  1476. go.transform.localPosition = Vector3.zero;
  1477. }
  1478. else
  1479. {
  1480. //Set text position
  1481. if (mat.textPosition == "top")
  1482. {
  1483. go.transform.localPosition = new Vector3(0, 0.3f, 0);
  1484. }
  1485. else if (mat.textPosition == "bottom")
  1486. {
  1487. go.transform.localPosition = new Vector3(0, -0.3f, 0);
  1488. }
  1489. }
  1490. mat.ObjectTransform.SetStartValue(go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
  1491. }
  1492. ObjectValue objectValue = new ObjectValue(i, material.id, mat.name, go);
  1493. objects.Add(objectValue);
  1494. }
  1495. newmaterial.materialList[i] = mat;
  1496. }
  1497. return objects;
  1498. }
  1499. /// <summary>
  1500. /// 创建 6模型+文字
  1501. /// </summary>
  1502. /// <param name="material"></param>
  1503. /// <param name="spoit"></param>
  1504. /// <returns></returns>
  1505. private List<ObjectValue> CreateModel_Text(SpoitValue spoitjd, MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
  1506. {
  1507. List<ObjectValue> objects = new List<ObjectValue>();
  1508. List<MaterialObjValue> objs = material.materialList;
  1509. newmaterial = material;
  1510. for (int i = 0; i < objs.Count; i++)
  1511. {
  1512. var mat = objs[i];
  1513. GameObject go = null;
  1514. switch (mat.type)
  1515. {
  1516. case (int)MaterialType.None:
  1517. break;
  1518. case (int)MaterialType.Model:
  1519. var pModel = ResMgr.Instance.Load<GameObject>("Template/Prefab/Model");
  1520. go = Instantiate(pModel, spoit.transform);
  1521. var modelitem = go.AddComponent<TemplateModel>();
  1522. go.SetActive(true);
  1523. modelitem.SetData(mat, material.updateTime);
  1524. break;
  1525. case (int)MaterialType.Text:
  1526. var pText = ResMgr.Instance.Load<GameObject>("Template/Prefab/Text");
  1527. go = Instantiate(pText, spoit.transform);
  1528. var textitem = go.AddComponent<TemplateText>();
  1529. go.SetActive(true);
  1530. textitem.SetData(mat, material.updateTime);
  1531. break;
  1532. default:
  1533. break;
  1534. }
  1535. if (go != null)
  1536. {
  1537. if (!GameManager.Instance.allobjs.ContainsKey(spoitjd.id.ToString()))
  1538. {
  1539. GameManager.Instance.allobjs.Add(spoitjd.id.ToString(), new Dictionary<string, Dictionary<string, GameObject>>());
  1540. }
  1541. if (!GameManager.Instance.allobjs[spoitjd.id.ToString()].ContainsKey(material.id.ToString()))
  1542. {
  1543. GameManager.Instance.allobjs[spoitjd.id.ToString()].Add(material.id.ToString(), new Dictionary<string, GameObject>());
  1544. }
  1545. if (!GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].ContainsKey(mat.id.ToString()))
  1546. {
  1547. GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].Add(mat.id.ToString(), go);
  1548. }
  1549. else
  1550. {
  1551. GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()][mat.id.ToString()] = go;
  1552. }
  1553. go.name = string.IsNullOrWhiteSpace(mat.name) ? spoit.name + "-" + i.ToString() : mat.name;
  1554. go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
  1555. if (material.select)
  1556. {
  1557. go.transform.localPosition = mat.ObjectTransform.nowPos;
  1558. go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
  1559. go.transform.localScale = mat.ObjectTransform.nowScale;
  1560. }
  1561. else
  1562. {
  1563. go.transform.localEulerAngles = Vector3.zero;
  1564. go.transform.localScale = new Vector3(1, 1, 1);
  1565. if (mat.type != (int)MaterialType.Text)
  1566. {
  1567. go.transform.localPosition = Vector3.zero;
  1568. }
  1569. else
  1570. {
  1571. //Set text position
  1572. if (mat.textPosition == "top")
  1573. {
  1574. go.transform.localPosition = new Vector3(0, 0.3f, 0);
  1575. }
  1576. else if (mat.textPosition == "bottom")
  1577. {
  1578. go.transform.localPosition = new Vector3(0, -0.3f, 0);
  1579. }
  1580. else if (mat.textPosition == "left")
  1581. {
  1582. go.transform.localPosition = new Vector3(-0.3f, 0, 0);
  1583. }
  1584. else if (mat.textPosition == "right")
  1585. {
  1586. go.transform.localPosition = new Vector3(0.3f, 0f, 0);
  1587. }
  1588. Debug.LogError("Tyyyyyyyyyyyyyyyyyyt " + go.transform.localPosition);
  1589. Debug.LogError("Tyyyyyyyyyyyyyyyyyyt " + mat.textContent);
  1590. }
  1591. mat.ObjectTransform.SetStartValue(go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
  1592. }
  1593. ObjectValue objectValue = CreateMatObjectValue(i, material.id, go, mat);
  1594. objects.Add(objectValue);
  1595. }
  1596. newmaterial.materialList[i] = mat;
  1597. }
  1598. return objects;
  1599. }
  1600. /// <summary>
  1601. /// 创建 5图片+文字/视频+文字
  1602. /// </summary>
  1603. private List<ObjectValue> CreateImage_Video_Text(SpoitValue spoitjd,MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
  1604. {
  1605. Debug.LogError("HJJmaterialObls.select DRFanLayout.CreateImage_Video_Text ");
  1606. newmaterial = material;
  1607. List<ObjectValue> objects = new List<ObjectValue>();
  1608. SRTitleLayout.CalLayout(spoitjd,material, spoit, out newmaterial);
  1609. Debug.LogError("HJJmaterialObls.select DRFanLayout.CalLayout default ");
  1610. return objects;
  1611. }
  1612. /// <summary>
  1613. /// 创建物体ObjectValue,并赋值位置信息
  1614. /// </summary>
  1615. /// <param name="id"></param>
  1616. /// <param name="parentid"></param>
  1617. /// <param name="go"></param>
  1618. /// <param name="mat"></param>
  1619. /// <returns></returns>
  1620. private ObjectValue CreateMatObjectValue(int id, int parentid, GameObject go, MaterialObjValue mat)
  1621. {
  1622. go.name = string.IsNullOrWhiteSpace(mat.name) ? go.name : mat.name;
  1623. go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
  1624. Debug.LogError("Tyyyyyyyyyyyyyyyyyyt " + mat.ObjectTransform.nowPos);
  1625. if (mat.type != (int)MaterialType.Text)
  1626. {
  1627. //为物体位置信息赋值
  1628. if (mat.ObjectTransform != null)
  1629. {
  1630. go.transform.localPosition = mat.ObjectTransform.nowPos;
  1631. go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
  1632. go.transform.localScale = mat.ObjectTransform.nowScale;
  1633. }
  1634. else
  1635. {
  1636. go.transform.localPosition = Vector3.zero;
  1637. go.transform.localEulerAngles = Vector3.zero;
  1638. go.transform.localScale = new Vector3(1, 1, 1);
  1639. }
  1640. }
  1641. ObjectValue objectValue = new ObjectValue(id, parentid, mat.name, go, go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
  1642. return objectValue;
  1643. }
  1644. #endregion
  1645. #region 路径
  1646. /// <summary>
  1647. /// 设置路线数据
  1648. /// </summary>
  1649. /// <param name="navLines"></param>
  1650. public void SetRouteValue(List<NavLinesItem> navLines)
  1651. {
  1652. if (navLines == null || navLines.Count <= 0)
  1653. {
  1654. Debug.Log("当前景点未绘制路线");
  1655. return;
  1656. }
  1657. RouteCtr.SetRouteValue(navLines);
  1658. }
  1659. #endregion
  1660. #region 锚点
  1661. /// <summary>
  1662. /// 设置场景锚点
  1663. /// </summary>
  1664. /// <param name="listAnchor"></param>
  1665. public void SetAnchor(List<Anchor> listAnchor)
  1666. {
  1667. if (listAnchor == null)
  1668. return;
  1669. Anchor anchor;
  1670. for (int i = 0; i < listAnchor.Count - 1; i++)
  1671. {
  1672. for (int j = 0; j < listAnchor.Count - 1 - i; j++)
  1673. {
  1674. if (listAnchor[j].id > listAnchor[j + 1].id)
  1675. {
  1676. anchor = listAnchor[j];
  1677. listAnchor[j] = listAnchor[j + 1];
  1678. listAnchor[j + 1] = anchor;
  1679. }
  1680. }
  1681. }
  1682. for (int i = 0; i < listAnchor.Count; i++)
  1683. {
  1684. // 创建锚点
  1685. GameManager.Instance.AnchorValue.Add(listAnchor[i], CreateAnchor(listAnchor[i]));
  1686. GameManager.Instance.AnchorChild.Add(listAnchor[i], AnchorValue[listAnchor[i]].transform.GetChild(0).gameObject);
  1687. }
  1688. m_UIAnchorsPanel.SetAnchor(AnchorValue);
  1689. }
  1690. private MeshRenderer CreateAnchor(Anchor anchor)
  1691. {
  1692. // 创建锚点 给锚点赋值
  1693. GameObject anchorObj = GameObject.Instantiate(Resources.Load<GameObject>("Template/Prefab/Anchor"),AnchorsParent);
  1694. anchorObj.name = "Anchor" + anchor.id;
  1695. /*
  1696. VuforiaAnchor vuforiaAnchor = anchorObj.GetComponent<VuforiaAnchor>();
  1697. vuforiaAnchor.player = GameManager.Instance.m_head.transform;
  1698. if (VuforiaManager.Instance.list_Anchor == null)
  1699. VuforiaManager.Instance.list_Anchor = new List<VuforiaAnchor>();
  1700. VuforiaManager.Instance.list_Anchor.Add(vuforiaAnchor);*/
  1701. var anchorPos = Vector3.zero;
  1702. Debug.Log(anchor.picturePosition.pointRelativeX+" "+ WebMapSize.x);
  1703. anchorPos = new Vector3((float)anchor.picturePosition.pointRelativeX / WebMapSize.x * MapSize.x, -1f, -(float)anchor.picturePosition.pointRelativeY / WebMapSize.y * MapSize.y);
  1704. anchorObj.transform.localPosition = anchorPos;
  1705. anchorObj.transform.GetChild(0).gameObject.SetActive(false);
  1706. var mesh = anchorObj.GetComponent<MeshRenderer>();
  1707. mesh.enabled = false;
  1708. //if(anchor.objectTransform!=null)
  1709. //{
  1710. // anchorObj.transform.localPosition = anchor.objectTransform.nowPos;
  1711. // anchorObj.transform.localEulerAngles = anchor.objectTransform.nowRot;
  1712. //}
  1713. if(anchor.objectTransform!=null && anchor.objectTransform.nowScale!=Vector3.zero)
  1714. {
  1715. anchorObj.transform.localEulerAngles = anchor.objectTransform.nowRot;
  1716. anchorObj.transform.localPosition = anchor.objectTransform.nowPos;
  1717. }
  1718. return mesh;
  1719. }
  1720. #endregion
  1721. #region 触发器判定
  1722. /// <summary>
  1723. /// 当人物进入触发器范围
  1724. /// </summary>
  1725. public void OnColliderTriggerEnter(Collider other)
  1726. {
  1727. IsTriggerExiting = true;
  1728. for (int i = 0; i < ListColliderBoxs.Count; i++)
  1729. {
  1730. if (other.name == ListColliderBoxs[i].name)
  1731. {
  1732. ListShowObjs[i].gameObject.SetActive(true);
  1733. MQTTClient.Instance.sendActiveSp(ListShowObjs[i].name, true);
  1734. Debug.Log(i);
  1735. if (isShowLoacalShowObjs)
  1736. ListLocalShowObjs[i].gameObject.SetActive(true);
  1737. // 进入景点通知后台
  1738. for (int j = 0; j < SceneValue.listSpoit.Count; j++)
  1739. {
  1740. if(SceneValue.listSpoit[i].name == other.name)
  1741. {
  1742. HttpSocket.Instance.SendIpToPointTrigger(" ", SceneValue.listSpoit[i].id, CallBack);
  1743. }
  1744. }
  1745. if (SpoitIndex == i)
  1746. {
  1747. return;
  1748. }
  1749. //进入新区域前关闭当前显示
  1750. if (SpoitIndex >= 0 && IsStartEditor)
  1751. {
  1752. ListShowObjs[SpoitIndex].gameObject.SetActive(false);
  1753. MQTTClient.Instance.sendActiveSp(ListShowObjs[SpoitIndex].name, false);
  1754. if (isShowLoacalShowObjs)
  1755. ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
  1756. ListCrystals[SpoitIndex].gameObject.SetActive(true);
  1757. m_EditorPanel.ClosePanel();
  1758. }
  1759. //进入新的出发区域
  1760. SpoitIndex = i;
  1761. ListCrystals[SpoitIndex].gameObject.SetActive(false);
  1762. m_EditorPanel.SetSpoit(SpoitValues[i]);
  1763. return;
  1764. }
  1765. }
  1766. }
  1767. public void SetPosRotScale()
  1768. {
  1769. refOldData();
  1770. }
  1771. /// <summary>
  1772. /// 当人物退出触发器范围
  1773. /// </summary>
  1774. public void OnColliderTriggerExit(Collider other)
  1775. {
  1776. IsTriggerExiting = false;
  1777. if (IsStartEditor)
  1778. {
  1779. return;
  1780. }
  1781. else
  1782. {
  1783. ListShowObjs[SpoitIndex].gameObject.SetActive(false);
  1784. MQTTClient.Instance.sendActiveSp(ListShowObjs[SpoitIndex].name, false);
  1785. if (isShowLoacalShowObjs)
  1786. ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
  1787. ListCrystals[SpoitIndex].gameObject.SetActive(true);
  1788. m_EditorPanel.ClosePanel();
  1789. SpoitIndex = -1;
  1790. }
  1791. }
  1792. /// <summary>
  1793. /// 更新景点信息
  1794. /// </summary>
  1795. public void UpdateSpoitValue()
  1796. {
  1797. if(SpoitValues!=null&& SpoitValues.Count> SpoitIndex&& SpoitIndex!=-1)
  1798. {
  1799. Debug.Log("SpoitValues====>"+SpoitValues.Count+" _ "+ SpoitIndex);
  1800. var spoit = SpoitValues[SpoitIndex];
  1801. var objvalues = ObjectValues[spoit.id];
  1802. spoit.spoitTf.SavePos(objvalues.nowPos, objvalues.nowRot, objvalues.nowScale);
  1803. //X\Y\W\H
  1804. var collidervalue = ColliderObjectValues[SpoitIndex];
  1805. var collider = collidervalue.Object;
  1806. var pos = collidervalue.nowPos;
  1807. var w = collidervalue.nowScale.x;
  1808. var h = collidervalue.nowScale.z;
  1809. var webpos = new Vector3(Math.Abs(pos.x) / MapSize.x * WebMapSize.x, 0, Math.Abs(pos.z) / MapSize.y * WebMapSize.y);
  1810. var webw = w / MapSize.x * WebMapSize.x;
  1811. var webh = h / MapSize.y * WebMapSize.y;
  1812. spoit.SpoitTransform[0].areaRelativeX = webpos.x;
  1813. spoit.SpoitTransform[0].areaRelativeY = webpos.z;
  1814. spoit.SpoitTransform[0].areaRelativeW = webw;
  1815. spoit.SpoitTransform[0].areaRelativeH = webh;
  1816. spoit.spoitTf.SavePos(objvalues.nowPos, objvalues.nowRot, objvalues.nowScale);
  1817. SpoitValues[SpoitIndex] = spoit;
  1818. }
  1819. return;
  1820. /*
  1821. if (objvalues.Object == null)
  1822. {
  1823. RemoveSpoitObjectValue(spoit.id);
  1824. spoit.material = new List<MaterialObl>();
  1825. }
  1826. else
  1827. {
  1828. var mats = spoit.material;
  1829. var objvalue = objvalues.ChildrenObj;
  1830. for (int j = 0; j < mats.Count; j++)
  1831. {
  1832. var matobj = mats[j];
  1833. var obis = objvalue[j];
  1834. matobj.objectTransform.SavePos(obis.nowPos, obis.nowRot, obis.nowScale);
  1835. for (int m = 0; m < matobj.materialList.Count; m++)
  1836. {
  1837. var childrenobj = obis.ChildrenObj[m];
  1838. var mat = matobj.materialList[m];
  1839. if (childrenobj.Object == null)
  1840. {
  1841. obis.ChildrenObj.RemoveAt(m);
  1842. matobj.materialList.RemoveAt(m);
  1843. break;
  1844. }
  1845. mat.ObjectTransform.SavePos(childrenobj.nowPos, childrenobj.nowRot, childrenobj.nowScale);
  1846. }
  1847. matobj.select = true;
  1848. if (obis.ChildrenObj.Count <= 0)
  1849. {
  1850. mats.RemoveAt(j);
  1851. objvalue.RemoveAt(j);
  1852. Destroy(obis.Object);
  1853. break;
  1854. }
  1855. }
  1856. }
  1857. SpoitValues[SpoitIndex] = spoit;*/
  1858. }
  1859. public void UpdateEditorUI()
  1860. {
  1861. m_EditorPanel.SetSpoit(SpoitValues[SpoitIndex]);
  1862. }
  1863. #endregion
  1864. public ObjectValue GetCurrentColliderValue()
  1865. {
  1866. return ColliderObjectValues[SpoitIndex];
  1867. }
  1868. public void SaveSpoitObjectValue(ObjectValue value)
  1869. {
  1870. if (ObjectValues.ContainsKey(SpoitValues[SpoitIndex].id))
  1871. {
  1872. ObjectValues[SpoitValues[SpoitIndex].id] = value;
  1873. }
  1874. }
  1875. public void RemoveSpoitObjectValue(int id)
  1876. {
  1877. if (ObjectValues.ContainsKey(id))
  1878. {
  1879. ObjectValues.Remove(id);
  1880. }
  1881. }
  1882. public void SaveCurrentColliderValue(ObjectValue value)
  1883. {
  1884. if (ColliderObjectValues.Contains(value))
  1885. {
  1886. ColliderObjectValues[SpoitIndex] = value;
  1887. }
  1888. }
  1889. //计算场景中点云地图比例
  1890. public void CalMapSize()
  1891. {
  1892. //场景地图比例
  1893. var disX = Vector3.Distance(PointA.localPosition, PointD.localPosition);
  1894. var disZ = Vector3.Distance(PointA.localPosition, PointB.localPosition);
  1895. MapSize = new Vector2(disX, disZ);
  1896. //Debug.LogFormat("{0}:{1}", "AB", Vector3.Distance(PointA.localPosition, PointB.localPosition));
  1897. //Debug.LogFormat("{0}:{1}", "CD", Vector3.Distance(PointC.localPosition, PointD.localPosition));
  1898. //Debug.LogFormat("{0}:{1}", "AD", Vector3.Distance(PointA.localPosition, PointD.localPosition));
  1899. //Debug.LogFormat("{0}:{1}", "BC", Vector3.Distance(PointB.localPosition, PointC.localPosition));
  1900. }
  1901. public void CallBack(string message)
  1902. {
  1903. }
  1904. }
  1905. [Serializable]
  1906. public class ObjectValue
  1907. {
  1908. /// <summary>
  1909. /// 景点ID
  1910. /// </summary>
  1911. [SerializeField]
  1912. public int ID;
  1913. /// <summary>
  1914. /// 当前物体名称
  1915. /// </summary>
  1916. [SerializeField]
  1917. public string matName;
  1918. /// <summary>
  1919. /// 父物体ID
  1920. /// -1表示当期物体为景点
  1921. /// </summary>
  1922. [SerializeField]
  1923. public int parentID;
  1924. /// <summary>
  1925. /// 对应的物体
  1926. /// </summary>
  1927. [SerializeField]
  1928. public GameObject Object;
  1929. /// <summary>
  1930. /// 子物体
  1931. /// </summary>
  1932. [SerializeField]
  1933. public List<ObjectValue> ChildrenObj;
  1934. public Vector3 startPos { get; set; }
  1935. public Vector3 startRot { get; set; }
  1936. public Vector3 startScale { get; set; }
  1937. public Vector3 nowPos { get; set; }
  1938. public Vector3 nowRot { get; set; }
  1939. public Vector3 nowScale { get; set; }
  1940. public ObjectValue()
  1941. {
  1942. ChildrenObj = new List<ObjectValue>();
  1943. parentID = -1;
  1944. }
  1945. /// <summary>
  1946. ///
  1947. /// </summary>
  1948. /// <param name="id">景点对应的index</param>
  1949. /// <param name="parentid">景点ID</param>
  1950. /// <param name="name"></param>
  1951. /// <param name="object"></param>
  1952. /// <param name="pos"></param>
  1953. /// <param name="Rot"></param>
  1954. /// <param name="Scale"></param>
  1955. public ObjectValue(int id, int parentid, string name, GameObject @object, Vector3 pos, Vector3 Rot, Vector3 Scale)
  1956. {
  1957. ID = id;
  1958. parentID = parentid;
  1959. matName = name;
  1960. Object = @object;
  1961. ChildrenObj = new List<ObjectValue>();
  1962. startPos = pos;
  1963. nowPos = pos;
  1964. startRot = Rot;
  1965. nowRot = Rot;
  1966. startScale = Scale;
  1967. nowScale = Scale;
  1968. }
  1969. public ObjectValue(int id, int parentid, string name, GameObject @object)
  1970. {
  1971. ID = id;
  1972. parentID = parentid;
  1973. matName = name;
  1974. Object = @object;
  1975. ChildrenObj = new List<ObjectValue>();
  1976. startPos = @object.transform.localPosition;
  1977. nowPos = startPos;
  1978. startRot = @object.transform.localEulerAngles;
  1979. nowRot = startRot;
  1980. startScale = @object.transform.localScale;
  1981. nowScale = startScale;
  1982. }
  1983. /// <summary>
  1984. /// 初始化时当前位置和初始位置
  1985. /// 此方法只在组合素材时使用
  1986. /// </summary>
  1987. public void InitTransform()
  1988. {
  1989. if (Object != null)
  1990. {
  1991. startPos = Object.transform.localPosition;
  1992. nowPos = Object.transform.localPosition;
  1993. startRot = Object.transform.localEulerAngles;
  1994. nowRot = Object.transform.localEulerAngles;
  1995. startScale = Object.transform.localScale;
  1996. nowScale = Object.transform.localScale;
  1997. }
  1998. }
  1999. /// <summary>
  2000. /// 编辑物体坐标时初始化坐标
  2001. /// </summary>
  2002. public void InitObjTransform()
  2003. {
  2004. Object.transform.localPosition = startPos;
  2005. Object.transform.localEulerAngles = startRot;
  2006. Object.transform.localScale = startScale;
  2007. nowPos = startPos;
  2008. nowRot = startRot;
  2009. nowScale = startScale;
  2010. }
  2011. /// <summary>
  2012. /// 编辑物体坐标时保存坐标信息
  2013. /// </summary>
  2014. public void SaveObjTransfoem()
  2015. {
  2016. if (Object != null)
  2017. {
  2018. nowPos = Object.transform.localPosition;
  2019. nowRot = Object.transform.localEulerAngles;
  2020. nowScale = Object.transform.localScale;
  2021. }
  2022. }
  2023. }