using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class VRTutorialMenu : MonoBehaviour { public void Init(UnityAction callback, string fileName = "vrcom_tutorial.nei") { this.m_ManualDataArray.Clear(); this.m_IndexPage = 0; if (!GameUty.FileSystem.IsExistentFile(fileName)) { NDebug.Assert("表がありません。" + fileName, false); } using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName)) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, fileName + "\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { int num = 0; int cellAsInteger = csvParser.GetCellAsInteger(num++, i); string cellAsString = csvParser.GetCellAsString(num++, i); char[] array = csvParser.GetCellAsString(num++, i).ToCharArray(); bool flag = false; for (int j = 0; j < array.Length; j++) { if (array[j] == ((int)GameMain.Instance.VRDeviceTypeID).ToString().ToCharArray()[0]) { flag = true; } } if (flag) { this.m_ManualDataArray.Add(new VRTutorialMenu.ManualData(cellAsInteger, cellAsString)); } } } } } this.m_ButtonReturn.onClick.RemoveAllListeners(); if (callback != null) { this.m_ButtonReturn.onClick.AddListener(callback); } this.m_ButtonReturn.onClick.AddListener(delegate() { VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); }); this.m_ButtonReturn.interactable = false; this.ButtonEvent_PageChange(false); } public void ButtonEvent_PageChange(bool isNextPage) { this.m_IndexPage += ((!isNextPage) ? -1 : 1); this.m_IndexPage = ((this.m_ManualDataArray.Count > this.m_IndexPage) ? this.m_IndexPage : (this.m_ManualDataArray.Count - 1)); this.m_IndexPage = ((this.m_IndexPage >= 0) ? this.m_IndexPage : 0); VRTutorialMenu.ManualData manualData = this.m_ManualDataArray[this.m_IndexPage]; string path = this.m_uGUIAtlasPath + manualData.ImageName; base.StartCoroutine(this.Coroutine_Load(path, delegate(ResourceRequest req) { this.m_ImageManual.sprite = (req.asset as Sprite); })); this.m_TextPageNumber.text = (this.m_IndexPage + 1).ToString() + " / " + this.m_ManualDataArray.Count.ToString(); this.m_ButtonRight.interactable = (this.m_IndexPage < this.m_ManualDataArray.Count - 1); this.m_ButtonLeft.interactable = (this.m_IndexPage > 0); manualData.IsDisplayed = true; bool flag = true; for (int i = 0; i < this.m_ManualDataArray.Count; i++) { flag &= this.m_ManualDataArray[i].IsDisplayed; } this.m_ButtonReturn.interactable = flag; } private IEnumerator Coroutine_Load(string path, UnityAction callback) where T : UnityEngine.Object { ResourceRequest res = Resources.LoadAsync(path); while (!res.isDone) { yield return null; } callback(res); yield break; } [SerializeField] private Image m_ImageManual; [SerializeField] private Button m_ButtonReturn; [SerializeField] private Button m_ButtonRight; [SerializeField] private Button m_ButtonLeft; [SerializeField] private Text m_TextPageNumber; private List m_ManualDataArray = new List(); private int m_IndexPage; private string m_uGUIAtlasPath = "SceneVRCommunication\\Tablet\\Sprite\\"; private class ManualData { public ManualData(int id, string imageName) { this.ID = id; this.ImageName = imageName; this.IsDisplayed = false; } public int ID; public string ImageName; public bool IsDisplayed; } }