73 lines
1.8 KiB
C#
73 lines
1.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using TMPro;
|
|
using TriLibCore.SFB;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using XRLib.UI;
|
|
|
|
namespace Studio.UI
|
|
{
|
|
public class Panel_TopMenuOpenProjectInfo : PanelBase
|
|
{
|
|
public TMP_InputField InputField_ProjectName;
|
|
public TMP_InputField InputField_ProjectRoute;
|
|
public Button Button_FileExplorer;
|
|
public Button Button_Open;
|
|
public Button Button_Cancel;
|
|
public Button Button_Close;
|
|
|
|
public Action onClickOpen;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
Button_FileExplorer.onClick.AddListener(OnClickFileExplorer);
|
|
Button_Open.onClick.AddListener(OnClickOpen);
|
|
Button_Cancel.onClick.AddListener(Close);
|
|
Button_Close.onClick.AddListener(Close);
|
|
}
|
|
private void OnClickFileExplorer()
|
|
{
|
|
var paths = StandaloneFileBrowser.OpenFilePanel("Select Project", "", "ocs", false);
|
|
|
|
if (paths.Count > 0 && !string.IsNullOrEmpty(paths[0].Name))
|
|
{
|
|
InputField_ProjectRoute.text = paths[0].Name;
|
|
}
|
|
}
|
|
|
|
private void OnClickOpen()
|
|
{
|
|
var projectPath = GetProjectRoute();
|
|
|
|
if (!IsPathVaild(projectPath))
|
|
return;
|
|
|
|
onClickOpen?.Invoke();
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
SetActive(true);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
SetActive(false);
|
|
}
|
|
public string GetProjectRoute()
|
|
{
|
|
var route = InputField_ProjectRoute.text;
|
|
return route;
|
|
}
|
|
private bool IsPathVaild(string path)
|
|
{
|
|
if (path == string.Empty || !File.Exists(path))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|