68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using XRLib.UI;
|
|
using XED.Asset;
|
|
using XED.Hierarchy;
|
|
|
|
namespace XED.UI
|
|
{
|
|
public class ScrollViewMenu_ImportExport : PanelBase, IDeselectHandler
|
|
{
|
|
private Canvas canvas;
|
|
private CustomScrollRect scrollRect;
|
|
private Button btnExport;
|
|
private Button btnImport;
|
|
private Selectable selectable;
|
|
private void Awake()
|
|
{
|
|
canvas = GetComponentInParent<Canvas>();
|
|
selectable = GetComponent<Selectable>();
|
|
foreach (Button btn in GetComponentsInChildren<Button>())
|
|
{
|
|
if (btn.gameObject.name.Equals("Export"))
|
|
{
|
|
btnExport = btn;
|
|
}
|
|
else if (btn.gameObject.name.Equals("Import"))
|
|
{
|
|
btnImport = btn;
|
|
}
|
|
}
|
|
}
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
public override void AfterAwake()
|
|
{
|
|
var customAssetConnector = FindSingle<CustomAssetConnector>();
|
|
btnExport.onClick.AddListener(customAssetConnector.SaveSelectedAssetDatasToLocal);
|
|
btnImport.onClick.AddListener(customAssetConnector.LoadLocalAssetDatas);
|
|
scrollRect = FindSingle<Canvas_Windows>().panel_assetlibrary.scrollRect;
|
|
scrollRect.menuPopup = gameObject;
|
|
SetActive(false);
|
|
}
|
|
protected override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
selectable.Select();
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
|
canvas.transform as RectTransform,
|
|
Input.mousePosition,
|
|
canvas.worldCamera,
|
|
out Vector2 pos
|
|
);
|
|
transform.position = canvas.transform.TransformPoint(pos);
|
|
}
|
|
public void OnDeselect(BaseEventData eventData)
|
|
{
|
|
StartCoroutine(CoroutineDelayedClose());
|
|
}
|
|
IEnumerator CoroutineDelayedClose()
|
|
{
|
|
yield return new WaitForSeconds(0.1f);
|
|
gameObject.SetActive(false);
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|