12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- namespace TriLib.Samples
- {
- public class URIDialog : MonoBehaviour
- {
- public static URIDialog Instance { get; private set; }
- public string Filename
- {
- get
- {
- return this._uriText.text;
- }
- set
- {
- this._uriText.text = value;
- }
- }
- public string Extension
- {
- get
- {
- return this._extensionText.text;
- }
- set
- {
- this._extensionText.text = value;
- }
- }
- protected void Awake()
- {
- this._cancelButton.onClick.AddListener(new UnityAction(this.HideDialog));
- this._uriText.onValueChanged.AddListener(new UnityAction<string>(this.UpdateExtension));
- URIDialog.Instance = this;
- }
- public void ShowDialog(Action<string, string> onOk)
- {
- this._okButton.onClick.RemoveAllListeners();
- this._okButton.onClick.AddListener(delegate()
- {
- if (onOk != null)
- {
- onOk(this.Filename, this.Extension);
- }
- this.HideDialog();
- });
- this._rendererGameObject.SetActive(true);
- }
- public void HideDialog()
- {
- this._rendererGameObject.SetActive(false);
- }
- private void UpdateExtension(string text)
- {
- this._extensionText.text = FileUtils.GetFileExtension(text);
- }
- [SerializeField]
- private Button _okButton;
- [SerializeField]
- private Button _cancelButton;
- [SerializeField]
- private InputField _uriText;
- [SerializeField]
- private InputField _extensionText;
- [SerializeField]
- private GameObject _rendererGameObject;
- }
- }
|