复制粘贴删除
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -12,8 +12,9 @@ GameObject:
|
||||
- component: {fileID: 6763562507922544190}
|
||||
- component: {fileID: 8976681661139621974}
|
||||
- component: {fileID: 4366070571324766663}
|
||||
- component: {fileID: 6485919050370088522}
|
||||
m_Layer: 5
|
||||
m_Name: GoToElementButton
|
||||
m_Name: DeleteButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -36,7 +37,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 165.00002, y: 0}
|
||||
m_AnchoredPosition: {x: 140, y: 0}
|
||||
m_SizeDelta: {x: 30, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6763562507922544190
|
||||
@@ -121,6 +122,18 @@ MonoBehaviour:
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &6485919050370088522
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1975073476707558943}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e6089dfd1807d473f80c6597f9b063dc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &2037738709231332070
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -156,8 +169,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -25, y: 0}
|
||||
m_SizeDelta: {x: 360, y: 30}
|
||||
m_AnchoredPosition: {x: 3, y: 0}
|
||||
m_SizeDelta: {x: 310, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &3176678068745517715
|
||||
GameObject:
|
||||
@@ -404,8 +417,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -0.000024795532, y: 0}
|
||||
m_SizeDelta: {x: 300, y: 30}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 250, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8557913501037026989
|
||||
CanvasRenderer:
|
||||
@@ -554,7 +567,7 @@ MonoBehaviour:
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: '>'
|
||||
m_text: X
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
@@ -794,7 +807,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 30}
|
||||
m_SizeDelta: {x: 310, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &7456916159291301029
|
||||
MonoBehaviour:
|
||||
@@ -821,7 +834,7 @@ MonoBehaviour:
|
||||
tabMainRect: {fileID: 4977671911614392296}
|
||||
tabButton: {fileID: 2984872097914611565}
|
||||
expandButton: {fileID: 2749324553351544168}
|
||||
gotoButton: {fileID: 4366070571324766663}
|
||||
deleteButton: {fileID: 6485919050370088522}
|
||||
tabButtonText: {fileID: 2880005684537739809}
|
||||
--- !u!114 &-1606289094185495319
|
||||
MonoBehaviour:
|
||||
@@ -879,7 +892,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -165.00003, y: 0}
|
||||
m_AnchoredPosition: {x: -140.00003, y: 0}
|
||||
m_SizeDelta: {x: 30, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &1982148510309425424
|
||||
|
||||
File diff suppressed because one or more lines are too long
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