效果模块,以及代码位置整理

This commit is contained in:
SoulliesOfficial
2025-02-16 11:15:42 -05:00
parent 934d1b5aba
commit d77e1a0f70
204 changed files with 1107 additions and 347 deletions

View File

@@ -1,13 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni
{
public class EditorSettings
{
public int autoSaveInterval = 300;
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
namespace Ichni.Editor
{

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
@@ -20,7 +21,19 @@ namespace Ichni.Editor
private void ApplyParameters(string text)
{
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, text);
Type type = connectedBaseElement.GetType().GetField(parameterName).FieldType;
if (type == typeof(int))
{
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, int.Parse(text));
}
else if (type == typeof(float))
{
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, float.Parse(text));
}
else if (type == typeof(string))
{
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, text);
}
connectedBaseElement.Refresh();
}
}

View File

@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Ichni.Editor
@@ -22,5 +23,10 @@ namespace Ichni.Editor
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, value);
connectedBaseElement.Refresh();
}
public void AddListenerFunction(UnityAction<bool> action)
{
toggle.onValueChanged.AddListener(action);
}
}
}

View File

@@ -6,9 +6,9 @@ namespace Ichni.Editor
{
public class EditorUIManager : MonoBehaviour
{
public MainPage mainPage;
public Hierarchy hierarchy;
public Inspector inspector;
public Timeline timeline;
}
}

View File

@@ -72,6 +72,16 @@ namespace Ichni.Editor
container.dynamicUIElements.Add(button);
return button;
}
public DynamicUIToggle GenerateToggle(IBaseElement baseElement, DynamicUIContainer container, string title,
string parameterName)
{
DynamicUIToggle toggle = Instantiate(EditorManager.instance.basePrefabs.toggle, container.rect)
.GetComponent<DynamicUIToggle>();
toggle.Initialize(baseElement, title, parameterName);
container.dynamicUIElements.Add(toggle);
return toggle;
}
public DynamicUIInputField GenerateInputField(IBaseElement baseElement, DynamicUIContainer container,
string title, string parameterName)

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6795f50bfe6d14cb7a78043ec0d9b433
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.Editor
{
public class MainPage : StaticWindow
{
public Canvas mainCanvas;
public ToolBar toolBar;
public ResolutionHints resolutionHints;
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77cef690bc8234daba9231732db8dfb4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.Editor
{
public partial class ResolutionHints : MonoBehaviour
{
public Image phoneFrame;
public Image iPadFrame;
public Image safeAreaFrame;
}
public partial class ResolutionHints
{
public void SetPhoneFrame()
{
phoneFrame.gameObject.SetActive(!phoneFrame.gameObject.activeSelf);
}
public void SetIPadFrame()
{
iPadFrame.gameObject.SetActive(!iPadFrame.gameObject.activeSelf);
}
public void SetSafeAreaFrame()
{
safeAreaFrame.gameObject.SetActive(!safeAreaFrame.gameObject.activeSelf);
}
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.Editor
{
public partial class ToolBar : MonoBehaviour
{
public Button projectInfoButton;
public Button songInfoButton;
public Button saveButton;
public Button exportButton;
private void Start()
{
saveButton.onClick.AddListener(EditorManager.instance.projectManager.saveManager.Save);
exportButton.onClick.AddListener(EditorManager.instance.projectManager.exportManager.Export);
}
}
public partial class ToolBar
{
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7bf117e642611451c8562357254c1e83
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -40,6 +40,7 @@ namespace Ichni.RhythmGame
throw new NotImplementedException();
}
public Inspector inspector => EditorManager.instance.uiManager.inspector;
public void SetUpInspector();
}

View File

@@ -81,15 +81,18 @@ namespace Ichni.RhythmGame
{
var container = inspector.GenerateContainer("Color");
var baseColor = inspector.GenerateBaseColorPicker(this, container, "Base Color", nameof(originalBaseColor));
var emissionColor = inspector.GenerateEmissionColorPicker(this, container, "Emission Color", nameof(emissionEnabled),
nameof(originalEmissionColor), nameof(originalEmissionIntensity));
if ((attachedGameElement as IHaveColorSubmodule).haveEmission)
{
var emissionColor = inspector.GenerateEmissionColorPicker(this, container, "Emission Color",
nameof(emissionEnabled), nameof(originalEmissionColor), nameof(originalEmissionIntensity));
}
}
}
public interface IHaveColorSubmodule
{
public ColorSubmodule colorSubmodule { get; set; }
public bool haveEmission { get; }
}
namespace Beatmap

View File

@@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Sirenix.Utilities;
using UnityEngine;
namespace Ichni.RhythmGame
@@ -47,11 +49,26 @@ namespace Ichni.RhythmGame
effectCollection.Add(effect.Key, effectList);
}
}
}
public partial class EffectSubmodule
{
public override void SaveBM()
{
matchedBM = new EffectSubmodule_BM(attachedGameElement);
}
public override void SetUpInspector()
{
foreach (var effect in effectCollection)
{
var container = inspector.GenerateContainer(effect.Key);
foreach (var effectBase in effect.Value)
{
effectBase.SetUpInspector();
}
}
}
}
public partial class EffectSubmodule
@@ -110,7 +127,7 @@ namespace Ichni.RhythmGame
}
}
public abstract class EffectBase
public abstract class EffectBase : IBaseElement
{
public enum EffectState
{
@@ -120,6 +137,9 @@ namespace Ichni.RhythmGame
Error = 100
}
public BaseElement_BM matchedBM { get; set; }
public Inspector inspector => EditorManager.instance.uiManager.inspector;
/// <summary>
/// 效果的持续时间如果为0则表示瞬间效果
/// </summary>
@@ -146,10 +166,15 @@ namespace Ichni.RhythmGame
this.effectTime = effectTime;
this.nowEffectState = EffectState.Before;
}
public virtual void UpdateEffect()
public void SaveBM()
{
EffectState state = CheckEffectState();
throw new System.NotImplementedException();
}
public virtual void UpdateEffect(float triggerTime)
{
EffectState state = CheckEffectState(triggerTime);
if (state == EffectState.Before && nowEffectState != EffectState.Before)
{
@@ -168,9 +193,27 @@ namespace Ichni.RhythmGame
}
}
public virtual EffectState CheckEffectState()
protected virtual EffectState CheckEffectState(float triggerTime)
{
throw new System.NotImplementedException();
float songTime = EditorManager.instance.songInformation.songTime;
if (songTime < triggerTime)
{
return EffectState.Before;
}
if (songTime >= triggerTime &&
songTime <= triggerTime + effectTime)
{
return EffectState.Middle;
}
if (songTime > triggerTime + effectTime)
{
return EffectState.After;
}
return EffectState.Error;
}
/// <summary>
@@ -203,6 +246,13 @@ namespace Ichni.RhythmGame
/// </summary>
/// <returns></returns>
public abstract EffectBase_BM ConvertToBM();
public void Refresh()
{
}
public abstract void SetUpInspector();
}
namespace Beatmap

View File

@@ -13,6 +13,8 @@ namespace Ichni.RhythmGame
public BaseElement_BM matchedBM { get; set; }
public Inspector inspector => EditorManager.instance.uiManager.inspector;
public SubmoduleBase(GameElement attachedGameElement)
{
this.attachedGameElement = attachedGameElement;
@@ -34,9 +36,7 @@ namespace Ichni.RhythmGame
{
attachedGameElement.submoduleList.Remove(this);
}
public Inspector inspector => EditorManager.instance.uiManager.inspector;
public virtual void SetUpInspector()
{

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class TimeDurationSubmodule: SubmoduleBase
public partial class TimeDurationSubmodule : SubmoduleBase
{
public bool isOverridingDuration; //是否手动设置了时间区间,开启时,子物体的时间区间将被忽略,且在自动计算区间时跳过此模块
public float startTime, endTime; //起止时间
@@ -82,6 +82,28 @@ namespace Ichni.RhythmGame
}
}
public partial class TimeDurationSubmodule
{
public override void SetUpInspector()
{
var container = inspector.GenerateContainer("Time Duration");
var overrideToggle = inspector.GenerateToggle(this, container, "Override Duration", nameof(isOverridingDuration));
var startTimeInputField = inspector.GenerateInputField(this, container, "Start Time", nameof(startTime));
var endTimeInputField = inspector.GenerateInputField(this, container, "End Time", nameof(endTime));
void SetInputFieldInteractable(bool interactable)
{
startTimeInputField.inputField.interactable = interactable;
endTimeInputField.inputField.interactable = interactable;
}
SetInputFieldInteractable(isOverridingDuration);
overrideToggle.AddListenerFunction(SetInputFieldInteractable);
}
}
public interface IHaveTimeDurationSubmodule
{
public TimeDurationSubmodule timeDurationSubmodule { get; set; }

View File

@@ -17,11 +17,7 @@ namespace Ichni.RhythmGame
public static ElementFolder GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated, GameElement parentElement)
{
ElementFolder elementFolder = Instantiate(EditorManager.instance.basePrefabs.elementFolder).GetComponent<ElementFolder>();
elementFolder.Initialize(name, id, tags, isFirstGenerated, parentElement);
//elementFolder.GenerateTab(parentElement);
return elementFolder;
}
@@ -33,7 +29,6 @@ namespace Ichni.RhythmGame
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
}
}

View File

@@ -39,6 +39,8 @@ namespace Ichni.RhythmGame
//存档类
public BaseElement_BM matchedBM { get; set; }
public Inspector inspector => EditorManager.instance.uiManager.inspector;
/// <summary>
/// 首次初始化
@@ -139,8 +141,6 @@ namespace Ichni.RhythmGame
public abstract partial class GameElement
{
public Inspector inspector => EditorManager.instance.uiManager.inspector;
public virtual void SetUpInspector() //被点击时设置第一层Inspector
{
var container = inspector.GenerateContainer("Element Info");

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using MoreMountains.Feedbacks;
@@ -28,5 +29,10 @@ namespace Ichni.RhythmGame
{
throw new NotImplementedException();
}
public override void SetUpInspector()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TimeEffectsCollection : GameElement, IHaveEffectSubmodule
{
public EffectSubmodule effectSubmodule { get; set; }
public float time;
public static TimeEffectsCollection CreateTimeEffectsCollection(float time)
{
TimeEffectsCollection timeEffectsCollection = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<TimeEffectsCollection>();
timeEffectsCollection.time = time;
return timeEffectsCollection;
}
protected override void SetDefaultSubmodules()
{
effectSubmodule = new EffectSubmodule(this);
}
private void Update()
{
effectSubmodule.effectCollection["Default"].ForEach(effect => effect.UpdateEffect(time));
}
}
public partial class TimeEffectsCollection
{
public override void SaveBM()
{
}
public override void SetUpInspector()
{
var container = inspector.GenerateContainer("Time Effects Collection");
var timeInputField = inspector.GenerateInputField(this, container, "Time", nameof(time));
}
}
namespace Beatmap
{
}
}

Some files were not shown because too many files have changed in this diff Show More