复制粘贴删除
This commit is contained in:
51
Assets/Scripts/DynamicUI/Hierarchy/DoubleCheckButton.cs
Normal file
51
Assets/Scripts/DynamicUI/Hierarchy/DoubleCheckButton.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class DoubleCheckButton : MonoBehaviour, IPointerExitHandler
|
||||
{
|
||||
private Button button;
|
||||
private bool isConfirmState = false;
|
||||
public UnityAction onConfirm;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
button.onClick.AddListener(OnButtonClick);
|
||||
}
|
||||
|
||||
private void OnButtonClick()
|
||||
{
|
||||
if (!isConfirmState)
|
||||
{
|
||||
// 第一次点击,进入确认状态(变红)
|
||||
isConfirmState = true;
|
||||
button.image.color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 第二次点击,执行命令
|
||||
ExecuteCommand();
|
||||
ResetButtonState();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
// 鼠标移出时,重置按钮状态
|
||||
ResetButtonState();
|
||||
}
|
||||
|
||||
private void ExecuteCommand()
|
||||
{
|
||||
onConfirm?.Invoke();
|
||||
}
|
||||
|
||||
private void ResetButtonState()
|
||||
{
|
||||
isConfirmState = false;
|
||||
button.image.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/DynamicUI/Hierarchy/DoubleCheckButton.cs.meta
Normal file
11
Assets/Scripts/DynamicUI/Hierarchy/DoubleCheckButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6089dfd1807d473f80c6597f9b063dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Michsky.MUIP;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
@@ -18,13 +20,13 @@ namespace Ichni.Editor
|
||||
public int tabLayer;
|
||||
public bool isSelected;
|
||||
public bool isExpanded;
|
||||
|
||||
|
||||
public RectTransform tabRect;
|
||||
public LayoutElement layoutElement;
|
||||
public RectTransform tabMainRect;
|
||||
public Button tabButton;
|
||||
public Button expandButton;
|
||||
public Button gotoButton;
|
||||
public DoubleCheckButton deleteButton;
|
||||
public TMP_Text tabButtonText;
|
||||
|
||||
public void SetTab(GameElement targetElement, GameElement parentElement)
|
||||
@@ -57,16 +59,21 @@ namespace Ichni.Editor
|
||||
|
||||
for (int i = 1; i <= this.tabLayer; i++)
|
||||
{
|
||||
float lineX = 30 * i - 10;
|
||||
float lineX = 30 * i - 15;
|
||||
Instantiate(indentationLinePrefab, tabRect).GetComponent<RectTransform>().anchoredPosition = new Vector2(lineX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float posX = -25 +( 30 * tabLayer);
|
||||
float posX = (30 * tabLayer);
|
||||
tabMainRect.anchoredPosition = new Vector2(posX, tabMainRect.anchoredPosition.y);
|
||||
tabButton.onClick.AddListener(SelectGameElement);
|
||||
expandButton.onClick.AddListener(ExpandOrFold);
|
||||
deleteButton.onConfirm = () =>
|
||||
{
|
||||
connectedGameElement.parentElement.childElementList.Remove(connectedGameElement);
|
||||
connectedGameElement.Delete();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +93,7 @@ namespace Ichni.Editor
|
||||
|
||||
private void SelectGameElement()
|
||||
{
|
||||
EditorManager.instance.operationManager.SelectElement(connectedGameElement);
|
||||
EditorManager.instance.uiManager.inspector.SetInspector(connectedGameElement);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user