Note inspector调整,Static Window可开关,Log可复制清空

This commit is contained in:
SoulliesOfficial
2025-02-24 15:20:54 -05:00
parent 935cbbb029
commit 1b4637ae95
39 changed files with 2556 additions and 121 deletions

Binary file not shown.

View File

@@ -21,12 +21,12 @@ namespace Ichni.Editor
dropdown.onValueChanged.AddListener((value) => ApplyParameters(dropdown.options[value].text) );
}
public void SetUpStringList(List<string> stringList)
public void SetUpStringList(List<string> originalList)
{
this.stringList = stringList;
this.stringList.AddRange(originalList);
this.stringList.Insert(0, "Please Select..."); // Add a default value "Please Select...
dropdown.ClearOptions();
dropdown.AddOptions(stringList);
dropdown.AddOptions(this.stringList);
}
private void ApplyParameters(string value)

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.Editor
{
public class EnableButtonGroup : MonoBehaviour
{
public Button enableButton;
public Button disableButton;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9e35201c989394f039d7a198ccd53d65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -3,20 +3,30 @@ using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Ichni.Editor
{
public class LogWindow : MonoBehaviour
public class LogWindow : StaticWindow
{
public GameObject logTextPrefab;
List<string> savedTexts;
public RectTransform textRect;
public Button copyAllTextsButton;
public Button removeAllTextsButton;
public Queue<LogText> logTexts;
public int logTextCapacity = 4;
private void Start()
protected override void Start()
{
base.Start();
savedTexts = new List<string>();
logTexts = new Queue<LogText>();
copyAllTextsButton.onClick.AddListener(CopyAllText);
removeAllTextsButton.onClick.AddListener(RemoveAllText);
}
public static void Log(string text, Color color = default)
@@ -29,6 +39,7 @@ namespace Ichni.Editor
CheckLogTextCapacity();
LogText logText = LeanPool.Spawn(logTextPrefab, textRect).GetComponent<LogText>();
if (color == default) color = Color.white;
savedTexts.Add(text);
logText.SetLogText(text, color);
logTexts.Enqueue(logText);
}
@@ -40,5 +51,26 @@ namespace Ichni.Editor
LeanPool.Despawn(logTexts.Dequeue().gameObject);
}
}
private void CopyAllText()
{
string allText = "";
foreach (string text in savedTexts)
{
allText += text + "\n";
}
GUIUtility.systemCopyBuffer = allText;
}
private void RemoveAllText()
{
foreach (LogText logText in logTexts)
{
LeanPool.Despawn(logText.gameObject);
}
logTexts.Clear();
savedTexts.Clear();
}
}
}

View File

@@ -6,18 +6,18 @@ using UnityEngine.UI;
namespace Ichni.Editor
{
public partial class ToolBar : MonoBehaviour
public partial class ToolBar : StaticWindow
{
public Button projectInfoButton;
public Button songInfoButton;
public Button saveButton;
public Button exportButton;
private void Start()
protected override void Start()
{
base.Start();
saveButton.onClick.AddListener(EditorManager.instance.projectManager.saveManager.Save);
exportButton.onClick.AddListener(EditorManager.instance.projectManager.exportManager.Export);
}
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -6,6 +7,29 @@ namespace Ichni.Editor
{
public abstract class StaticWindow : MonoBehaviour
{
public EnableButtonGroup enableButtonGroup;
protected virtual void Start()
{
if (enableButtonGroup != null)
{
enableButtonGroup.enableButton.onClick.AddListener(EnableWindow);
enableButtonGroup.disableButton.onClick.AddListener(DisableWindow);
}
}
public virtual void EnableWindow()
{
gameObject.SetActive(true);
enableButtonGroup.disableButton.gameObject.SetActive(true);
enableButtonGroup.enableButton.gameObject.SetActive(false);
}
public virtual void DisableWindow()
{
gameObject.SetActive(false);
enableButtonGroup.disableButton.gameObject.SetActive(false);
enableButtonGroup.enableButton.gameObject.SetActive(true);
}
}
}

View File

@@ -12,7 +12,7 @@ using UnityEngine.UI;
namespace Ichni.Editor
{
public partial class Timeline : MonoBehaviour
public partial class Timeline : StaticWindow
{
public float songTime => EditorManager.instance.songInformation.songTime;
public float songBeat => EditorManager.instance.songInformation.songBeat;

BIN
Assets/Scripts/EditorGame/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -101,6 +101,13 @@ namespace Ichni.RhythmGame
inspector.GenerateParameterText(this, container, "Current Position", nameof(currentPosition), true);
var currentRotText =
inspector.GenerateParameterText(this, container, "Current Rotation", nameof(currentEulerAngles), true);
if (attachedGameElement is PathNode pathNode) // 如果是PathNode显示法线方向
{
var currentNormalText =
inspector.GenerateHintText(this, container, () => "Normal: " + pathNode.transform.forward);
}
var currentScaleText =
inspector.GenerateParameterText(this, container, "Current Scale", nameof(currentScale), true);
@@ -108,8 +115,8 @@ namespace Ichni.RhythmGame
originalRotInputField.AddListenerFunction(Refresh);
originalScaleInputField.AddListenerFunction(Refresh);
//这玩意得放在最下面
container.SetDeviver(1);
//这玩意得放在最下面
container.SetDeviver(1);
}
public override void Refresh()

Binary file not shown.

Binary file not shown.

View File

@@ -135,7 +135,8 @@ namespace Ichni.RhythmGame
}
}
public override void SetUpInspector()
{//我想把时间放在第一层菜单所以
{
//我想把时间放在第一层菜单所以
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Element Info");
var nameInputField = inspector.GenerateParameterInputField(this, container, GetType().Name + "'s Name", nameof(elementName));
@@ -144,15 +145,16 @@ namespace Ichni.RhythmGame
{
inspector.GenerateCompositeParameterWindow(this, "Tags List", nameof(tags)).SetAsStringList();
});
var exactJudgeTimeInputField =
inspector.GenerateParameterInputField(this, container, "exactJudgeTime", nameof(exactJudgeTime));
exactJudgeTimeInputField.AddListenerFunction(_ => UpdateNoteInTrack());
foreach (var submodule in submoduleList)
{
submodule.SetUpInspector();
}
var judgetimeinput =
inspector.GenerateParameterInputField(this, container, "exactJudgeTime", nameof(exactJudgeTime));
base.SetUpInspector();
}
}

View File

@@ -36,9 +36,9 @@ namespace Ichni.RhythmGame
themeBundleList, nameof(themeBundleName));
themeBundleDropdown.AddListenerFunction(_ => inspectorMain.SetInspector(this));
if (themeBundleName != String.Empty)
if (themeBundleName != String.Empty && ThemeBundleManager.instance.TryGetThemeBundle(themeBundleName, out ThemeBundle themeBundle))
{
objectNameList = ThemeBundleManager.instance.GetThemeBundle(themeBundleName).assetList_GameObject.ConvertAll(x => x.name);
objectNameList = themeBundle.assetList_GameObject.ConvertAll(x => x.name);
var objectNameDropdown =
inspector.GenerateDropdown(this, container, "Object Name", objectNameList, nameof(objectName));
objectNameDropdown.AddListenerFunction(_ => inspectorMain.SetInspector(this));

Binary file not shown.

View File

@@ -276,8 +276,6 @@ namespace Ichni.RhythmGame
var setOnlyStartEndPathNodeSphereEnabledButton = inspector.GenerateButton(this, toolsContainerPathNode,
"Only Start & End Path Node's sphere enabled", SetOnlyStartEndPathNodeSphereEnabled);
trackSubmodulesContainer.SetDeviver(1);
}
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
@@ -14,12 +15,13 @@ namespace Ichni.Editor
public bool isSceneCameraActive;
public SceneCamera sceneCamera;
public float sceneCameraMoveSpeed;
public float sceneCameraRotateSpeed;
public GameCamera gameCamera;
public bool haveGameCamera => gameCamera != null;
public BaseElement_BM matchedBM { get; set; }
public void SwitchCamera()
{
if (!haveGameCamera)

View File

@@ -2,47 +2,82 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.UI;
namespace Ichni.Editor
{
public class InputListener : MonoBehaviour
public partial class InputListener : MonoBehaviour
{
private PointerEventData pointerEventData;
public EventSystem eventSystem;
public List<GraphicRaycaster> graphicRaycasters;
private void Update()
{
if (EditorManager.instance.cameraManager.isSceneCameraActive)
if (EditorManager.instance.cameraManager.isSceneCameraActive ||
!Keyboard.current.leftCtrlKey.isPressed) // 场景相机的移动和旋转
{
float cameraSpeed = EditorManager.instance.cameraManager.sceneCameraMoveSpeed * Time.deltaTime;
float cameraMoveSpeed = EditorManager.instance.cameraManager.sceneCameraMoveSpeed * Time.deltaTime;
Transform sceneCameraTransform = EditorManager.instance.cameraManager.sceneCamera.transform;
if (Keyboard.current.wKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.forward * cameraSpeed;
sceneCameraTransform.position += sceneCameraTransform.forward * cameraMoveSpeed;
}
if (Keyboard.current.sKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.forward * cameraSpeed;
sceneCameraTransform.position -= sceneCameraTransform.forward * cameraMoveSpeed;
}
if (Keyboard.current.dKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.right * cameraSpeed;
sceneCameraTransform.position += sceneCameraTransform.right * cameraMoveSpeed;
}
if (Keyboard.current.aKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.right * cameraSpeed;
sceneCameraTransform.position -= sceneCameraTransform.right * cameraMoveSpeed;
}
if (Keyboard.current.spaceKey.isPressed)
if (Keyboard.current.eKey.isPressed)
{
sceneCameraTransform.position += sceneCameraTransform.up * cameraSpeed;
sceneCameraTransform.position += sceneCameraTransform.up * cameraMoveSpeed;
}
if (Keyboard.current.leftShiftKey.isPressed)
if (Keyboard.current.qKey.isPressed)
{
sceneCameraTransform.position -= sceneCameraTransform.up * cameraSpeed;
sceneCameraTransform.position -= sceneCameraTransform.up * cameraMoveSpeed;
}
bool isPointerOverUI = IsPointerOverUI(out GameObject hoveredUI);
if (Mouse.current.rightButton.isPressed && !isPointerOverUI)
{
float cameraRotateSpeed = EditorManager.instance.cameraManager.sceneCameraRotateSpeed * Time.deltaTime;
Vector2 mouseDelta = Mouse.current.delta.ReadValue();
sceneCameraTransform.Rotate(Vector3.up, -mouseDelta.x * cameraRotateSpeed, Space.World);
sceneCameraTransform.Rotate(sceneCameraTransform.right, mouseDelta.y * cameraRotateSpeed, Space.World);
}
else if (isPointerOverUI)
{
}
}
if (eventSystem.currentSelectedGameObject == null &&
Keyboard.current.enterKey.wasPressedThisFrame) // 播放或暂停音乐
{
if (!EditorManager.instance.uiManager.timeline.musicPlayer.isPlaying)
{
EditorManager.instance.uiManager.timeline.musicPlayer.PlayMusic();
}
else
{
EditorManager.instance.uiManager.timeline.musicPlayer.PauseMusic();
}
}
if (Keyboard.current.leftCtrlKey.isPressed)
if (Keyboard.current.leftCtrlKey.isPressed) // 快捷键
{
// 保存和导出
if (Keyboard.current.sKey.wasPressedThisFrame)
{
EditorManager.instance.projectManager.saveManager.Save();
@@ -52,6 +87,7 @@ namespace Ichni.Editor
EditorManager.instance.projectManager.exportManager.Export();
}
// 复制粘贴删除
if (Keyboard.current.cKey.wasPressedThisFrame)
{
EditorManager.instance.operationManager.CopyPasteDeleteModule.CopyElement(EditorManager.instance.operationManager.currentSelectedElement);
@@ -60,7 +96,12 @@ namespace Ichni.Editor
{
EditorManager.instance.operationManager.CopyPasteDeleteModule.PasteElement(EditorManager.instance.operationManager.currentSelectedElement);
}
else if (Keyboard.current.dKey.wasPressedThisFrame)
{
EditorManager.instance.operationManager.currentSelectedElement.Delete();
}
// 开关移动设备分辨率提示
if (Keyboard.current.digit1Key.wasPressedThisFrame)
{
EditorManager.instance.uiManager.mainPage.resolutionHints.SetPhoneFrame();
@@ -76,4 +117,39 @@ namespace Ichni.Editor
}
}
}
public partial class InputListener
{
public bool IsPointerOverUI(out GameObject hoveredUI)
{
hoveredUI = null;
if (eventSystem == null || graphicRaycasters.Count == 0)
return false;
pointerEventData = new PointerEventData(eventSystem)
{
position = Mouse.current.position.ReadValue()
};
List<RaycastResult> allResults = new List<RaycastResult>();
// 遍历所有 Canvas 上的 GraphicRaycaster
foreach (var raycaster in graphicRaycasters)
{
List<RaycastResult> results = new List<RaycastResult>();
raycaster.Raycast(pointerEventData, results);
allResults.AddRange(results);
}
if (allResults.Count > 0)
{
// 按照 sortingOrder 获取最前面的 UI 物体
allResults.Sort((a, b) => b.sortingOrder.CompareTo(a.sortingOrder));
hoveredUI = allResults[0].gameObject;
return true;
}
return false;
}
}
}

View File

@@ -30,11 +30,12 @@ namespace Ichni
LoadThemeBundle("departure_to_multiverse");
}
public ThemeBundle GetThemeBundle(string themeBundleName)
public bool TryGetThemeBundle(string themeBundleName, out ThemeBundle themeBundle)
{
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName);
themeBundle = loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName);
return themeBundle != null;
}
public T GetObject<T>(string themeBundleName, string objectName) where T : class
{
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);