变量模块;Element启用控制
This commit is contained in:
@@ -10,7 +10,6 @@ namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIInputFieldUnit : DynamicUICompositeUnit
|
||||
{
|
||||
[FormerlySerializedAs("stringInputField")]
|
||||
public TMP_InputField inputField;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIStringIntPairUnit : DynamicUICompositeUnit
|
||||
{
|
||||
public TMP_InputField keyInputField, valueInputField;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
{
|
||||
var pair = (KeyValuePair<string, int>) itemContent;
|
||||
compositeParameterWindow = window;
|
||||
|
||||
keyInputField.text = pair.Key;
|
||||
valueInputField.text = pair.Value.ToString();
|
||||
|
||||
keyInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
valueInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
|
||||
removeButton.onClick.AddListener(() =>
|
||||
{
|
||||
compositeParameterWindow.RemoveUnit(this);
|
||||
compositeParameterWindow.ApplyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
public KeyValuePair<string, int> GetValue()
|
||||
{
|
||||
return new KeyValuePair<string, int>(keyInputField.text, int.Parse(valueInputField.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25331c63f94545888c2f71a36d239ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -34,6 +34,11 @@ namespace Ichni.Editor
|
||||
unitList.Remove(unit);
|
||||
Destroy(unit.gameObject);
|
||||
}
|
||||
|
||||
public void AddListenerFunction(UnityAction action)
|
||||
{
|
||||
onQuit = action;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CompositeParameterWindow
|
||||
@@ -254,12 +259,45 @@ namespace Ichni.Editor
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newCurve);
|
||||
};
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
|
||||
public void SetAsStringIntDictionary()
|
||||
{
|
||||
ApplyParameters();
|
||||
//StartCoroutine(WindowAnim.HidePanel(gameObject, true));
|
||||
Destroy(gameObject);
|
||||
//生成Unit
|
||||
void GenerateUnit(KeyValuePair<string, int> content)
|
||||
{
|
||||
DynamicUIStringIntPairUnit unit = Instantiate(unitPrefab, windowRect).GetComponent<DynamicUIStringIntPairUnit>();
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.stringIntPairUnit;
|
||||
|
||||
Dictionary<string, int> dictionary = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Dictionary<string, int>;
|
||||
foreach (var pair in dictionary)
|
||||
{
|
||||
GenerateUnit(pair);
|
||||
}
|
||||
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
//为添加新的Unit的按钮设置点击事件
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new KeyValuePair<string, int>("New Variable", 0));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
//将当前所有Unit的值应用到对应的变量中
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
Dictionary<string, int> dictionaryList = new Dictionary<string, int>();
|
||||
foreach (var unit in unitList)
|
||||
{
|
||||
KeyValuePair<string, int> pair = (unit as DynamicUIStringIntPairUnit).GetValue();
|
||||
dictionaryList.Add(pair.Key, pair.Value);
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, dictionaryList);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni;
|
||||
@@ -5,6 +6,7 @@ using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
@@ -154,8 +156,7 @@ namespace Ichni.Editor
|
||||
return hintText;
|
||||
}
|
||||
|
||||
public DynamicUIHintText GenerateHintText(IBaseElement baseElement, DynamicUIContainer container,
|
||||
System.Func<string> action)
|
||||
public DynamicUIHintText GenerateHintText(IBaseElement baseElement, DynamicUIContainer container, Func<string> action)
|
||||
{
|
||||
DynamicUIHintText hintText = Object.Instantiate(EditorManager.instance.basePrefabs.hintText, container.rect)
|
||||
.GetComponent<DynamicUIHintText>();
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Ichni.Editor
|
||||
public Button closeButton;
|
||||
public TMP_Text title;
|
||||
public UnityAction onCloseWindow;
|
||||
public UnityAction onQuit;
|
||||
|
||||
protected void InitializeWindow(string titleText, UnityAction closeAction = null)
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace Ichni.Editor
|
||||
closeButton.onClick.AddListener(() =>
|
||||
{
|
||||
onCloseWindow?.Invoke();
|
||||
onQuit?.Invoke();
|
||||
Destroy(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
effectCollection = new Dictionary<string, List<EffectBase>>();
|
||||
|
||||
if (preset == EffectSubmodulePreset.Default) //对于默认的效果次级模块,只有Default效果集合
|
||||
if (preset == EffectSubmodulePreset.Default) //对于默认的效果次级模块,有Prior、Default、Late三个效果集合
|
||||
{
|
||||
effectCollection.Add("Prior", new List<EffectBase>());
|
||||
effectCollection.Add("Default", new List<EffectBase>());
|
||||
effectCollection.Add("Late", new List<EffectBase>());
|
||||
}
|
||||
else if (preset == EffectSubmodulePreset.Note) //对于Note的效果次级模块,在Note的不同状态下有独立的效果集合
|
||||
{
|
||||
@@ -33,6 +35,7 @@ namespace Ichni.RhythmGame
|
||||
effectCollection.Add("Good", new List<EffectBase>());
|
||||
effectCollection.Add("Bad", new List<EffectBase>());
|
||||
effectCollection.Add("Miss", new List<EffectBase>());
|
||||
effectCollection.Add("AfterJudge", new List<EffectBase>());
|
||||
}
|
||||
|
||||
(attachedGameElement as IHaveEffectSubmodule).effectSubmodule = this;
|
||||
@@ -79,7 +82,7 @@ namespace Ichni.RhythmGame
|
||||
var effectNameInputField = inspector.GenerateInputField(container, "Effect Name");
|
||||
var addEffectButton = inspector.GenerateButton(this, container, "Add Effect", () =>
|
||||
{
|
||||
if (EffectSubmodule.EffectCollection.TryGetValue(effectNameInputField.GetValue<string>(), out var newEffect))
|
||||
if (EffectCollection.TryGetValue(effectNameInputField.GetValue<string>(), out var newEffect))
|
||||
{
|
||||
effectCollection[effect.Key].Add(newEffect);
|
||||
inspectorMain.SetInspector(attachedGameElement);
|
||||
@@ -107,7 +110,9 @@ namespace Ichni.RhythmGame
|
||||
{ "Bloom", new BloomEffect(1, 2, CustomCurvePresets.Parabolic(1,0,2)) },
|
||||
{ "CameraShake", new CameraShakeEffect(1, 50, 1, 1, 1) },
|
||||
{ "ChromaticAberration", new ChromaticAberrationEffect(1, 1, CustomCurvePresets.Parabolic(1,0,1)) },
|
||||
{ "Vignette", new VignetteEffect(1, 1, 0.4f, Color.black, CustomCurvePresets.Parabolic(1,0,1)) }
|
||||
{ "Vignette", new VignetteEffect(1, 1, 0.4f, Color.black, CustomCurvePresets.Parabolic(1,0,1)) },
|
||||
{ "SetInteger", new SetIntegerEffect("New Variable", 0, false, 0, 1) },
|
||||
{ "EnableControl", new EnableControlEffect(null, "New Variable", 0, false, "") },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class EnableControlEffect : EffectBase
|
||||
{
|
||||
public GameElement connectedGameElement;
|
||||
public string connectedVariableName;
|
||||
public int enableValue;
|
||||
|
||||
public bool useExpression;
|
||||
public string expression;
|
||||
|
||||
public EnableControlEffect(GameElement connectedGameElement, string connectedVariableName,
|
||||
int enableValue, bool useExpression, string expression)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.connectedGameElement = connectedGameElement;
|
||||
this.connectedVariableName = connectedVariableName;
|
||||
this.enableValue = enableValue;
|
||||
this.useExpression = useExpression;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public override void Recover()
|
||||
{
|
||||
if (connectedGameElement == null) return;
|
||||
|
||||
connectedGameElement.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
if (connectedGameElement == null) return;
|
||||
|
||||
if (!useExpression)
|
||||
{
|
||||
int value = EditorManager.instance.variablesContainer.GetVariable(connectedVariableName);
|
||||
connectedGameElement.gameObject.SetActive(value == enableValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new EnableControlEffect_BM(connectedGameElement.elementGuid,
|
||||
connectedVariableName, enableValue, useExpression, expression);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
var container = inspector.GenerateContainer("Enable Control");
|
||||
var connectedGameElementInputField = inspector.GenerateInputField(container, "Game Element Name");
|
||||
var connectGameElementButton = inspector.GenerateButton(this, container, "Connect Game Element", () =>
|
||||
{
|
||||
connectedGameElement = EditorManager.instance.beatmapContainer.gameElementList
|
||||
.First(e => e.elementName == connectedGameElementInputField.GetValue<string>());
|
||||
|
||||
if (connectedGameElement == null)
|
||||
{
|
||||
LogWindow.Log("Game Element not found.", Color.red);
|
||||
}
|
||||
|
||||
inspectorMain.SetInspector(EditorManager.instance.operationManager.currentSelectedElement);
|
||||
});
|
||||
|
||||
string ShowConnection() => connectedGameElement == null ? "No Game Element Connected" : "Connected With: " + connectedGameElement.elementName;
|
||||
var connectHintText = inspector.GenerateHintText(this, container, ShowConnection);
|
||||
|
||||
var connectedVariableNameInputField = inspector.GenerateInputField(this, container, "Connected Variable Name", nameof(connectedVariableName));
|
||||
var enableValueInputField = inspector.GenerateInputField(this, container, "Enable Value", nameof(enableValue));
|
||||
|
||||
var useExpressionToggle = inspector.GenerateToggle(this, container, "Use Expression", nameof(useExpression));
|
||||
useExpressionToggle.toggle.interactable = false;
|
||||
var expressionInputField = inspector.GenerateInputField(this, container, "Expression", nameof(expression));
|
||||
expressionInputField.inputField.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class EnableControlEffect_BM : EffectBase_BM
|
||||
{
|
||||
public Guid connectedGameElementGuid;
|
||||
public string connectedVariableName;
|
||||
public int enableValue;
|
||||
public bool useExpression;
|
||||
public string expression;
|
||||
|
||||
public EnableControlEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EnableControlEffect_BM(Guid connectedGameElementGuid, string connectedVariableName,
|
||||
int enableValue, bool useExpression, string expression)
|
||||
{
|
||||
this.connectedGameElementGuid = connectedGameElementGuid;
|
||||
this.connectedVariableName = connectedVariableName;
|
||||
this.enableValue = enableValue;
|
||||
this.useExpression = useExpression;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new EnableControlEffect(GameElement_BM.GetElement(connectedGameElementGuid), connectedVariableName,
|
||||
enableValue, useExpression, expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1117b38637ccd4eae86b05caa2160ab5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class SetIntegerEffect : EffectBase
|
||||
{
|
||||
public string targetVariableName;
|
||||
|
||||
public int targetValue;
|
||||
|
||||
public bool isRandom;
|
||||
public int minValue;
|
||||
public int maxValue;
|
||||
|
||||
public SetIntegerEffect(string targetVariableName, int targetValue, bool isRandom, int minValue, int maxValue)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.targetVariableName = targetVariableName;
|
||||
this.targetValue = targetValue;
|
||||
this.isRandom = isRandom;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override void Recover()
|
||||
{
|
||||
EditorManager.instance.variablesContainer.RevertVariable(targetVariableName);
|
||||
}
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
EditorManager.instance.variablesContainer.SetVariable(targetVariableName, isRandom ? Random.Range(minValue, maxValue + 1) : targetValue);
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new SetIntegerEffect_BM(targetVariableName, targetValue, isRandom, minValue, maxValue);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Set Integer");
|
||||
var targetVariableNameInputField = inspector.GenerateInputField(this, container, "Target Variable Name", nameof(targetVariableName));
|
||||
var targetValueInputField = inspector.GenerateInputField(this, container, "Target Value", nameof(targetValue));
|
||||
var isRandomToggle = inspector.GenerateToggle(this, container, "Is Random", nameof(isRandom));
|
||||
var minValueInputField = inspector.GenerateInputField(this, container, "Min Value", nameof(minValue));
|
||||
var maxValueInputField = inspector.GenerateInputField(this, container, "Max Value", nameof(maxValue));
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class SetIntegerEffect_BM : EffectBase_BM
|
||||
{
|
||||
public string targetVariableName;
|
||||
public int targetValue;
|
||||
public bool isRandom;
|
||||
public int minValue;
|
||||
public int maxValue;
|
||||
|
||||
public SetIntegerEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SetIntegerEffect_BM(string targetVariableName, int targetValue, bool isRandom, int minValue, int maxValue)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.targetVariableName = targetVariableName;
|
||||
this.targetValue = targetValue;
|
||||
this.isRandom = isRandom;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new SetIntegerEffect(targetVariableName, targetValue, isRandom, minValue, maxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3abb71bdf6fc94cd982379ef2f5161fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -30,6 +30,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private void Update()
|
||||
{
|
||||
effectSubmodule.effectCollection["Prior"].ForEach(effect => effect.UpdateEffect(time));
|
||||
effectSubmodule.effectCollection["Default"].ForEach(effect => effect.UpdateEffect(time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 635b0c6a4e50f4b83beb64c5e13ef0c2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class BackgroundSetter : GameElement
|
||||
{
|
||||
@@ -20,8 +20,15 @@ namespace Ichni.Editor
|
||||
bool isFirstGenerated, GameElement parentElement, bool useSkybox, string skyboxThemeBundleName,
|
||||
string skyboxMaterialName, string backgroundSpriteName)
|
||||
{
|
||||
if (EditorManager.instance.backgroundSetter != null)
|
||||
{
|
||||
LogWindow.Log("There is already a Background Setter in the scene.", Color.red);
|
||||
return null;
|
||||
}
|
||||
|
||||
BackgroundSetter backgroundSetter = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
|
||||
.AddComponent<BackgroundSetter>();
|
||||
EditorManager.instance.backgroundSetter = backgroundSetter;
|
||||
backgroundSetter.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
backgroundSetter.useSkybox = useSkybox;
|
||||
backgroundSetter.skyboxThemeBundleName = skyboxThemeBundleName;
|
||||
@@ -29,26 +36,26 @@ namespace Ichni.Editor
|
||||
backgroundSetter.backgroundSpriteName = backgroundSpriteName;
|
||||
return backgroundSetter;
|
||||
}
|
||||
|
||||
public void SetSkybox(string themeBundleName, string materialName)
|
||||
public override void Refresh()
|
||||
{
|
||||
skyboxThemeBundleName = themeBundleName;
|
||||
skyboxMaterialName = materialName;
|
||||
skyboxMaterial = ThemeBundleManager.instance.GetObject<Material>(themeBundleName, materialName);
|
||||
if (skyboxMaterial == null) skyboxMaterial = EditorManager.instance.basePrefabs.defaultSkyboxMaterial;
|
||||
EditorManager.instance.backgroundController.SetSkybox(skyboxMaterial);
|
||||
EditorManager.instance.backgroundController.EnableBackground(!useSkybox);
|
||||
if (useSkybox)
|
||||
{
|
||||
SetSkybox(skyboxThemeBundleName, skyboxMaterialName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBackgroundSprite(backgroundSpriteName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBackgroundSprite(string backgroundSpriteName)
|
||||
public partial class BackgroundSetter
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
string path = EditorManager.instance.projectInformation.projectPath + "/Sprites/" + backgroundSpriteName + ".png";
|
||||
backgroundSprite = ES3.FileExists(path) ? ES3.Load<Sprite>(path) : EditorManager.instance.basePrefabs.defaultBackground;
|
||||
EditorManager.instance.backgroundController.SetBackground(backgroundSprite);
|
||||
}
|
||||
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
|
||||
matchedBM = new BackgroundSetter_BM(elementName, elementGuid, tags, null,
|
||||
useSkybox, skyboxThemeBundleName, skyboxMaterialName, backgroundSpriteName);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -73,34 +80,61 @@ namespace Ichni.Editor
|
||||
useSkyboxToggle.AddListenerFunction(() => EditorManager.instance.backgroundController.EnableBackground(!useSkybox));
|
||||
useSkyboxToggle.AddListenerFunction(() => SetInputFields(useSkybox));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
public partial class BackgroundSetter
|
||||
{
|
||||
private void SetSkybox(string themeBundleName, string materialName)
|
||||
{
|
||||
skyboxThemeBundleName = themeBundleName;
|
||||
skyboxMaterialName = materialName;
|
||||
skyboxMaterial = ThemeBundleManager.instance.GetObject<Material>(themeBundleName, materialName);
|
||||
if (skyboxMaterial == null) skyboxMaterial = EditorManager.instance.basePrefabs.defaultSkyboxMaterial;
|
||||
EditorManager.instance.backgroundController.SetSkybox(skyboxMaterial);
|
||||
}
|
||||
|
||||
EditorManager.instance.backgroundController.EnableBackground(!useSkybox);
|
||||
if (useSkybox)
|
||||
{
|
||||
SetSkybox(skyboxThemeBundleName, skyboxMaterialName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBackgroundSprite(backgroundSpriteName);
|
||||
}
|
||||
private void SetBackgroundSprite(string spriteName)
|
||||
{
|
||||
string path = EditorManager.instance.projectInformation.projectPath + "/Sprites/" + spriteName + ".png";
|
||||
backgroundSprite = ES3.FileExists(path) ? ES3.Load<Sprite>(path) : EditorManager.instance.basePrefabs.defaultBackground;
|
||||
EditorManager.instance.backgroundController.SetBackground(backgroundSprite);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class BackgroundSetter_BM : BaseElement_BM
|
||||
public class BackgroundSetter_BM : GameElement_BM
|
||||
{
|
||||
public bool useSkybox;
|
||||
public string skyboxThemeBundleName;
|
||||
public string skyboxMaterialName;
|
||||
public string backgroundSpriteName;
|
||||
|
||||
public BackgroundSetter_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BackgroundSetter_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
bool useSkybox, string skyboxThemeBundleName, string skyboxMaterialName, string backgroundSpriteName)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.useSkybox = useSkybox;
|
||||
this.skyboxThemeBundleName = skyboxThemeBundleName;
|
||||
this.skyboxMaterialName = skyboxMaterialName;
|
||||
this.backgroundSpriteName = backgroundSpriteName;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
matchedElement = BackgroundSetter.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid), useSkybox, skyboxThemeBundleName, skyboxMaterialName, backgroundSpriteName);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement attached)
|
||||
{
|
||||
return BackgroundSetter.GenerateElement(elementName, Guid.NewGuid(), tags, false, attached,
|
||||
useSkybox, skyboxThemeBundleName, skyboxMaterialName, backgroundSpriteName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class VariablesContainer : GameElement
|
||||
{
|
||||
public Dictionary<string, int> originalVariables;
|
||||
public Dictionary<string, int> currentVariables;
|
||||
|
||||
public static VariablesContainer GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, Dictionary<string, int> variables)
|
||||
{
|
||||
if (EditorManager.instance.variablesContainer != null)
|
||||
{
|
||||
LogWindow.Log("There is already a Variables Container in the scene.", Color.red);
|
||||
return null;
|
||||
}
|
||||
|
||||
VariablesContainer variablesContainer =
|
||||
Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<VariablesContainer>();
|
||||
|
||||
EditorManager.instance.variablesContainer = variablesContainer;
|
||||
variablesContainer.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
variablesContainer.originalVariables = new Dictionary<string, int>(variables);
|
||||
variablesContainer.currentVariables = new Dictionary<string, int>(variables);
|
||||
|
||||
return variablesContainer;
|
||||
}
|
||||
|
||||
public void SetVariable(string variableName, int value)
|
||||
{
|
||||
currentVariables[variableName] = value;
|
||||
}
|
||||
|
||||
public int GetVariable(string variableName)
|
||||
{
|
||||
return currentVariables[variableName];
|
||||
}
|
||||
|
||||
public void RevertVariable(string variableName)
|
||||
{
|
||||
currentVariables[variableName] = originalVariables[variableName];
|
||||
}
|
||||
|
||||
public void RevertAllVariables()
|
||||
{
|
||||
currentVariables = new Dictionary<string, int>(originalVariables);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class VariablesContainer
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new VariablesContainer_BM(elementName, elementGuid, tags, null, originalVariables);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Variables Container");
|
||||
var originalVariablesButton = inspector.GenerateButton(this, container, "Original Variables", () =>
|
||||
{
|
||||
var ov = inspector.GenerateCompositeParameterWindow(this, "Original Variables List", nameof(originalVariables));
|
||||
ov.SetAsStringIntDictionary();
|
||||
ov.AddListenerFunction(RevertAllVariables);
|
||||
});
|
||||
|
||||
var currentVariablesButton = inspector.GenerateButton(this, container, "Current Variables", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Current Variables List", nameof(currentVariables)).SetAsStringIntDictionary();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class VariablesContainer_BM : GameElement_BM
|
||||
{
|
||||
public Dictionary<string, int> originalVariables;
|
||||
|
||||
public VariablesContainer_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public VariablesContainer_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
|
||||
Dictionary<string, int> originalVariables) : base(elementName, elementGuid, tags, parentElement)
|
||||
{
|
||||
this.originalVariables = new Dictionary<string, int>(originalVariables);
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = VariablesContainer.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid), originalVariables);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement attached)
|
||||
{
|
||||
return VariablesContainer.GenerateElement(elementName, Guid.NewGuid(), tags, false, attached, originalVariables);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3635ae4e7b31f4ae7a942151377c59f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -118,6 +118,8 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
}
|
||||
|
||||
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
|
||||
if (EditorManager.instance.cameraManager.haveGameCamera)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject animatedBoolUnit;
|
||||
public GameObject customCurveKeyframeUnit;
|
||||
public GameObject customCurveWrapModeUnit;
|
||||
public GameObject stringIntPairUnit;
|
||||
[Title("图形化动画编辑器")]
|
||||
public GameObject graphicalFlexibleFloatWindow;
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace Ichni
|
||||
|
||||
public NoteBase.NoteJudgeType currentJudgeType;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
[Title("Runtime Global Elements")]
|
||||
public VariablesContainer variablesContainer;
|
||||
public BackgroundSetter backgroundSetter;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -109,6 +113,11 @@ namespace Ichni
|
||||
new List<string>(), true, null, false,
|
||||
"basic", "Skybox", "Background"));
|
||||
|
||||
var generateVariablesContainerButton =
|
||||
inspector.GenerateButton(this, container, "Generate Variables Container",
|
||||
() => VariablesContainer.GenerateElement("Variables Container", Guid.NewGuid(),
|
||||
new List<string>(), true, null, new Dictionary<string, int>()));
|
||||
|
||||
projectInformation.SetUpInspector();
|
||||
songInformation.SetUpInspector();
|
||||
cameraManager.SetUpInspector();
|
||||
|
||||
@@ -19,11 +19,15 @@ namespace Ichni.Editor
|
||||
|
||||
public void SelectElement(GameElement gameElement)
|
||||
{
|
||||
if(currentSelectedElement != null)
|
||||
if (currentSelectedElement != null)
|
||||
{
|
||||
currentSelectedElement.connectedTab.isSelected = false;
|
||||
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
|
||||
if (currentSelectedElement.connectedTab.BgImage != null)
|
||||
{
|
||||
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
currentSelectedElement = gameElement;
|
||||
currentSelectedElement.connectedTab.isSelected = true;
|
||||
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f,0.5f, 0.5f, 0.2f);
|
||||
|
||||
Reference in New Issue
Block a user