123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Localization;
- using UnityEngine.Localization.Settings;
- using UnityEngine.Localization.Tables;
- using UnityEngine.UI;
- public class TabListManager : MonoBehaviour
- {
- public GameObject Texiao;
- public List<GameObject> Tablist;
- public InfoWindow infoWindow;
- public static TabListManager Instance;
- public GameObject Fgo;
- public GameObject Sgo;
- public GameObject Tgo;
- public DeMaConfig dc;
-
- public List<GameObject> golist;
- public Animator animator;
- public void Awake()
- {
- Instance=this;
- Fgo.SetActive(false);
- Sgo.SetActive(false);
- Tgo.SetActive(false);
-
-
- SetLanguage("en");
- }
- StringTable stringTable ;
-
- public string GetTextByKey(string key)
- {
- if(stringTable==null)
- stringTable= LocalizationSettings.StringDatabase.GetTable("DeMa");
-
- var tableEntry = stringTable.GetEntry(key);
- if (tableEntry != null)
- {
-
- return tableEntry.GetLocalizedString();
- }
- else
- {
- return key;
- }
- }
- public void SetLanguage(string languageCode)
- {
-
- foreach (var locale in LocalizationSettings.AvailableLocales.Locales)
- {
- if (locale.Identifier.Code == languageCode)
- {
- LocalizationSettings.SelectedLocale = locale;
- Debug.Log("Language set to: " + languageCode);
- return;
- }
- }
- Debug.LogError("Language not found: " + languageCode);
- }
- public void Start()
- {
- TableReference tableReference = "DeMa";
- for (int i = 0;i<dc.TaskList.Count;i++)
- {
- GameObject fgo = GameObject.Instantiate(Fgo,Fgo.transform.parent);
- fgo.name = GetTextByKey( dc.TaskList[i].key);
- fgo.SetActive(true);
- FItemGo fg= new FItemGo();
- fg.info = dc.TaskList[i].info;
- fg.url = dc.TaskList[i].imgandmp4;
- fg.showList=new List<GameObject>();
-
- LocalizedText tt= fgo.GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedText>();
- tt.localizedString= new LocalizedString();
- tt.localizedString.TableReference = tableReference;
- tt.changeKey(dc.TaskList[i].key);
- for (int p=0;p<dc.TaskList[i].goidx.Count;p++)
- {
- fg.showList.Add(golist[dc.TaskList[i].goidx[p]]);
- }
-
- fg.Idx = i;
- fg.go = fgo;
- fg.init();
- fgoList.Add(fg);
- for (int j = 0;j<dc.TaskList[i].slist.Count;j++)
- {
- GameObject sgo = GameObject.Instantiate(Sgo,Sgo.transform.parent);
- sgo.name =GetTextByKey( dc.TaskList[i].slist[j].key);;
- sgo.SetActive(false);
- SItemGo sg= new SItemGo();
- sg.tab =Tablist[ dc.TaskList[i].slist[j].tabidx];
- sg.info = dc.TaskList[i].slist[j].info;
- sg.url = dc.TaskList[i].slist[j].imgandmp4;
- if(sg.tab)
- {
- Debug.Log(" sg.tab===>"+ sg.tab.name);
-
- LocalizedText ttt= sg.tab.GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedText>();
- ttt.localizedString= new LocalizedString();
- ttt.localizedString.TableReference = tableReference;
- ttt.changeKey(dc.TaskList[i].slist[j].key);
- }
- sg.showList=new List<GameObject>();
- for (int p=0;p<dc.TaskList[i].slist[j].goidx.Count;p++)
- {
- sg.showList.Add(golist[dc.TaskList[i].slist[j].goidx[p]]);
- }
- sg.Idx = j;
- sg.go = sgo;
- sg.init();
-
- LocalizedText tt2= sgo.GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedText>();
- tt2.localizedString= new LocalizedString();
- tt2.localizedString.TableReference = tableReference;
- tt2.changeKey( dc.TaskList[i].slist[j].key);
- fgoList[i].slist.Add(sg);
- for (int z = 0;z<dc.TaskList[i].slist[j].tlist.Count;z++)
- {
- GameObject tgo = GameObject.Instantiate(Tgo,Tgo.transform.parent);
- tgo.name = GetTextByKey(dc.TaskList[i].slist[j].tlist[z].key);
- tgo.SetActive(false);
- TItemGo tg= new TItemGo();
- tg.application = dc.TaskList[i].slist[j].tlist[z].application;
- tg.title = dc.TaskList[i].slist[j].tlist[z].key;
- tg.Idx = dc.TaskList[i].slist[j].tlist[z].index;
- tg.info = dc.TaskList[i].slist[j].tlist[z].info;
- tg.info2 = dc.TaskList[i].slist[j].tlist[z].info2;
- tg.url = dc.TaskList[i].slist[j].tlist[z].imgandmp4;
- tg.showList=golist[dc.TaskList[i].slist[j].tlist[z].goidx];
- try
- {
- if(tg.showList.GetComponent<ModelXuHua>().TabGo!=null)
- {
- LocalizedText tt4 = tg.showList.GetComponent<ModelXuHua>().TabGo.GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedText>();
- tt4.localizedString= new LocalizedString();
- tt4.localizedString.TableReference = tableReference;
- tt4.changeKey(dc.TaskList[i].slist[j].tlist[z].key);
- }
- }catch
- {
- }
- tg.go = tgo;
- tg.init();
-
-
- LocalizedText tt3= tgo.GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedText>();
- tt3.localizedString= new LocalizedString();
- tt3.localizedString.TableReference = tableReference;
- tt3.changeKey(dc.TaskList[i].slist[j].tlist[z].key);
- fgoList[i].slist[j].tlist.Add(tg);
- }
- }
- }
-
- TabListManager.Instance.infoWindow.gameObject.SetActive(true);
- TabListManager.Instance.infoWindow.init("300001","","",0,"301001","320001");
- }
- bool isstart=true;
- private IEnumerator Dh()
- {
- int idx=0;
- while (isstart)
- {
- yield return new WaitForSeconds(60f);
- if(idx==0)
- golist[1].GetComponent<ModelXuHua>().hide();
- else
- {
- golist[0].GetComponent<ModelXuHua>().hide();
- }
- idx++;
- yield return new WaitForSeconds(2f);
- if(idx>1)
- {
- yield return new WaitForSeconds(30f);
- idx=0;
- golist[0].GetComponent<ModelXuHua>().show();
- yield return new WaitForSeconds(0.5f);
- golist[0].GetComponent<ModelXuHua>().changemode();
- yield return new WaitForSeconds(30f);
- golist[1].GetComponent<ModelXuHua>().show();
- yield return new WaitForSeconds(0.5f);
- golist[1].GetComponent<ModelXuHua>().changemode();
- }
- }
- }
- int nowFindx=-1;
- public void showF(int index,bool isF=true)
- {
- for (int i=0;i<Tablist.Count;i++)
- {
- Tablist[i].SetActive(false);
- }
- TabListManager.Instance.infoWindow.gameObject.SetActive(true);
- TabListManager.Instance.infoWindow.init("300001","","",0,"301001","320001");
- if(nowFindx==index&&isF)
- {
- nowFindx=-1;
- isstart=true;
-
- showAllModel();
- }
- else
- {
- isstart=false;
- StopAllCoroutines();
- nowFindx=index;
- for (int i=0;i<fgoList[nowFindx].slist.Count;i++)
- {
- fgoList[nowFindx].slist[i].go.SetActive(true);
- }
- closeAllModel();
-
- for (int j=0;j< fgoList[nowFindx].showList.Count;j++)
- {
- fgoList[nowFindx].showList[j].GetComponent<ModelXuHua>().showModel();
- }
- }
- }
- public void showT(int index)
- {
- TabListManager.Instance.infoWindow.gameObject.SetActive(false);
- showF(nowFindx,false);
- for (int i=0;i<fgoList[nowFindx].slist[index].tlist.Count;i++)
- {
- fgoList[nowFindx].slist[index].tlist[i].go.SetActive(true);
- }
- for (int i=0;i<Tablist.Count;i++)
- {
- Tablist[i].SetActive(false);
- }
- fgoList[nowFindx].slist[index].tab.SetActive(true);
- }
- public void closeAllModel()
- {
- for (int i=0;i<golist.Count;i++)
- {
- if(golist[i]&&golist[i].GetComponent<ModelXuHua>())
- golist[i].GetComponent<ModelXuHua>().showBaiMo();
- }
- }
- public void showAllModel()
- {
- for (int i=0;i<golist.Count;i++)
- {
- golist[i].GetComponent<ModelXuHua>().showModel(false);
-
- }
- for (int i=0;i<Tablist.Count;i++)
- {
- Tablist[i].SetActive(false);
- }
- Texiao.SetActive(false);
- animator.enabled=true;
- }
- public void showInfo(GameObject go)
- {
-
-
- }
- public GameObject TabGoList;
- public void showTab(GameObject go)
- {
- TabGoList.SetActive(false);
- for (int i=0;i<TabGoList.GetAllChildren().Count;i++)
- {
- TabGoList.transform.GetChild(i).gameObject.SetActive(false);
- }
- if(go.GetComponent<ModelXuHua>().TabGo)
- go.GetComponent<ModelXuHua>().TabGo.SetActive(true);
-
-
- for (int i=0;i<Tablist.Count;i++)
- {
- Tablist[i].SetActive(false);
- }
- }
- public void closeTab()
- {
- TabGoList.SetActive(false);
- }
- public void clossAll()
- {
-
- for (int i = 0;i<fgoList.Count;i++)
- {
- for (int j = 0;j<fgoList[i].slist.Count;j++)
- {
- fgoList[i].slist[j].go.SetActive(false);
- for (int z = 0;z<fgoList[i].slist[j].tlist.Count;z++)
- {
- fgoList[i].slist[j].tlist[z].go.SetActive(false);
- }
- }
- }
- }
- List<FItemGo> fgoList = new List<FItemGo>();
- [System.Serializable]
- public class FItemGo
- {
- public string info;
- public string url;
- public int Idx;
- public GameObject go;
- public List<SItemGo> slist= new List<SItemGo>();
- public List<GameObject> showList =new List<GameObject>();
- public void init()
- {
- go.GetComponent<Button>().onClick.AddListener(()=>{
- TabListManager.Instance.clossAll();
- TabListManager.Instance.showF(Idx);
- Debug.Log("TabListManager.Instance.nowFindx"+TabListManager.Instance.nowFindx);
- if( TabListManager.Instance.nowFindx!=-1)
- {
- TabListManager.Instance.animator.Play("Take 001", 0, 0f);
- TabListManager.Instance.animator.speed =0;
- TabListManager.Instance.showInfo(go);
- TabListManager.Instance.closeAllModel();
-
- for (int j=0;j< showList.Count;j++)
- {
- showList[j].GetComponent<ModelXuHua>().showModel();
- }
- }
- else
- {
- TabListManager.Instance.animator.Play("Take 001", 0, 0f);
- TabListManager.Instance.animator.speed =1;
- }
- TabListManager.Instance.closeTab();
-
- TabListManager.Instance.Texiao.SetActive(false);
- });
- }
- }
- public class SItemGo
- {
- public GameObject tab;
- public string info;
- public string url;
- public int Idx;
- public GameObject go;
- public List<TItemGo> tlist= new List<TItemGo>();
- public List<GameObject> showList =new List<GameObject>();
- public void init()
- {
- go.GetComponent<Button>().onClick.AddListener(()=>{
- TabListManager.Instance.clossAll();
- TabListManager.Instance.showT(Idx);
- TabListManager.Instance.showInfo(go);
- TabListManager.Instance.closeAllModel();
-
- for (int j=0;j< showList.Count;j++)
- {
- showList[j].GetComponent<ModelXuHua>().showModel();
- }
- TabListManager.Instance.closeTab();
- TabListManager.Instance.infoWindow.gameObject.SetActive(false);
- TabListManager.Instance.Texiao.SetActive(false);
- TabListManager.Instance.animator.Play("Take 001", 0, 0f);
- TabListManager.Instance.animator.speed =0;
- });
-
- }
- }
- public class TItemGo
- {
- public string info;
- public string info2;
- public string url;
- public string title;
- public string application;
- public int Idx;
- public GameObject go;
- public GameObject showList =new GameObject();
- public void init()
- {
-
- go.GetComponent<Button>().onClick.AddListener(()=>{
- TabListManager.Instance.showInfo(go);
- TabListManager.Instance.closeAllModel();
- showList.GetComponent<ModelXuHua>().showModel();
- TabListManager.Instance.showTab(showList);
- TabListManager.Instance.infoWindow.gameObject.SetActive(true);
- TabListManager.Instance.infoWindow.init(info,url,info2,Idx,title,application);
- TabListManager.Instance.Texiao.SetActive(true);
- TabListManager.Instance.animator.Play("Take 001", 0, 0f);
- TabListManager.Instance.animator.speed =0;
- });
- }
- }
- }
|