复制粘贴删除
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,6 @@ namespace Ichni.RhythmGame
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
Debug.Log(attachedElementGuid);
|
||||
(attachedElement as IHaveTransformSubmodule).transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
attachedElement.submoduleList.Add((attachedElement as IHaveTransformSubmodule).transformSubmodule);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public virtual void Delete()
|
||||
{
|
||||
if (this.childElementList != null)
|
||||
if (childElementList is { Count: > 0 })
|
||||
{
|
||||
for (int i = 0; i < childElementList.Count; i++)
|
||||
{
|
||||
@@ -133,13 +133,16 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
OnDelete();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Delete " + elementName + "(" + elementGuid + ")");
|
||||
#endif
|
||||
|
||||
LogWindow.Log("Deleted element: " + elementName);
|
||||
|
||||
EditorManager.instance.beatmapContainer.gameElementList.Remove(this); //从保存列表中剔除
|
||||
this.parentElement.childElementList.Remove(this);
|
||||
Destroy(connectedTab.gameObject);
|
||||
|
||||
if (connectedTab != null)
|
||||
{
|
||||
Destroy(connectedTab.gameObject);
|
||||
}
|
||||
|
||||
Destroy(gameObject); //销毁
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Ichni
|
||||
public ProjectManager projectManager;
|
||||
public EditorUIManager uiManager;
|
||||
public EditorSettings editorSettings;
|
||||
public OperationManager operationManager;
|
||||
public BackgroundController backgroundController;
|
||||
public CameraManager cameraManager;
|
||||
|
||||
@@ -32,6 +33,8 @@ namespace Ichni
|
||||
{
|
||||
instance = this;
|
||||
projectManager = new ProjectManager();
|
||||
operationManager = new OperationManager();
|
||||
|
||||
if (!ES3.FileExists(Application.streamingAssetsPath + "/EditorSettings.es3"))
|
||||
{
|
||||
editorSettings = new EditorSettings(300, 100, 100);
|
||||
|
||||
@@ -52,6 +52,14 @@ namespace Ichni.Editor
|
||||
EditorManager.instance.projectManager.exportManager.Export();
|
||||
}
|
||||
|
||||
if (Keyboard.current.cKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.operationManager.copyPasteModule.CopyElement(EditorManager.instance.operationManager.currentSelectedElement);
|
||||
}
|
||||
else if (Keyboard.current.vKey.wasPressedThisFrame)
|
||||
{
|
||||
EditorManager.instance.operationManager.copyPasteModule.PasteElement(EditorManager.instance.operationManager.currentSelectedElement);
|
||||
}
|
||||
|
||||
if (Keyboard.current.digit1Key.wasPressedThisFrame)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
public class OperationManager : MonoBehaviour
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class OperationManager
|
||||
{
|
||||
public GameElement currentSelectedElement { get; private set; }
|
||||
|
||||
public CopyPasteModule copyPasteModule;
|
||||
|
||||
public OperationManager()
|
||||
{
|
||||
copyPasteModule = new CopyPasteModule();
|
||||
}
|
||||
|
||||
public void SelectElement(GameElement gameElement)
|
||||
{
|
||||
currentSelectedElement = gameElement;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public class CopyPasteModule
|
||||
{
|
||||
public GameElement copiedElement;
|
||||
|
||||
public void CopyElement(GameElement gameElement)
|
||||
{
|
||||
LogWindow.Log("Copied element: " + gameElement.elementName);
|
||||
copiedElement = gameElement;
|
||||
}
|
||||
|
||||
public void PasteElement(GameElement parentElement)
|
||||
{
|
||||
if (copiedElement == null)
|
||||
{
|
||||
LogWindow.Log("No element copied.");
|
||||
return;
|
||||
}
|
||||
|
||||
LogWindow.Log("Pasted element: " + copiedElement.elementName + " to " + parentElement.elementName);
|
||||
AffiliatedPaste(copiedElement, parentElement);
|
||||
}
|
||||
|
||||
private GameElement AffiliatedPaste(GameElement gameElement, GameElement parent)
|
||||
{
|
||||
gameElement.SaveBM();
|
||||
GameElement pastedElement = (gameElement.matchedBM as GameElement_BM).DuplicateBM(parent);
|
||||
|
||||
gameElement.submoduleList.ForEach(submodule =>
|
||||
{
|
||||
submodule.SaveBM();
|
||||
(submodule.matchedBM as Submodule_BM).DuplicateBM(pastedElement);
|
||||
});
|
||||
|
||||
if (gameElement.childElementList != null)
|
||||
{
|
||||
for (int i = 0; i < gameElement.childElementList.Count; i++)
|
||||
{
|
||||
AffiliatedPaste(gameElement.childElementList[i], pastedElement);
|
||||
}
|
||||
}
|
||||
|
||||
return pastedElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user