public void OnPointerClick(PointerEventData eventData) { #if UNITY_EDITOR Debug.Log(builder.GetCurrentJSON()); #endif if (window) { window.ToggleActive(); field.text = builder.GetCurrentJSON(); } }
public void OnPointerClick(PointerEventData eventData) { if (window) { window.ToggleActive(); field.text = builder.GetCurrentJSON(); } }
void Show(IOMode mode) { buttons.Clear(); active = true; gameObject.SetActive(true); window.SetActive(true); newWorldStack.SetActive(mode == IOMode.Write || mode == IOMode.WriteShipJSON || mode == IOMode.WriteWaveJSON); DestroyAllButtons(); this.mode = mode; string[] directories = null; readButton.gameObject.SetActive(mode == IOMode.Read || mode == IOMode.Write); switch (mode) { case IOMode.Read: readButton.text = "Read world"; worldPathName.text = "If you select a world, its name will appear here."; authors.text = ""; description.text = ""; defaultBlueprint.text = ""; authors.placeholder.GetComponent <Text>().text = "World authors appear here"; description.placeholder.GetComponent <Text>().text = "World description appears here"; defaultBlueprint.placeholder.GetComponent <Text>().text = "Default blueprint appears here"; directories = Directory.GetDirectories(Application.streamingAssetsPath + "\\Sectors"); break; case IOMode.Write: readButton.text = "Write world"; worldPathName.text = "If you select a world, its name will appear here."; authors.text = ""; description.text = ""; defaultBlueprint.text = ""; authors.placeholder.GetComponent <Text>().text = "Enter world authors here"; description.placeholder.GetComponent <Text>().text = "Enter world description here"; defaultBlueprint.placeholder.GetComponent <Text>().text = "Enter default blueprint here"; directories = Directory.GetDirectories(Application.streamingAssetsPath + "\\Sectors"); break; case IOMode.ReadShipJSON: case IOMode.WriteShipJSON: directories = Directory.GetFiles(Application.streamingAssetsPath + "\\EntityPlaceholder"); break; case IOMode.ReadWaveJSON: case IOMode.WriteWaveJSON: directories = Directory.GetFiles(Application.streamingAssetsPath + "\\WavePlaceholder"); break; } foreach (var dir in directories) { if (!dir.Contains("TestWorld") && !dir.Contains("meta")) { AddButton(dir, new UnityEngine.Events.UnityAction(() => { switch (mode) { case IOMode.Read: case IOMode.Write: SetWorldIndicators(dir); break; case IOMode.ReadShipJSON: builder.LoadBlueprint(System.IO.File.ReadAllText(dir)); Hide(); break; case IOMode.WriteShipJSON: ShipBuilder.SaveBlueprint(null, dir, builder.GetCurrentJSON()); Hide(); break; case IOMode.ReadWaveJSON: waveBuilder.ReadWaves(JsonUtility.FromJson <WaveSet>(System.IO.File.ReadAllText(dir))); Hide(); break; case IOMode.WriteWaveJSON: waveBuilder.ParseWaves(dir); Hide(); break; } })); } } }