变量模块;Element启用控制
This commit is contained in:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user