/* *Copyright(C) 2023 by Cocklebur All rights reserved. *Unity版本:2022.2.1f1c1 *作者:Chief *创建日期: 2023-01-12 *模块说明:模板信息 *版本: 1.0 */ using Sirenix.OdinInspector; using TMPro; using UnityEngine; using UnityEngine.UI; namespace UpmGitTool.UI { /// /// 手动拉取控件 /// public class UICtrl_ManualFetch : MonoBehaviour { [LabelText("打开按钮")] public Button BtnOpen; [LabelText("关闭按钮")] public Button BtnClose; [LabelText("拉取按钮")] public Button BtnFetch; [LabelText("Git拉取地址输入框")] public TMP_InputField GitPathInputFiled; private void Start() { BtnOpen.onClick.AddListener(Open); BtnClose.onClick.AddListener(Close); BtnFetch.onClick.AddListener(Fetch); GitPathInputFiled.onEndEdit.AddListener(CheckGitPath); Close(); } private void Open() { SetActive(true); CheckGitPath(GitPathInputFiled.text); } private void Close() { SetActive(false); GitPathInputFiled.text = string.Empty; } private void SetActive(bool active) { BtnOpen.gameObject.SetActive(!active); BtnClose.gameObject.SetActive(active); BtnFetch.gameObject.SetActive(active); GitPathInputFiled.gameObject.SetActive(active); } private void CheckGitPath(string path) { bool pathError = IsGitPathError(path); BtnFetch.interactable = !pathError; } private bool IsGitPathError(string path) { if (string.IsNullOrEmpty(path)) return true; if (string.IsNullOrWhiteSpace(path)) return true; if (!path.Contains("git")) return false; return false; } private void Fetch() { string path = GitPathInputFiled.text; if (IsGitPathError(path)) return; //从Git上拉取所有包; CoreFunction.StartFetchGitUrl(path); Close(); } } }