1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020 |
- using LitJson;
- using Newtonsoft.Json;
- using SC.XR.Unity;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- public class GameManager : MonoSingleton<GameManager>
- {
- public Text text;
- public GameObject Map;
-
-
-
- [SerializeField, Tooltip("景点对应的物体及景点下的素材")]
- private Dictionary<int, ObjectValue> ObjectValues = new Dictionary<int, ObjectValue>();
- public List<ObjectValue> ColliderObjectValues = new List<ObjectValue>();
- [Header("Spoit")]
- [Tooltip("景点对应的显示物体")]
- public List<Transform> ListShowObjs;
- [Tooltip("景点对应的显示物体,本地添加物体")]
- public List<Transform> ListLocalShowObjs;
- public bool isShowLoacalShowObjs = false;
- [Tooltip("景点对应的物体触发范围")]
- public List<Transform> ListColliderBoxs;
- private List<MeshRenderer> ListColiderBoxs_Mesh;
- [Tooltip("景点对应的水晶点")]
- public List<Transform> ListCrystals;
- [Tooltip("景点对应的显示物体父物体")]
- public Transform ObjsParent;
- [Tooltip("触发器父物体")]
- public Transform CollidersParent;
- [Tooltip("水晶点父物体")]
- public Transform CrystalsParent;
- [Tooltip("锚点父物体")]
- public Transform AnchorsParent;
- public GameObject ColliderItem;
- public GameObject CrystalItem;
- [Space(20)]
- [Tooltip("是否显示路径")]
- public bool IsShowLuJIng = true;
- [Tooltip("是否为编辑模式")]
- public bool IsEditor = true;
- [Tooltip("是否是全自动显示景点")]
- public bool IsAuto = true;
- [SerializeField, Tooltip("路径控制器")]
- private RouteCtr RouteCtr;
- [SerializeField, Tooltip("素材编辑器")]
- private EditorPanel m_EditorPanel;
- [SerializeField, Tooltip("计算人物在地图上的位置")]
- [Header("MinMap")]
- private CalMap m_CalMap;
- [SerializeField, Tooltip("小地图信息")]
- private MinMap m_MinMap;
- [Header("Setting")]
- [SerializeField, Tooltip("设置面板")]
- private SettingPanel m_SettingPanel;
- [SerializeField, Tooltip("编辑器面板")]
- private Transform m_EditorCanvas;
- [SerializeField, Tooltip("设置按钮")]
- private Transform m_SetBtn;
- [Header("地图比例")]
- public Transform PointA;
- public Transform PointB;
- public Transform PointC;
- public Transform PointD;
- public bool isStart;
- public Vector2 WebMapSize;
- public Vector2 MapSize;
- public Vector2 MinMapSize = new Vector2(320, 135);
- public string MapPicUrl;
- [Header("展厅")]
- public GameObject MRZhanTing;
- public bool isPlayMRZhanTing;
- public IrobotMove m_IroBot;
- [Header("Player")]
- public PlayerTrigger Player;
- [Header("Head")]
- public Transform m_head;
- [Header("虚拟导游")]
- public List<IrobotMove> Irobots;
-
-
-
- private bool m_IsTriggerExiting;
-
-
-
-
- public GameObject arcamre;
- public GameObject immser;
- public bool IsTriggerExiting
- {
- get { return m_IsTriggerExiting; }
- set { m_IsTriggerExiting = value; }
- }
-
-
-
- private bool m_IsStartEditor;
-
-
-
- public bool IsStartEditor
- {
- get { return m_IsStartEditor; }
- set { m_IsStartEditor = value; }
- }
-
-
-
- public bool m_IsRuning;
-
-
-
- public bool IsRuning
- {
- get { return m_IsRuning; }
- set { m_IsRuning = value; }
- }
-
-
-
- private int m_SpoitIndex;
-
-
-
- public int SpoitIndex
- {
- get { return m_SpoitIndex; }
- set { m_SpoitIndex = value; }
- }
-
-
-
- public UserSceneItem m_scene;
-
-
-
- public SceneValue m_SceneValue;
-
-
-
- public SceneValue SceneValue
- {
- get { return m_SceneValue; }
- set { m_SceneValue = value; }
- }
-
-
-
- private List<SpoitValue> m_SpoitValues;
-
-
-
- public List<SpoitValue> SpoitValues
- {
- get { return m_SpoitValues; }
- set { m_SpoitValues = value; }
- }
-
-
-
- private Dictionary<int, SpoitValueDetail> m_SpoitsValueDetail;
-
-
-
- public Dictionary<int, SpoitValueDetail> SpoitsValueDetail
- {
- get { return m_SpoitsValueDetail; }
- set { m_SpoitsValueDetail = value; }
- }
- public UIAnchorsPanel m_UIAnchorsPanel;
- private Dictionary<Anchor, MeshRenderer> m_AnchorValue;
- public Dictionary<Anchor, MeshRenderer> AnchorValue
- {
- get { return m_AnchorValue; }
- set { m_AnchorValue = value; }
- }
- private Dictionary<Anchor, GameObject> m_AnchorChild;
- public Dictionary<Anchor,GameObject> AnchorChild
- {
- get { return m_AnchorChild; }
- set { m_AnchorChild = value; }
- }
- public Toggle EditorToggle;
- private void Awake()
- {
-
- }
- public Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>> allOldobjs = new Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>>();
- public Dictionary<string, Dictionary<string, Dictionary<string, GameObject>>> allobjs = new Dictionary<string, Dictionary<string, Dictionary<string, GameObject>>>();
- public bool isShowDownTip;
- private void Start()
- {
- this.gameObject.AddComponent<TimerMgr>();
-
- isStart = false;
- m_SpoitsValueDetail = new Dictionary<int, SpoitValueDetail>();
- m_AnchorValue = new Dictionary<Anchor, MeshRenderer>();
- m_AnchorChild = new Dictionary<Anchor, GameObject>();
- SceneValue = null;
- m_IsStartEditor = false;
- m_IsRuning = false;
- m_SetBtn.gameObject.SetActive(false);
-
- SpoitIndex = -1;
- SpoitValues = new List<SpoitValue>();
- if (m_EditorPanel == null)
- {
- m_EditorPanel = GameObject.FindObjectOfType<EditorPanel>();
- }
-
- if (!IsAuto)
- {
-
-
- }
- else
- {
- ListShowObjs = new List<Transform>();
- ListColliderBoxs = new List<Transform>();
- ListColiderBoxs_Mesh = new List<MeshRenderer>();
- ListCrystals = new List<Transform>();
-
- }
- m_MinMap.gameObject.SetActive(false);
- Map.SetActive(false);
- var t = TimerMgr.Instance.CreateTimer(()=> {
- if(isShowDownTip)
- {
- Debug.Log("HJJ 判断正在下载");
- if (downLoadCount == 0)
- {
- downLoadCount = COSDownLoad.showDownEndLoadCount;
- Debug.Log("HJJ 判断正在下载downLoadCount==0");
- }
- if (COSDownLoad.showDownLoadCount > COSDownLoad.showDownEndLoadCount)
- {
- Debug.Log("HJJ 判断正在下载COSDownLoad.showDownLoadCount > COSDownLoad.showDownEndLoadCount");
- string str = string.Format("{0}/{1}正在下载,{2}%", (COSDownLoad.showDownEndLoadCount - downLoadCount), COSDownLoad.showDownLoadCount - downLoadCount, COSDownLoad.showDownLoadPre.ToString("F2"));
- UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.download);
- ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str;
- }
- else
- {
- Debug.Log("HJJ 判断正在下载downLoadCount != 0");
- UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
- downLoadCount = 0;
- UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.updateEnd);
- isShowDownTip = false;
- }
- if(COSDownLoad.showDownLoadCount==0&& downLoadCount ==0)
- {
- Debug.Log("HJJ 判断正在下载COSDownLoad.showDownLoadCount==0&& downLoadCount ==0");
- Debug.Log("DGJ updateEnd ");
- UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.updateEnd);
- isShowDownTip = false;
-
- }
- }
- },1,-1);
- }
- int downLoadCount = 0;
- private void LateUpdate()
- {
-
-
- m_SetBtn.transform.LookAt(OpenXRCamera.Instance.head);
- m_SetBtn.transform.localEulerAngles = new Vector3(0, m_SetBtn.transform.localEulerAngles.y+180, 0);
-
-
- m_SetBtn.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward * 1.3f + new Vector3(-0.2f, 1f, 0);
-
- if (avplayer && !avplayer.IsPlaying()&& !TemplateVideo.isPlayLock)
- {
- Debug.Log("HJJVideo 创建锁解开 并且播放完毕");
- TemplateVideo.isPlaying = false;
- avplayer = null;
- }
- if (TemplateVideo.temQueue.Count>0&&!TemplateVideo.isPlaying &&!TemplateVideo.isPlayLock)
- {
- Debug.Log("HJJVideo 开始播放");
- TemplateVideo.isPlaying = true;
- TimerMgr.Instance.CreateTimer(()=> {
- Debug.Log("HJJVideo 播放的创建锁 创建锁解开");
- TemplateVideo.isPlayLock = false;
- },3);
- TemplateVideo video = TemplateVideo.temQueue.Dequeue();
- #if !UNITY_EDITOR
- if (!video.localSavePath.Contains("file"))
- video.m_Video.SetUrl("file://" + video.localSavePath);
- #endif
- video.m_Video.transform.GetComponent<VideoPlayBtn>().m_IsPlaying = false;
- video.m_Video.transform.GetComponent<VideoPlayBtn>().PlayVideoAuto();
- avplayer = video.m_Video;
- }
- }
- float lockTime = 0;
- public AVProVideoPlayer avplayer;
- public void Init()
- {
- }
- private void InitCrystals()
- {
- for (int i = 0; i < ListCrystals.Count; i++)
- {
- ListCrystals[i].gameObject.SetActive(true);
- }
- }
- private void InitBoxColliders()
- {
- for (int i = 0; i < ListColliderBoxs.Count; i++)
- {
- ListColliderBoxs[i].gameObject.SetActive(true);
- }
- }
- public void IntoScene()
- {
- Map.SetActive(true);
-
-
-
-
- StartCoroutine(StartScene(isPlayMRZhanTing));
- HttpSocket.Instance.SendIpToElectric();
- if(!UserInfo.Instance.is20)
- MQTTClient.Instance.StartSendCameraPos();
- }
- public void saveOldData()
- {
- allOldobjs = new Dictionary<string, Dictionary<string, Dictionary<string, PosRotScalePatch>>>();
- foreach (var i in allobjs.Keys)
- {
- allOldobjs.Add(i, new Dictionary<string, Dictionary<string, PosRotScalePatch>>());
- foreach (var j in allobjs[i].Keys)
- {
- allOldobjs[i].Add(j, new Dictionary<string, PosRotScalePatch>());
- foreach (var k in allobjs[i][j].Keys)
- {
- PosRotScalePatch p = new PosRotScalePatch();
- p.PosPatch = allobjs[i][j][k].transform.localPosition;
- p.RotPatch = allobjs[i][j][k].transform.localEulerAngles;
- p.ScalePatch = allobjs[i][j][k].transform.localScale;
- allOldobjs[i][j].Add(k, p);
- }
- }
- }
- }
- public void refOldData()
- {
- foreach (var i in allobjs.Keys)
- {
- foreach (var j in allobjs[i].Keys)
- {
- foreach (var k in allobjs[i][j].Keys)
- {
- allobjs[i][j][k].transform.localPosition = allOldobjs[i][j][k].PosPatch;
- allobjs[i][j][k].transform.localEulerAngles = allOldobjs[i][j][k].RotPatch;
- allobjs[i][j][k].transform.localScale = allOldobjs[i][j][k].ScalePatch;
- }
- }
- }
- }
- IEnumerator StartScene( bool isPlayMRZhanTing)
- {
- yield return new WaitForSeconds(0.5f);
- if(isPlayMRZhanTing)
- {
-
-
-
- MRZhanTing.gameObject.SetActive(true);
- MRZhanTing.transform.position = API_GSXR_Slam.GSXR_Get_Head().position + API_GSXR_Slam.GSXR_Get_Head().forward + new Vector3(0, -0.7f, 0);
- MRZhanTing.transform.localEulerAngles = new Vector3(0, API_GSXR_Slam.GSXR_Get_Head().eulerAngles.y, 0);
- yield return new WaitForSeconds(18f);
- MRZhanTing.gameObject.SetActive(false);
-
- }
- m_SettingPanel.gameObject.SetActive(true);
- m_EditorPanel.Init();
- m_SettingPanel.Init();
- if (RouteCtr.CurrentPoints.Count > 0)
- {
- Player.MovePoints = RouteCtr.CurrentPoints;
-
-
-
-
-
- m_IroBot.gameObject.SetActive(true);
- m_IroBot.Points = RouteCtr.CurrentPoints;
- yield return new WaitForSeconds(5f);
-
- }
- IsRuning = true;
- m_SetBtn.gameObject.SetActive(true);
- InitCrystals();
- InitBoxColliders();
- }
- private int ChooseIroBot()
- {
- int id = 3;
- var navlines = DataManager.Instance.CurrentScene.navLines;
- if (navlines.Count > 0)
- {
- id = navlines[0].guideMod;
- }
- return id;
- }
-
-
-
- private void GetObjectValue()
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #region 设置功能
- public bool needSavePosRotScale = true;
- public void OnEditorBtnValueChanged(bool ison)
- {
- m_EditorCanvas.gameObject.SetActive(ison);
- m_IsStartEditor = ison;
- for (int i = 0; i < ListColiderBoxs_Mesh.Count; i++)
- {
- ListColiderBoxs_Mesh[i].enabled = ison;
- }
- if (ison)
- {
- if (needSavePosRotScale)
- {
- GetPosRotScale();
- needSavePosRotScale = false;
- }
- m_EditorCanvas.position = OpenXRCamera.Instance.head.position + Player.transform.forward + new Vector3(0, 0.5f, 0);
- m_EditorCanvas.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
- CommandSystem.Instance.Send( new EditorSettingCommand(true){ } );
- CommandSystem.Instance.Send( new Patch_VideoCommand(true){ } );
- }
- else
- {
- m_EditorCanvas.position = OpenXRCamera.Instance.head.position + new Vector3(0, 100, 0);
- if (SpoitIndex >= 0 && !IsTriggerExiting)
- {
- ListShowObjs[SpoitIndex].gameObject.SetActive(false);
- if (isShowLoacalShowObjs)
- ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
- ListCrystals[SpoitIndex].gameObject.SetActive(true);
- m_EditorPanel.ClosePanel();
- SpoitIndex = -1;
- }
- CommandSystem.Instance.Send( new EditorSettingCommand(false){ } );
- CommandSystem.Instance.Send( new Patch_VideoCommand(false){ } );
- }
- }
- public static bool m_IsStartEditorJD;
- public void open20zuJD(bool ison)
- {
- m_IsStartEditorJD = ison;
- if (!ison)
- {
-
- }
- SaveButton.SetActive(ison);
- }
- public static bool m_IsStartEditorzu;
- public void open20zu(bool ison)
- {
- m_IsStartEditorzu = ison;
- if (!ison)
- {
-
- }
- SaveButton.SetActive(ison);
- }
-
- public void open20Editor(bool ison)
- {
- m_IsStartEditor = ison;
- if(!ison)
- {
-
- }
- SaveButton.SetActive(ison);
- }
- public GameObject SaveButton;
- public void save20All()
- {
- if (!m_IsStartEditor)
- {
- List<SendSaveDataNew> saveData = new List<SendSaveDataNew>();
- foreach (var i in UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].SpotsList.Keys)
- {
- SpotsItem sp = UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].SpotsList[i.ToString()];
- SendSaveDataNew data = new SendSaveDataNew();
- data.position = sp.position;
- data.id = int.Parse(sp.id);
- data.name = sp.name;
- data.projectId = int.Parse(UserSceneManager.Instance.SceneList[UserSceneManager.Instance.nowId].id);
- List<MaterialOblNew> MaterialObllsit = new List<MaterialOblNew>();
- foreach (var z in sp.modelList.Keys)
- {
- ObjectTransform objt2 = new ObjectTransform();
- objt2.nowPos = sp.modelList[z].Model.transform.localPosition;
- objt2.nowRot = sp.modelList[z].Model.transform.localEulerAngles;
- objt2.nowScale = sp.modelList[z].Model.transform.localScale;
- sp.modelList[z].objectTransform = objt2;
- List<MaterialObjValueNew> materialList = new List<MaterialObjValueNew>();
- for (int j = 0; j < sp.modelList[z].materialList.Count; j++)
- {
- ObjectTransform objt3 = new ObjectTransform();
- objt3.nowPos = sp.modelList[z].materialList[j].prefabModel.transform.localPosition;
- objt3.nowRot = sp.modelList[z].materialList[j].prefabModel.transform.localEulerAngles;
- objt3.nowScale = sp.modelList[z].materialList[j].prefabModel.transform.localScale;
- sp.modelList[z].materialList[j].objectTransform = objt3;
- MaterialObjValueNew mov = new MaterialObjValueNew();
- mov.uid = sp.modelList[z].materialList[j].uid;
- mov.id = sp.modelList[z].materialList[j].id;
- mov.fileId = sp.modelList[z].materialList[j].fileId;
- mov.type = sp.modelList[z].materialList[j].type;
- mov.textContent = sp.modelList[z].materialList[j].textContent.ToString();
- mov.textPosition = sp.modelList[z].materialList[j].textPosition.ToString();
- mov.textBJ = sp.modelList[z].materialList[j].TextBJ.ToString();
- mov.downloadPath = sp.modelList[z].materialList[j].DownloadPath.ToString();
- mov.localSavePath = sp.modelList[z].materialList[j].localSavePath.ToString();
- mov.name = sp.modelList[z].materialList[j].name;
- mov.template = sp.modelList[z].materialList[j].template;
- mov.objectTransform = sp.modelList[z].materialList[j].objectTransform;
- materialList.Add(mov);
- }
- MaterialOblNew obj = new MaterialOblNew();
- obj.id = sp.modelList[z].id;
- obj.name = sp.modelList[z].name;
- obj.objectTransform = sp.modelList[z].objectTransform;
- obj.describe = sp.modelList[z].describe;
- obj.select = sp.modelList[z].select;
- obj.type = sp.modelList[z].type;
- obj.materialList = materialList;
- MaterialObllsit.Add(obj);
- }
- data.material = MaterialObllsit;
- ObjectTransform objt = new ObjectTransform();
- objt.nowPos = sp.SpotsObj.transform.localPosition;
- objt.nowRot = sp.SpotsObj.transform.localEulerAngles;
- objt.nowScale = sp.SpotsObj.transform.localScale;
- data.spoittf = objt;
-
- saveData.Add(data);
- }
- string sendData = JsonConvert.SerializeObject(saveData);
-
- Debug.Log("更新景点数据: " + sendData);
- HttpTool.Instance.PostTest(HttpAction.viewpoint_update, sendData, (string str) => {
- JsonData jd = JsonMapper.ToObject(str);
- if(jd["message"].ToString()=="success")
- {
- InstantiateCommand Command = new InstantiateCommand(
- InstantiateSystem.Instance.BlueObject.WarningPopUp,
- InstantiateSystem.Instance.BlueObject.SuccessText);
- CommandSystem.Instance.Send(Command);
- }else
- {
- InstantiateCommand Command = new InstantiateCommand(
- InstantiateSystem.Instance.BlueObject.WarningPopUp,
- InstantiateSystem.Instance.BlueObject.NetErrorText);
- CommandSystem.Instance.Send(Command);
- }
- Debug.Log("保存回调===》" + str);
- });
- }
- }
- public void OnSettingBtnValueChanged(bool ison)
- {
- m_SettingPanel.gameObject.SetActive(ison);
- if (ison)
- {
- Debug.Log(OpenXRCamera.Instance.head.forward);
- m_SettingPanel.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward;
- m_SettingPanel.transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
- }
- }
- public void OnAnchorBtnValueChanged(bool ison)
- {
- foreach (var item in m_AnchorValue)
- {
- item.Value.enabled = ison;
- }
-
-
-
-
- if(ison)
- {
- m_UIAnchorsPanel.transform.position = OpenXRCamera.Instance.head.position + Player.transform.forward + new Vector3(0, 0.5f, 0);
- m_UIAnchorsPanel.transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
- }
- else
- {
- m_UIAnchorsPanel.transform.position = OpenXRCamera.Instance.head.position + new Vector3(0, 100, 0);
- }
- }
- public void GetPosRotScale()
- {
- saveOldData();
- return;
- PosRotScale.PosRotScalePatchList.Clear();
- for (int i = 0; i < GameManager.Instance.ObjsParent.childCount; i++)
- {
- if (i != 0)
- {
- for (int j = 0; j < GameManager.Instance.ObjsParent.GetChild(i).childCount; j++)
- {
- for (int k = 0; k < GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).childCount; k++)
- {
- PosRotScalePatch PosRotScalePatch = new PosRotScalePatch();
- PosRotScalePatch.PosPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
- PosRotScalePatch.RotPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
- PosRotScalePatch.ScalePatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
- PosRotScale.PosRotScalePatchList.Add(PosRotScalePatch);
- }
- }
- }
- }
- }
- #endregion
- #region 获取景点信息--素材编辑模式下
-
-
-
-
-
- public ObjectValue GetSpoitObjs(int spoitID)
- {
- if (ObjectValues.ContainsKey(spoitID))
- {
- return ObjectValues[spoitID];
- }
- else
- {
- return null;
- }
- }
-
-
-
-
-
- public void InitSpoitObjs()
- {
- m_EditorPanel.InitObjTransForm();
- }
-
-
-
-
-
- public void SaveSpoitObjs()
- {
- m_EditorPanel.SaveObjTransForm();
- }
- public void SaveAnchorObjs( string name)
- {
- foreach (var item in AnchorValue)
- {
- item.Key.objectTransform.SavePos(item.Value.transform.localPosition, item.Value.transform.localEulerAngles, item.Value.transform.localScale);
- }
-
- m_UIAnchorsPanel.SaveAnchors(name);
- }
- #endregion
- #region 创建水晶点、触发器范围、显示物体
- public IEnumerator CreateScene(SceneValue scene)
- {
- SceneValue = scene;
- if (m_MinMap.Map.sprite == null)
- {
- GetMinMap(scene ,null);
- }
- else
- {
- yield return StartCoroutine(StartCreateScene(scene));
- }
- yield return new WaitForSeconds(1f);
- MoveScenePatch();
- }
- private void MoveScenePatch()
- {
- Vector3 temp = ObjsParent.parent.localPosition;
- temp.z += MapSize.y;
- ObjsParent.parent.localPosition = temp;
- }
- private IEnumerator StartCreateScene(SceneValue scene)
- {
- if (scene.navLines != null && scene.navLines.Count > 0)
- SetRouteValue(scene.navLines);
- else
- Debug.LogError(" 当前场景未设置路径");
- Debug.Log("DGJ ====> " + JsonConvert.SerializeObject(scene));
- if (scene.listSpoit != null && scene.listSpoit.Count > 0)
- yield return StartCoroutine(SetSpoitValue(scene.listSpoit));
- else
- Debug.LogError(" 当前场景未创建景点");
- if (scene.listPicture != null && scene.listPicture.Count > 0)
- SetAnchor(scene.listPicture);
- else
- Debug.LogError(" 当前场景未创建锚点");
-
-
- yield return null;
-
-
-
- }
- Action<bool> GetMinMapBack;
-
-
-
- public void GetMinMap( SceneValue scene ,Action<bool> getBack)
- {
- GetMinMapBack = getBack;
-
-
-
-
-
-
-
- if(scene.width>0 &&scene.length>0)
- {
-
- isStart = true;
- PointB.position = Vector3.zero;
- PointB.eulerAngles = Vector3.zero;
- PointA.position = PointB.position + new Vector3(0, 0, scene.width);
- PointA.eulerAngles = Vector3.zero;
- PointC.position = PointB.position + new Vector3(scene.length, 0, 0);
- PointC.eulerAngles = Vector3.zero;
- PointD.position = PointB.position + new Vector3(scene.length, 0, scene.width);
- PointD.eulerAngles = Vector3.zero;
- m_CalMap.SettingMapPoint(ListCrystals);
- }
- DownLoadMaterial downLoadMaterial = new DownLoadMaterial();
- downLoadMaterial.downLoadPath = MapPicUrl;
- downLoadMaterial.localLoadPath = Application.persistentDataPath + "/Material/" + MapPicUrl;
- downLoadMaterial.updataTime = scene.updateTime;
- downLoadMaterial.type = "-1";
- Debug.Log("Hjj 开始获取地图大小==》");
- MsgHandler.AddListener(downLoadMaterial.downLoadPath, HandleMsg);
- DownloadResManager.Instance.DownLoad(downLoadMaterial);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GameManager.Instance.isShowDownTip = true;
- DownloadResManager.Instance.StartDownLoad();
- }
- private void HandleMsg(Msg msg)
- {
- Debug.Log("Hjj 获取地图大小==》");
-
- if(msg.Value!=null)
- {
- Texture2D tex = new Texture2D(1, 1);
- tex.LoadImage((byte[])msg.Value);
-
- Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
- m_MinMap.Map.sprite = sprite;
-
- float width = tex.width;
- float height = tex.height;
- if (width > height)
- {
- width = width / height;
- height = 1;
- }
- else
- {
- height = height / width;
- width = 1;
- }
- MinMapSize = new Vector2(width * 150, height * 150);
- CalMapSize();
- m_MinMap.Map.GetComponent<RectTransform>().sizeDelta = new Vector2(width * 150, height * 150);
-
- WebMapSize = new Vector2((float)tex.width, (float)tex.height);
- if (SceneValue != null)
- {
- StartCreateScene(SceneValue);
- }
- GetMinMapBack?.Invoke(true);
- }else
- {
- GetMinMapBack?.Invoke(false);
- }
- }
-
-
-
-
- public IEnumerator SetSpoitValue(List<SpoitValue> spoits)
- {
-
- SpoitValue spoitValue;
- for (int i = 0; i < spoits.Count-1; i++)
- {
- spoitValue = null;
- for (int j = 0; j < spoits.Count-1-i; j++)
- {
- if(spoits[j].id>spoits[j+1].id)
- {
- spoitValue = spoits[j];
- spoits[j] = spoits[j+1];
- spoits[j+1] = spoitValue;
- }
- }
- }
- SpoitValues.Clear();
- for (int i = 0; i < spoits.Count; i++)
- {
- var spoit = spoits[i];
- SpoitValue spoit1 = spoit;
- CreateCrystalAndTrigger(spoit);
- yield return StartCoroutine(CreateMaterial(spoit));
- spoits[i] = SV;
- }
- for (int i = 0; i < ListColiderBoxs_Mesh.Count; i++)
- {
- ListColiderBoxs_Mesh[i].enabled = false;
- }
- SpoitValues.AddRange(spoits);
- SceneValue.listSpoit = SpoitValues;
- DataManager.Instance.Spoits = SpoitValues;
- }
-
-
-
- private void CreateCrystalAndTrigger(SpoitValue spoit)
- {
- var spoitPos = Vector3.zero;
- if (spoit.SpoitTransform!=null&&spoit.SpoitTransform.Count > 0)
- {
- Debug.LogFormat("{0}{1}", spoit.name, " DGJ ===> 景点存在");
- SpoitPos trans = spoit.SpoitTransform[0];
- spoitPos = new Vector3((float)trans.pointRelativeX / WebMapSize.x * MapSize.x, -1f, -(float)trans.pointRelativeY / WebMapSize.y * MapSize.y);
-
- var obj = Instantiate(CrystalItem, CrystalsParent);
- CommandSystem.Instance.Send(
- new InstantiateGOCommand(InstantiateSystem.Instance.BlueObject.SpoitName, obj.gameObject)
- );
- obj.name = spoit.name;
- obj.transform.localPosition = spoitPos;
- ListCrystals.Add(obj.transform);
- var spoitobj = CreateSpoit(spoit, spoitPos);
- ListShowObjs.Add(spoitobj.transform);
- ObjectValue spoitvalue = new ObjectValue(spoit.id, -1, spoitobj.name, spoitobj);
- ObjectValues.Add(spoit.id, spoitvalue);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var tiggerpos = new Vector3((float)(trans.areaRelativeX + trans.areaRelativeW / 2) / WebMapSize.x * MapSize.x, -0.5f, -(float)(trans.areaRelativeY + trans.areaRelativeH / 2) / WebMapSize.y * MapSize.y);
- var tiggerRange = new Vector3((float)trans.areaRelativeW / WebMapSize.x * MapSize.x, 0.1f, (float)trans.areaRelativeH / WebMapSize.y * MapSize.y);
- var triggerobj = Instantiate(ColliderItem, CollidersParent);
- triggerobj.name = spoit.name;
- triggerobj.transform.localPosition = tiggerpos;
- triggerobj.transform.localScale = tiggerRange;
-
- ObjectValue boxvalue = new ObjectValue(spoit.id, -1, triggerobj.name, triggerobj);
- ColliderObjectValues.Add(boxvalue);
- ListColliderBoxs.Add(triggerobj.transform);
- ListColiderBoxs_Mesh.Add(triggerobj.GetComponent<MeshRenderer>());
- }
- else
- {
- Debug.LogFormat("{0}{1}", spoit.name, "景点不存在");
- }
- }
- private GameObject CreateSpoit(SpoitValue spoit, Vector3 spoitPos)
- {
-
- GameObject spoitObj = new GameObject(spoit.name);
- spoitObj.transform.SetParent(ObjsParent.transform);
- spoitObj.AddComponent<EditorEventHandler>().IsClickEditor = false;
-
- if (spoit.spoitTf.startPos == Vector3.zero && spoit.spoitTf.nowPos == Vector3.zero)
- {
- spoitObj.transform.localPosition = new Vector3(spoitPos.x, 0.5f, spoitPos.z);
- spoitObj.transform.localRotation = Quaternion.identity;
- spoitObj.transform.localScale = new Vector3(1, 1, 1);
- spoit.spoitTf.SetStartValue(spoitObj.transform.localPosition, spoitObj.transform.localEulerAngles, spoitObj.transform.localScale);
- }
- else
- {
- spoitObj.transform.localPosition = spoit.spoitTf.nowPos;
- spoitObj.transform.localEulerAngles = spoit.spoitTf.nowRot;
- spoitObj.transform.localScale = spoit.spoitTf.nowScale;
- }
- return spoitObj;
- }
- SpoitValue SV;
-
-
-
-
- private IEnumerator CreateMaterial(SpoitValue spoit)
- {
- if(!ObjectValues.ContainsKey(spoit.id))
- {
- SV = new SpoitValue();
- }
- else
- {
- var spoitValues = ObjectValues[spoit.id];
- var spoitObj = spoitValues.Object;
- Debug.Log("DGJ ===> 创建整体素材 "+ spoit.material.Count);
- SyncSpoit syncSpoit = new SyncSpoit();
- syncSpoit.spoitId = spoit.name;
- syncSpoit.spoitObj = spoitObj;
- MultiPlayerManager.Instance.dicSpoitValue.Add(spoit.name, syncSpoit);
- if(!UserInfo.Instance.is20)
-
- for (int i = 0; i < spoit.material.Count; i++)
- {
-
- MaterialObl material = spoit.material[i];
-
-
- GameObject matObj = new GameObject(material.name);
- matObj.transform.SetParent(spoitValues.Object.transform);
- matObj.transform.localPosition = Vector3.zero;
- matObj.transform.localEulerAngles = Vector3.zero;
- matObj.transform.localScale = new Vector3(1, 1, 1);
- material.objectTransform.SetStartValue(matObj.transform.localPosition, matObj.transform.localEulerAngles, matObj.transform.localScale);
-
- ObjectValue spoitValue = new ObjectValue(i, spoit.id, material.name, matObj);
-
- List<ObjectValue> objsvalue = null;
- MaterialObl newmaterial = material;
-
- switch (material.type)
- {
- case (int)MaterialType.None:
- break;
- case (int)MaterialType.Image:
- case (int)MaterialType.Video:
- case (int)MaterialType.Model:
- case (int)MaterialType.Text:
- case (int)MaterialType.LocaImage:
- Debug.Log("DGJ ===> LocalImage " + material.name);
- objsvalue = CreateSuCaiObj(spoit,material, matObj, out newmaterial);
- break;
- case (int)MaterialType.Image_Video_Text:
- Debug.Log("DGJ ===> Image_Video_Text " + material.name);
- objsvalue = CreateImage_Video_Text(spoit,material, matObj, out newmaterial);
- break;
- case (int)MaterialType.Model_Text:
- Debug.Log("DGJ ===> Model_Text " + material.name);
- objsvalue = CreateModel_Text(spoit,material, matObj, out newmaterial);
- break;
- default:
- break;
- }
-
- spoit.material[i] = newmaterial;
- spoitValue.ChildrenObj.AddRange(objsvalue);
- spoitValues.ChildrenObj.Add(spoitValue);
- }
- SV = spoit;
- if (ObjectValues.ContainsKey(spoit.id))
- {
- ObjectValues[spoit.id] = spoitValues;
- }
- else
- {
- ObjectValues.Add(spoit.id, spoitValues);
- }
- spoitObj.gameObject.SetActive(false);
- }
- yield return null;
- }
-
-
-
-
- public void AddMaterial(MaterialObl material)
- {
- if (SpoitIndex < 0)
- {
- return;
- }
- MaterialObl newmaterial = new MaterialObl();
- newmaterial = material;
- var spoit = SpoitValues[SpoitIndex];
- var spoitValues = ObjectValues[spoit.id];
- var spoitObj = spoitValues.Object;
-
- GameObject matObj = new GameObject(newmaterial.name + "-" + spoit.material.Count.ToString());
- newmaterial.name = matObj.name;
- matObj.transform.SetParent(spoitValues.Object.transform);
- if (!material.select)
- {
- matObj.transform.localPosition = Vector3.zero;
- matObj.transform.localEulerAngles = Vector3.zero;
- matObj.transform.localScale = new Vector3(1, 1, 1);
- newmaterial.objectTransform.SetStartValue(matObj.transform.localPosition, matObj.transform.localEulerAngles, matObj.transform.localScale);
- }
- else
- {
- matObj.transform.localPosition = newmaterial.objectTransform.nowPos;
- matObj.transform.localEulerAngles = newmaterial.objectTransform.nowRot;
- matObj.transform.localScale = newmaterial.objectTransform.nowScale;
- }
-
- ObjectValue spoitValue = new ObjectValue(spoit.material.Count, spoit.id, newmaterial.name, matObj);
-
- List<ObjectValue> objsvalue = null;
-
- switch (material.type)
- {
- case (int)MaterialType.None:
- break;
- case (int)MaterialType.Image:
- case (int)MaterialType.Video:
- case (int)MaterialType.Model:
- case (int)MaterialType.Text:
- case (int)MaterialType.LocaImage:
- objsvalue = CreateSuCaiObj(spoit, newmaterial, matObj, out newmaterial);
- break;
- case (int)MaterialType.Image_Video_Text:
- objsvalue = CreateImage_Video_Text(spoit,newmaterial, matObj, out newmaterial);
- break;
- case (int)MaterialType.Model_Text:
- objsvalue = CreateModel_Text(spoit, newmaterial, matObj, out newmaterial);
- break;
- default:
- break;
- }
- newmaterial.select = true;
- spoit.material.Add(newmaterial);
- spoitValue.ChildrenObj.AddRange(objsvalue);
- spoitValues.ChildrenObj.Add(spoitValue);
- if (ObjectValues.ContainsKey(spoit.id))
- {
- ObjectValues[spoit.id] = spoitValues;
- }
- else
- {
- ObjectValues.Add(spoit.id, spoitValues);
- }
- SpoitValues[SpoitIndex] = spoit;
-
- UpdateEditorUI();
- }
-
-
-
-
-
-
-
-
- private List<ObjectValue> CreateSuCaiObj(SpoitValue spoitjd, MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
- {
- List<ObjectValue> objects = new List<ObjectValue>();
- List<MaterialObjValue> objs = material.materialList;
- newmaterial = material;
-
-
-
-
- for (int i = 0; i < objs.Count; i++)
- {
- var mat = objs[i];
- GameObject go = null;
- switch (mat.type)
- {
- case (int)MaterialType.None:
- break;
- case (int)MaterialType.Image:
- var pImage = ResMgr.Instance.Load<GameObject>("Template/Prefab/Image");
- go = Instantiate(pImage, spoit.transform);
- var imageitem = go.AddComponent<TemplateImage>();
- go.SetActive(true);
- imageitem.SetData(mat, material.updateTime);
- break;
- case (int)MaterialType.Video:
- var pVideo = ResMgr.Instance.Load<GameObject>("Template/Prefab/Video");
- go = Instantiate(pVideo, spoit.transform);
- var videoitem = go.AddComponent<TemplateVideo>();
- videoitem.autoplay = material.autoplay;
- go.SetActive(true);
- videoitem.SetData(mat, material.updateTime);
-
- break;
- case (int)MaterialType.Model:
- var pModel = ResMgr.Instance.Load<GameObject>("Template/Prefab/Model");
- go = Instantiate(pModel, spoit.transform);
- var modelitem = go.AddComponent<TemplateModel>();
- go.SetActive(true);
- modelitem.SetData(mat, material.updateTime);
- Debug.Log(modelitem.Data.localLoadPath);
- break;
- case (int)MaterialType.Text:
- var pText = ResMgr.Instance.Load<GameObject>("Template/Prefab/Text");
- go = Instantiate(pText, spoit.transform);
- var textitem = go.AddComponent<TemplateText>();
- go.SetActive(true);
- textitem.SetData(mat, material.updateTime);
- break;
- case (int)MaterialType.LocaImage:
- var pLocaImage = ResMgr.Instance.Load<GameObject>("Template/Prefab/Image");
- go = Instantiate(pLocaImage, spoit.transform);
- var locaImageitem = go.AddComponent<TemplateImage>();
- go.SetActive(true);
- locaImageitem.SetLocaImageData(mat);
- break;
- default:
- break;
- }
- if (go != null)
- {
- if (!GameManager.Instance.allobjs.ContainsKey(spoitjd.id.ToString()))
- {
- GameManager.Instance.allobjs.Add(spoitjd.id.ToString(), new Dictionary<string, Dictionary<string, GameObject>>());
- }
- if (!GameManager.Instance.allobjs[spoitjd.id.ToString()].ContainsKey(material.id.ToString()))
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()].Add(material.id.ToString(), new Dictionary<string, GameObject>());
- }
- if (!GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].ContainsKey(mat.id.ToString()))
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].Add(mat.id.ToString(), go);
- }
- else
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()][mat.id.ToString()] = go;
- }
- go.name = string.IsNullOrWhiteSpace(mat.name) ? spoit.name + "-" + i.ToString() : mat.name;
- mat.name = go.name;
- go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
- if (material.select)
- {
- go.transform.localPosition = mat.ObjectTransform.nowPos;
- go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
- go.transform.localScale = mat.ObjectTransform.nowScale;
- }
- else
- {
- go.transform.localEulerAngles = Vector3.zero;
- go.transform.localScale = new Vector3(1, 1, 1);
- if (mat.type != (int)MaterialType.Text)
- {
- go.transform.localPosition = Vector3.zero;
- }
- else
- {
-
- if (mat.textPosition == "top")
- {
- go.transform.localPosition = new Vector3(0, 0.3f, 0);
- }
- else if (mat.textPosition == "bottom")
- {
- go.transform.localPosition = new Vector3(0, -0.3f, 0);
- }
- }
- mat.ObjectTransform.SetStartValue(go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
- }
- ObjectValue objectValue = new ObjectValue(i, material.id, mat.name, go);
- objects.Add(objectValue);
- }
- newmaterial.materialList[i] = mat;
- }
- return objects;
- }
-
-
-
-
-
-
- private List<ObjectValue> CreateModel_Text(SpoitValue spoitjd, MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
- {
- List<ObjectValue> objects = new List<ObjectValue>();
- List<MaterialObjValue> objs = material.materialList;
- newmaterial = material;
- for (int i = 0; i < objs.Count; i++)
- {
- var mat = objs[i];
- GameObject go = null;
- switch (mat.type)
- {
- case (int)MaterialType.None:
- break;
- case (int)MaterialType.Model:
- var pModel = ResMgr.Instance.Load<GameObject>("Template/Prefab/Model");
- go = Instantiate(pModel, spoit.transform);
- var modelitem = go.AddComponent<TemplateModel>();
- go.SetActive(true);
- modelitem.SetData(mat, material.updateTime);
- break;
- case (int)MaterialType.Text:
- var pText = ResMgr.Instance.Load<GameObject>("Template/Prefab/Text");
- go = Instantiate(pText, spoit.transform);
- var textitem = go.AddComponent<TemplateText>();
- go.SetActive(true);
- textitem.SetData(mat, material.updateTime);
- break;
- default:
- break;
- }
- if (go != null)
- {
- if (!GameManager.Instance.allobjs.ContainsKey(spoitjd.id.ToString()))
- {
- GameManager.Instance.allobjs.Add(spoitjd.id.ToString(), new Dictionary<string, Dictionary<string, GameObject>>());
- }
- if (!GameManager.Instance.allobjs[spoitjd.id.ToString()].ContainsKey(material.id.ToString()))
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()].Add(material.id.ToString(), new Dictionary<string, GameObject>());
- }
- if (!GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].ContainsKey(mat.id.ToString()))
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()].Add(mat.id.ToString(), go);
- }
- else
- {
- GameManager.Instance.allobjs[spoitjd.id.ToString()][material.id.ToString()][mat.id.ToString()] = go;
- }
- go.name = string.IsNullOrWhiteSpace(mat.name) ? spoit.name + "-" + i.ToString() : mat.name;
- go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
- if (material.select)
- {
- go.transform.localPosition = mat.ObjectTransform.nowPos;
- go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
- go.transform.localScale = mat.ObjectTransform.nowScale;
- }
- else
- {
- go.transform.localEulerAngles = Vector3.zero;
- go.transform.localScale = new Vector3(1, 1, 1);
- if (mat.type != (int)MaterialType.Text)
- {
- go.transform.localPosition = Vector3.zero;
- }
- else
- {
-
- if (mat.textPosition == "top")
- {
- go.transform.localPosition = new Vector3(0, 0.3f, 0);
- }
- else if (mat.textPosition == "bottom")
- {
- go.transform.localPosition = new Vector3(0, -0.3f, 0);
- }
- else if (mat.textPosition == "left")
- {
- go.transform.localPosition = new Vector3(-0.3f, 0, 0);
- }
- else if (mat.textPosition == "right")
- {
- go.transform.localPosition = new Vector3(0.3f, 0f, 0);
- }
- }
- mat.ObjectTransform.SetStartValue(go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
- }
- ObjectValue objectValue = CreateMatObjectValue(i, material.id, go, mat);
- objects.Add(objectValue);
- }
- newmaterial.materialList[i] = mat;
- }
- return objects;
- }
-
-
-
- private List<ObjectValue> CreateImage_Video_Text(SpoitValue spoitjd,MaterialObl material, GameObject spoit, out MaterialObl newmaterial)
- {
- Debug.LogError("HJJmaterialObls.select DRFanLayout.CreateImage_Video_Text ");
- newmaterial = material;
- List<ObjectValue> objects = new List<ObjectValue>();
- SRTitleLayout.CalLayout(spoitjd,material, spoit, out newmaterial);
- Debug.LogError("HJJmaterialObls.select DRFanLayout.CalLayout default ");
- return objects;
- }
-
-
-
-
-
-
-
-
- private ObjectValue CreateMatObjectValue(int id, int parentid, GameObject go, MaterialObjValue mat)
- {
- go.name = string.IsNullOrWhiteSpace(mat.name) ? go.name : mat.name;
- go.AddComponent<EditorEventHandler>().Type = (MaterialType)(mat.type);
-
- if (mat.ObjectTransform != null)
- {
- go.transform.localPosition = mat.ObjectTransform.nowPos;
- go.transform.localEulerAngles = mat.ObjectTransform.nowRot;
- go.transform.localScale = mat.ObjectTransform.nowScale;
- }
- else
- {
- go.transform.localPosition = Vector3.zero;
- go.transform.localEulerAngles = Vector3.zero;
- go.transform.localScale = new Vector3(1, 1, 1);
- }
- ObjectValue objectValue = new ObjectValue(id, parentid, mat.name, go, go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
- return objectValue;
- }
- #endregion
- #region 路径
-
-
-
-
- public void SetRouteValue(List<NavLinesItem> navLines)
- {
- if (navLines == null || navLines.Count <= 0)
- {
- Debug.Log("当前景点未绘制路线");
- return;
- }
- RouteCtr.SetRouteValue(navLines);
- }
- #endregion
- #region 锚点
-
-
-
-
- public void SetAnchor(List<Anchor> listAnchor)
- {
- if (listAnchor == null)
- return;
- Anchor anchor;
- for (int i = 0; i < listAnchor.Count - 1; i++)
- {
- for (int j = 0; j < listAnchor.Count - 1 - i; j++)
- {
- if (listAnchor[j].id > listAnchor[j + 1].id)
- {
- anchor = listAnchor[j];
- listAnchor[j] = listAnchor[j + 1];
- listAnchor[j + 1] = anchor;
- }
- }
- }
-
- for (int i = 0; i < listAnchor.Count; i++)
- {
-
-
- GameManager.Instance.AnchorValue.Add(listAnchor[i], CreateAnchor(listAnchor[i]));
- GameManager.Instance.AnchorChild.Add(listAnchor[i], AnchorValue[listAnchor[i]].transform.GetChild(0).gameObject);
- }
- m_UIAnchorsPanel.SetAnchor(AnchorValue);
- }
- private MeshRenderer CreateAnchor(Anchor anchor)
- {
-
- GameObject anchorObj = GameObject.Instantiate(Resources.Load<GameObject>("Template/Prefab/Anchor"),AnchorsParent);
- anchorObj.name = "Anchor" + anchor.id;
-
- var anchorPos = Vector3.zero;
- Debug.Log(anchor.picturePosition.pointRelativeX+" "+ WebMapSize.x);
- anchorPos = new Vector3((float)anchor.picturePosition.pointRelativeX / WebMapSize.x * MapSize.x, -1f, -(float)anchor.picturePosition.pointRelativeY / WebMapSize.y * MapSize.y);
- anchorObj.transform.localPosition = anchorPos;
- anchorObj.transform.GetChild(0).gameObject.SetActive(false);
- var mesh = anchorObj.GetComponent<MeshRenderer>();
- mesh.enabled = false;
-
-
-
-
-
- if(anchor.objectTransform!=null && anchor.objectTransform.nowScale!=Vector3.zero)
- {
- anchorObj.transform.localEulerAngles = anchor.objectTransform.nowRot;
- anchorObj.transform.localPosition = anchor.objectTransform.nowPos;
- }
- return mesh;
- }
- #endregion
- #region 触发器判定
-
-
-
- public void OnColliderTriggerEnter(Collider other)
- {
- IsTriggerExiting = true;
- for (int i = 0; i < ListColliderBoxs.Count; i++)
- {
- if (other.name == ListColliderBoxs[i].name)
- {
- ListShowObjs[i].gameObject.SetActive(true);
-
- MQTTClient.Instance.sendActiveSp(ListShowObjs[i].name, true);
- Debug.Log(i);
- if (isShowLoacalShowObjs)
- ListLocalShowObjs[i].gameObject.SetActive(true);
-
- for (int j = 0; j < SceneValue.listSpoit.Count; j++)
- {
- if(SceneValue.listSpoit[i].name == other.name)
- {
- HttpSocket.Instance.SendIpToPointTrigger(" ", SceneValue.listSpoit[i].id, CallBack);
- }
- }
- if (SpoitIndex == i)
- {
- return;
- }
-
- if (SpoitIndex >= 0 && IsStartEditor)
- {
- ListShowObjs[SpoitIndex].gameObject.SetActive(false);
- MQTTClient.Instance.sendActiveSp(ListShowObjs[SpoitIndex].name, false);
- if (isShowLoacalShowObjs)
- ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
- ListCrystals[SpoitIndex].gameObject.SetActive(true);
- m_EditorPanel.ClosePanel();
- }
-
- SpoitIndex = i;
- ListCrystals[SpoitIndex].gameObject.SetActive(false);
- m_EditorPanel.SetSpoit(SpoitValues[i]);
- return;
- }
- }
- }
- public void SetPosRotScale()
- {
- refOldData();
- }
-
-
-
- public void OnColliderTriggerExit(Collider other)
- {
- IsTriggerExiting = false;
- if (IsStartEditor)
- {
- return;
- }
- else
- {
- ListShowObjs[SpoitIndex].gameObject.SetActive(false);
- MQTTClient.Instance.sendActiveSp(ListShowObjs[SpoitIndex].name, false);
- if (isShowLoacalShowObjs)
- ListLocalShowObjs[SpoitIndex].gameObject.SetActive(false);
- ListCrystals[SpoitIndex].gameObject.SetActive(true);
- m_EditorPanel.ClosePanel();
- SpoitIndex = -1;
- }
- }
-
-
-
- public void UpdateSpoitValue()
- {
- var spoit = SpoitValues[SpoitIndex];
- var objvalues = ObjectValues[spoit.id];
- spoit.spoitTf.SavePos(objvalues.nowPos, objvalues.nowRot, objvalues.nowScale);
-
- var collidervalue = ColliderObjectValues[SpoitIndex];
- var collider = collidervalue.Object;
- var pos = collidervalue.nowPos;
- var w = collidervalue.nowScale.x;
- var h = collidervalue.nowScale.z;
- var webpos = new Vector3(Math.Abs(pos.x) / MapSize.x * WebMapSize.x, 0, Math.Abs(pos.z) / MapSize.y * WebMapSize.y);
- var webw = w / MapSize.x * WebMapSize.x;
- var webh = h / MapSize.y * WebMapSize.y;
- spoit.SpoitTransform[0].areaRelativeX = webpos.x;
- spoit.SpoitTransform[0].areaRelativeY = webpos.z;
- spoit.SpoitTransform[0].areaRelativeW = webw;
- spoit.SpoitTransform[0].areaRelativeH = webh;
- spoit.spoitTf.SavePos(objvalues.nowPos, objvalues.nowRot, objvalues.nowScale);
- if (objvalues.Object == null)
- {
- RemoveSpoitObjectValue(spoit.id);
- spoit.material = new List<MaterialObl>();
- }
- else
- {
- var mats = spoit.material;
- var objvalue = objvalues.ChildrenObj;
- for (int j = 0; j < mats.Count; j++)
- {
- var matobj = mats[j];
- var obis = objvalue[j];
- matobj.objectTransform.SavePos(obis.nowPos, obis.nowRot, obis.nowScale);
- for (int m = 0; m < matobj.materialList.Count; m++)
- {
- var childrenobj = obis.ChildrenObj[m];
- var mat = matobj.materialList[m];
- if (childrenobj.Object == null)
- {
- obis.ChildrenObj.RemoveAt(m);
- matobj.materialList.RemoveAt(m);
- break;
- }
- mat.ObjectTransform.SavePos(childrenobj.nowPos, childrenobj.nowRot, childrenobj.nowScale);
- }
- matobj.select = true;
- if (obis.ChildrenObj.Count <= 0)
- {
- mats.RemoveAt(j);
- objvalue.RemoveAt(j);
- Destroy(obis.Object);
- break;
- }
- }
- }
- SpoitValues[SpoitIndex] = spoit;
- }
- public void UpdateEditorUI()
- {
- m_EditorPanel.SetSpoit(SpoitValues[SpoitIndex]);
- }
-
- #endregion
- public ObjectValue GetCurrentColliderValue()
- {
- return ColliderObjectValues[SpoitIndex];
- }
- public void SaveSpoitObjectValue(ObjectValue value)
- {
- if (ObjectValues.ContainsKey(SpoitValues[SpoitIndex].id))
- {
- ObjectValues[SpoitValues[SpoitIndex].id] = value;
- }
- }
- public void RemoveSpoitObjectValue(int id)
- {
- if (ObjectValues.ContainsKey(id))
- {
- ObjectValues.Remove(id);
- }
- }
- public void SaveCurrentColliderValue(ObjectValue value)
- {
- if (ColliderObjectValues.Contains(value))
- {
- ColliderObjectValues[SpoitIndex] = value;
- }
- }
-
- public void CalMapSize()
- {
-
-
-
- var disX = Vector3.Distance(PointA.localPosition, PointD.localPosition);
- var disZ = Vector3.Distance(PointA.localPosition, PointB.localPosition);
- MapSize = new Vector2(disX, disZ);
-
-
-
-
- }
- public void CallBack(string message)
- {
- }
- }
- [Serializable]
- public class ObjectValue
- {
-
-
-
- [SerializeField]
- public int ID;
-
-
-
- [SerializeField]
- public string matName;
-
-
-
-
- [SerializeField]
- public int parentID;
-
-
-
- [SerializeField]
- public GameObject Object;
-
-
-
- [SerializeField]
- public List<ObjectValue> ChildrenObj;
- public Vector3 startPos { get; set; }
- public Vector3 startRot { get; set; }
- public Vector3 startScale { get; set; }
- public Vector3 nowPos { get; set; }
- public Vector3 nowRot { get; set; }
- public Vector3 nowScale { get; set; }
- public ObjectValue()
- {
- ChildrenObj = new List<ObjectValue>();
- parentID = -1;
- }
-
-
-
-
-
-
-
-
-
-
- public ObjectValue(int id, int parentid, string name, GameObject @object, Vector3 pos, Vector3 Rot, Vector3 Scale)
- {
- ID = id;
- parentID = parentid;
- matName = name;
- Object = @object;
- ChildrenObj = new List<ObjectValue>();
- startPos = pos;
- nowPos = pos;
- startRot = Rot;
- nowRot = Rot;
- startScale = Scale;
- nowScale = Scale;
- }
- public ObjectValue(int id, int parentid, string name, GameObject @object)
- {
- ID = id;
- parentID = parentid;
- matName = name;
- Object = @object;
- ChildrenObj = new List<ObjectValue>();
- startPos = @object.transform.localPosition;
- nowPos = startPos;
- startRot = @object.transform.localEulerAngles;
- nowRot = startRot;
- startScale = @object.transform.localScale;
- nowScale = startScale;
- }
-
-
-
-
- public void InitTransform()
- {
- if (Object != null)
- {
- startPos = Object.transform.localPosition;
- nowPos = Object.transform.localPosition;
- startRot = Object.transform.localEulerAngles;
- nowRot = Object.transform.localEulerAngles;
- startScale = Object.transform.localScale;
- nowScale = Object.transform.localScale;
- }
- }
-
-
-
- public void InitObjTransform()
- {
- Object.transform.localPosition = startPos;
- Object.transform.localEulerAngles = startRot;
- Object.transform.localScale = startScale;
- nowPos = startPos;
- nowRot = startRot;
- nowScale = startScale;
- }
-
-
-
- public void SaveObjTransfoem()
- {
- if (Object != null)
- {
- nowPos = Object.transform.localPosition;
- nowRot = Object.transform.localEulerAngles;
- nowScale = Object.transform.localScale;
- }
- }
- }
|