submodule bug fix & Clip extend
移除submodule重复引用的问题, Clip现在可以保存任意GameElement,且任意指定物体作为父物体加载
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GeneralSecondaryWIndow : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
65
Assets/Scripts/DynamicUI/MainUI/GeneralSecondaryWindow.cs
Normal file
65
Assets/Scripts/DynamicUI/MainUI/GeneralSecondaryWindow.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class GeneralSecondaryWindow : MovableWindow
|
||||
{
|
||||
public RectTransform WindowRect { get; set; }
|
||||
public List<DynamicUIContainer> Containers { get; set; }
|
||||
|
||||
public void Initialize(string titleText, UnityAction closeAction = null)
|
||||
{
|
||||
WindowRect = windowRect;
|
||||
Containers = new List<DynamicUIContainer>();
|
||||
|
||||
InitializeWindow(titleText, closeAction);
|
||||
}
|
||||
|
||||
public DynamicUIContainer GenerateContainer(string title)
|
||||
{
|
||||
DynamicUIContainer container =
|
||||
Instantiate(EditorManager.instance.basePrefabs.dynamicUIContainer, WindowRect)
|
||||
.GetComponent<DynamicUIContainer>();
|
||||
container.title.text = title;
|
||||
Containers.Add(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
public DynamicUIContainer GenerateContainer()
|
||||
{
|
||||
DynamicUIContainer container =
|
||||
Instantiate(EditorManager.instance.basePrefabs.dynamicUIContainer, WindowRect)
|
||||
.GetComponent<DynamicUIContainer>();
|
||||
Destroy(container.title.gameObject);
|
||||
Containers.Add(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
public DynamicUIInputField GenerateInputField(DynamicUIContainer container,
|
||||
string title, string defaultText = "") //不与参数绑定的InputField
|
||||
{
|
||||
DynamicUIInputField inputField = Instantiate(EditorManager.instance.basePrefabs.inputField, container.rect)
|
||||
.GetComponent<DynamicUIInputField>();
|
||||
inputField.Initialize(null, title, string.Empty);
|
||||
inputField.SetDefaultValue(defaultText);
|
||||
container.dynamicUIElements.Add(inputField);
|
||||
return inputField;
|
||||
}
|
||||
|
||||
public DynamicUIButton GenerateButton(DynamicUIContainer container, string buttonText,
|
||||
UnityAction function, string title = "null")
|
||||
{
|
||||
DynamicUIButton button = Instantiate(EditorManager.instance.basePrefabs.button, container.rect)
|
||||
.GetComponent<DynamicUIButton>();
|
||||
button.SetText(buttonText, title != "null");
|
||||
button.Initialize(null, title, string.Empty);
|
||||
button.ApplyFunction(function);
|
||||
container.dynamicUIElements.Add(button);
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class ClipManagementWindow : MovableWindow
|
||||
{
|
||||
public TMP_InputField clipNameInputField;
|
||||
public Button applyClipButton;
|
||||
|
||||
public void InitializeAsSaveClip()
|
||||
{
|
||||
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElement;
|
||||
|
||||
if (currentElement == null)
|
||||
{
|
||||
LogWindow.Log("No Game Element selected.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!OpenWindow())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeWindow("Save Clip: " + currentElement.elementName);
|
||||
|
||||
clipNameInputField.text = currentElement.elementName;
|
||||
applyClipButton.onClick.RemoveAllListeners();
|
||||
applyClipButton.onClick.AddListener(() =>
|
||||
{
|
||||
EditorManager.instance.projectManager.beatmapClipManager.Save(clipNameInputField.text);
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void InitializeAsLoadClip()
|
||||
{
|
||||
if (!OpenWindow())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeWindow("Load Clip");
|
||||
|
||||
clipNameInputField.text = "";
|
||||
applyClipButton.onClick.RemoveAllListeners();
|
||||
applyClipButton.onClick.AddListener(() =>
|
||||
{
|
||||
EditorManager.instance.projectManager.beatmapClipManager.Load(clipNameInputField.text);
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
private bool OpenWindow()
|
||||
{
|
||||
if (EditorManager.instance.uiManager.mainPage.toolBar.clipManagementWindow.gameObject.activeSelf)
|
||||
{
|
||||
LogWindow.Log("Clip Management Window is already active.");
|
||||
return false;
|
||||
}
|
||||
|
||||
gameObject.SetActive(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98c54627a956d42e8af1eb21c396109a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -18,20 +19,80 @@ namespace Ichni.Editor
|
||||
public Button clipLoadButton;
|
||||
|
||||
[Title("Windows")]
|
||||
public ClipManagementWindow clipManagementWindow;
|
||||
public GeneralSecondaryWindow clipManagementWindow;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
saveButton.onClick.AddListener(EditorManager.instance.projectManager.saveManager.Save);
|
||||
exportButton.onClick.AddListener(EditorManager.instance.projectManager.exportManager.Export);
|
||||
clipSaveButton.onClick.AddListener(clipManagementWindow.InitializeAsSaveClip);
|
||||
clipLoadButton.onClick.AddListener(clipManagementWindow.InitializeAsLoadClip);
|
||||
clipSaveButton.onClick.AddListener(GenerateSaveClipWindow);
|
||||
clipLoadButton.onClick.AddListener(GenerateLoadClipWindow);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ToolBar
|
||||
{
|
||||
|
||||
private void GenerateSaveClipWindow()
|
||||
{
|
||||
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElement;
|
||||
|
||||
if (currentElement == null)
|
||||
{
|
||||
LogWindow.Log("No Game Element selected.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clipManagementWindow != null)
|
||||
{
|
||||
LogWindow.Log("Clip Management Window already exists.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralSecondaryWindow saveClipWindow =
|
||||
Instantiate(EditorManager.instance.basePrefabs.generalSecondaryWindow,
|
||||
EditorManager.instance.uiManager.mainPage.mainCanvas.GetComponent<RectTransform>()).GetComponent<GeneralSecondaryWindow>();
|
||||
clipManagementWindow = saveClipWindow;
|
||||
saveClipWindow.Initialize("Save Clip: " + currentElement.elementName, () => clipManagementWindow = null);
|
||||
|
||||
var container = saveClipWindow.GenerateContainer();
|
||||
var clipNameInputField = saveClipWindow.GenerateInputField(container, "Clip Name", currentElement.elementName);
|
||||
var applyClipButton = saveClipWindow.GenerateButton(container, "Apply", () =>
|
||||
{
|
||||
EditorManager.instance.projectManager.beatmapClipManager.SaveClip(clipNameInputField.GetValue<string>());
|
||||
});
|
||||
}
|
||||
|
||||
private void GenerateLoadClipWindow()
|
||||
{
|
||||
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElement;
|
||||
|
||||
if (currentElement == null)
|
||||
{
|
||||
LogWindow.Log("No Game Element selected.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
GameElement loadTarget = currentElement == EditorManager.instance ? null : currentElement.parentElement;
|
||||
|
||||
if (clipManagementWindow != null)
|
||||
{
|
||||
LogWindow.Log("Clip Management Window already exists.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralSecondaryWindow loadClipWindow =
|
||||
Instantiate(EditorManager.instance.basePrefabs.generalSecondaryWindow,
|
||||
EditorManager.instance.uiManager.mainPage.mainCanvas.GetComponent<RectTransform>()).GetComponent<GeneralSecondaryWindow>();
|
||||
clipManagementWindow = loadClipWindow;
|
||||
loadClipWindow.Initialize("Load Clip", () => clipManagementWindow = null);
|
||||
|
||||
var container = loadClipWindow.GenerateContainer();
|
||||
var clipNameInputField = loadClipWindow.GenerateInputField(container, "Clip Name");
|
||||
var applyClipButton = loadClipWindow.GenerateButton(container, "Apply", () =>
|
||||
{
|
||||
EditorManager.instance.projectManager.beatmapClipManager.LoadClip(clipNameInputField.GetValue<string>());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user