15 Commits

23 changed files with 174 additions and 99 deletions

Binary file not shown.

View File

@@ -10,6 +10,11 @@ namespace Cryville.Common.Unity {
float timer = 0;
const float DURATION = 5.0f;
const float DURIN = 0.4f;
const float DUROUT = 0.4f;
const float HEIGHT = 50f;
#pragma warning disable IDE0051
void Start() {
layout = GetComponent<LayoutElement>();
@@ -19,9 +24,9 @@ namespace Cryville.Common.Unity {
}
void Update() {
if (timer <= 0.8f) layout.minHeight = timer * 50;
else if (timer >= 5f) GameObject.Destroy(gameObject);
else if (timer >= 4.2f) layout.minHeight = (300 - timer) * 50;
if (timer <= DURIN) layout.minHeight = timer / DURIN * HEIGHT;
else if (timer >= DURATION) GameObject.Destroy(gameObject);
else if (timer >= DURATION - DUROUT) layout.minHeight = (DURATION - timer) / DUROUT * HEIGHT;
timer += Time.deltaTime;
}
#pragma warning restore IDE0051

View File

@@ -200,8 +200,7 @@ namespace Cryville.Common.Unity.UI {
void GenerateLine(int index, int line) {
for (int j = 0; j < LineItemCount; j++) {
var child = GameObject.Instantiate(m_itemTemplate);
child.transform.SetParent(transform, false);
var child = GameObject.Instantiate(m_itemTemplate, transform, false);
lines[index][j] = child;
}
LoadLine(index, line);

View File

@@ -60,10 +60,10 @@ namespace Cryville.Crtr.Browsing {
}
}
public void OnPlay() {
Master.Open(_id);
Master.Open(_id, _data);
}
public void OnConfig() {
Master.OpenConfig(_id);
Master.OpenConfig(_id, _data);
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using Logger = Cryville.Common.Logger;
namespace Cryville.Crtr.Browsing {
internal class LegacyResourceManager : IResourceManager<ChartDetail> {
@@ -115,9 +116,19 @@ namespace Cryville.Crtr.Browsing {
var file = new FileInfo(path);
if (!converters.ContainsKey(file.Extension)) return false;
foreach (var converter in converters[file.Extension]) {
var resources = converter.ConvertFrom(file);
IEnumerable<Resource> resources = null;
try {
resources = converter.ConvertFrom(file);
}
catch (Exception ex) {
CallHelper.ShowMessageBox(ex.Message);
return false;
}
foreach (var res in resources) {
if (res is ChartResource) {
if (!res.Valid) {
Logger.Log("main", 3, "Resource", "Attempt to import invalid resource {0}", res);
}
else if (res is ChartResource) {
var tres = (ChartResource)res;
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
if (!dir.Exists) dir.Create();
@@ -134,6 +145,7 @@ namespace Cryville.Crtr.Browsing {
if (!dir.Exists) dir.Create();
var dest = new FileInfo(_rootPath + "/charts/" + res.Name + "/cover" + tres.Source.Extension);
if (!dest.Exists) tres.Source.CopyTo(dest.FullName);
}
else if (res is SongResource) {
var tres = (SongResource)res;

View File

@@ -24,10 +24,6 @@ namespace Cryville.Crtr.Browsing {
const float SPEED = 8;
float _ratio;
#pragma warning disable IDE0051
void Start() {
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
}
void Update() {
if (_value && _ratio != 1) {
_ratio += SPEED * Time.deltaTime;
@@ -40,6 +36,10 @@ namespace Cryville.Crtr.Browsing {
UpdateGraphics();
}
}
void OnRectTransformDimensionsChange() {
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
}
#pragma warning restore IDE0051
void UpdateGraphics() {

View File

@@ -60,7 +60,6 @@ namespace Cryville.Crtr.Browsing {
ev.callback.AddListener(e => OnPointerClick((PointerEventData)e));
m_ctn.triggers.Add(ev);
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
if (MaxStep != 0) SetRatio(0.5f);
}
@@ -70,6 +69,10 @@ namespace Cryville.Crtr.Browsing {
SetValueFromPos(pp);
}
}
void OnRectTransformDimensionsChange() {
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
}
#pragma warning restore IDE0051
Vector2 pp;

View File

@@ -32,8 +32,7 @@ namespace Cryville.Crtr.Browsing {
public void Load(string name, IEnumerable<PropertyInfo> props, object target) {
Name = name.ToUpper();
foreach (var prop in props) {
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab);
obj.transform.SetParent(transform, false);
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab, transform, false);
obj.GetComponent<PropertyPanel>().Load(prop, target);
}
}

View File

@@ -33,7 +33,7 @@ namespace Cryville.Crtr.Browsing {
if (prop.PropertyType == typeof(bool)) vp = m_bool;
else if (prop.PropertyType == typeof(float) || prop.PropertyType == typeof(int)) vp = m_number;
else return;
_value = GameObject.Instantiate(vp, _valueContainer).GetComponent<PropertyValuePanel>();
_value = GameObject.Instantiate(vp, _valueContainer, false).GetComponent<PropertyValuePanel>();
if (_value is PVPNumber) {
var t = (PVPNumber)_value;
t.IntegerMode = prop.PropertyType == typeof(int);

View File

@@ -59,11 +59,11 @@ namespace Cryville.Crtr.Browsing {
private void OnAddDialogClosed() {
if (_dialog.FileName == null) return;
if (ResourceManager.ImportItemFrom(_dialog.FileName)) {
Debug.Log("Import succeeded"); // TODO
CallHelper.ShowMessageBox("Import succeeded");
OnPathClicked(ResourceManager.CurrentDirectory.Length - 1);
}
else {
Debug.Log("Import failed"); // TODO
CallHelper.ShowMessageBox("Import failed");
}
}
}

View File

@@ -64,8 +64,8 @@ namespace Cryville.Crtr.Browsing {
_units[_slideDest + 1].SlideToRight();
}
public void Open(int id) {
SetDataSettings(id);
public void Open(int id, ChartDetail detail) {
SetDataSettings(id, detail);
#if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Play", LoadSceneMode.Additive);
#else
@@ -74,8 +74,8 @@ namespace Cryville.Crtr.Browsing {
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
}
public void OpenConfig(int id) {
SetDataSettings(id);
public void OpenConfig(int id, ChartDetail detail) {
SetDataSettings(id, detail);
#if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Config", LoadSceneMode.Additive);
#else
@@ -84,9 +84,9 @@ namespace Cryville.Crtr.Browsing {
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
}
void SetDataSettings(int id) {
Settings.Default.LoadRuleset = "key/.umgr";
Settings.Default.LoadSkin = "key/0/.umgs";
void SetDataSettings(int id, ChartDetail detail) {
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
Settings.Default.LoadSkin = detail.Meta.ruleset + "/Old KeyUI/.umgs";
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
}
}

View File

@@ -12,6 +12,10 @@ namespace Cryville.Crtr.Browsing {
Name = StringUtils.EscapeFileName(name);
}
public string Name { get; private set; }
public abstract bool Valid { get; }
public override string ToString() {
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
}
}
public class ChartResource : Resource {
public ChartResource(string name, Chart main, ChartMeta meta) : base(name) {
@@ -19,17 +23,20 @@ namespace Cryville.Crtr.Browsing {
}
public Chart Main { get; private set; }
public ChartMeta Meta { get; private set; }
public override bool Valid { get { return true; } }
}
public class CoverResource : Resource {
public CoverResource(string name, FileInfo src) : base(name) {
Source = src;
}
public FileInfo Source { get; private set; }
public override bool Valid { get { return Source.Exists; } }
}
public class SongResource : Resource {
public SongResource(string name, FileInfo src) : base(name) {
Source = src;
}
public FileInfo Source { get; private set; }
public override bool Valid { get { return Source.Exists; } }
}
}

View File

@@ -1,4 +1,3 @@
//#define NO_THREAD
#define BUILD
using Cryville.Common;
@@ -74,9 +73,7 @@ namespace Cryville.Crtr {
}
public void Dispose() {
#if !NO_THREAD
if (loadThread != null) loadThread.Abort();
#endif
if (texLoader != null) texLoader.Dispose();
}
@@ -107,8 +104,12 @@ namespace Cryville.Crtr {
bool firstFrame;
double atime0;
void Update() {
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
if (started) {
if (started) GameUpdate();
else if (loadThread != null) LoadUpdate();
if (logEnabled) LogUpdate();
else Game.MainLogger.Enumerate((level, module, msg) => { });
}
void GameUpdate() {
try {
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
throw new InvalidOperationException("Window resized while playing");
@@ -144,8 +145,7 @@ namespace Cryville.Crtr {
Stop();
}
}
#if !NO_THREAD
else if (loadThread != null) {
void LoadUpdate() {
if (texLoader != null) {
string url = texLoader.url;
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
@@ -203,8 +203,8 @@ namespace Cryville.Crtr {
}
}
}
#endif
if (logEnabled) {
string timetext = string.Empty;
void LogUpdate() {
string _logs = logs.text;
Game.MainLogger.Enumerate((level, module, msg) => {
string color;
@@ -239,19 +239,19 @@ namespace Cryville.Crtr {
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
#endif
);
if (started) sttext += string.Format(
sttext += timetext;
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
status.text = sttext;
}
void OnCameraPostRender(Camera cam) {
if (started) timetext = string.Format(
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
cbus.Time,
Game.AudioClient.Position - atime0,
inputProxy.GetTimestampAverage()
);
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
status.text = sttext;
else timetext = string.Empty;
}
else {
Game.MainLogger.Enumerate((level, module, msg) => { });
}
}
#endregion
#region Triggers
@@ -303,12 +303,12 @@ namespace Cryville.Crtr {
startOffset = Settings.Default.StartOffset;
sv = Settings.Default.ScrollVelocity;
firstFrame = true;
#if !NO_THREAD
texloaddone = false;
#endif
Game.NetworkTaskWorker.SuspendBackgroundTasks();
Game.AudioSession = Game.AudioSequencer.NewSession();
Camera.onPostRender += OnCameraPostRender;
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
float dist;
@@ -331,23 +331,12 @@ namespace Cryville.Crtr {
FileInfo skinFile = new FileInfo(
Game.GameDataPath + "/skins/" + Settings.Default.LoadSkin
);
#if NO_THREAD
texloadtimer.Stop();
Logger.LogFormat("main", 0, "Load/MainThread", "Textures loaded successfully ({0}ms)", texloadtimer.Elapsed.TotalMilliseconds);
Load(new LoadInfo(){
chartFile = chartFile,
rulesetFile = rulesetFile,
skinFile = skinFile,
});
Prehandle();
#else
loadThread = new Thread(new ParameterizedThreadStart(Load));
loadThread.Start(new LoadInfo() {
chartFile = chartFile,
rulesetFile = rulesetFile,
skinFile = skinFile,
});
#endif
Logger.Log("main", 0, "Load/MainThread", "Loading textures...");
texloadtimer = new diag::Stopwatch();
@@ -355,15 +344,7 @@ namespace Cryville.Crtr {
texs = new Dictionary<string, Texture2D>();
var flist = skinFile.Directory.GetFiles("*.png");
foreach (FileInfo f in flist) {
#if NO_THREAD
using (WWW w = new WWW("file:///" + f.FullName)) {
string name = StringUtils.TrimExt(f.Name);
while (!w.isDone);
texs.Add(name, w.texture);
}
#else
texLoadQueue.Enqueue(f.FullName);
#endif
}
}
@@ -430,6 +411,7 @@ namespace Cryville.Crtr {
if (nbus != null) nbus.Dispose();
inputProxy.Deactivate();
foreach (var t in texs) Texture.Destroy(t.Value);
Camera.onPostRender -= OnCameraPostRender;
Logger.Log("main", 1, "Game", "Stopped");
}
catch (Exception ex) {

View File

@@ -3,6 +3,16 @@ using UnityEngine.SceneManagement;
namespace Cryville.Crtr.Config {
public class ConfigScene : MonoBehaviour {
[SerializeField]
Transform m_content;
public void SwitchCategory(GameObject cat) {
foreach (Transform c in m_content) {
c.gameObject.SetActive(false);
}
cat.SetActive(true);
}
public void ReturnToMenu() {
GameObject.Find("Master").GetComponent<Master>().ShowMenu();
#if UNITY_5_5_OR_NEWER

View File

@@ -66,8 +66,7 @@ namespace Cryville.Crtr.Config {
ruleset.LoadPdt(dir);
_proxy = new InputProxy(ruleset.Root, null);
foreach (var i in ruleset.Root.inputs) {
var e = GameObject.Instantiate(m_prefabInputConfigEntry).GetComponent<InputConfigEntry>();
e.transform.SetParent(m_entryList.transform);
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigEntry>();
_entries.Add(i.Key, e);
e.SetKey(this, i.Key);
}
@@ -92,8 +91,7 @@ namespace Cryville.Crtr.Config {
void AddSourceItem(InputSource? src) {
if (_recvsrcs.Contains(src)) return;
_recvsrcs.Add(src);
var obj = Instantiate(m_prefabListItem);
obj.transform.SetParent(m_deviceList);
var obj = Instantiate(m_prefabListItem, m_deviceList);
obj.transform.Find("Text").GetComponent<Text>().text = src == null ? "None" : src.Value.Handler.GetTypeName(src.Value.Type);
var btn = obj.GetComponent<Button>();
if (src != null) btn.interactable = !_proxy.IsUsed(src.Value);

View File

@@ -2,6 +2,7 @@ using Cryville.Crtr.Browsing;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -21,19 +22,25 @@ namespace Cryville.Crtr.Extensions.Malody {
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
}
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
if (src.meta.mode_ext.column != 4) throw new NotImplementedException("The key count is not supported");
var ruleset = "malody!" + MODES[src.meta.mode];
if (src.meta.mode == 0) {
ruleset += "." + src.meta.mode_ext.column.ToString(CultureInfo.InvariantCulture) + "k";
}
ChartMeta meta = new ChartMeta() {
song = new ChartMeta.MetaInfo() {
name = src.meta.song.titleorg != null ? src.meta.song.titleorg : src.meta.song.title,
author = src.meta.song.artistorg != null ? src.meta.song.artistorg : src.meta.song.artist,
},
ruleset = "malody!" + MODES[src.meta.mode],
ruleset = ruleset,
};
Chart chart = new Chart {
format = 2,
time = new BeatTime(-4, 0, 1),
ruleset = "malody!" + MODES[src.meta.mode],
ruleset = ruleset,
sigs = new List<Chart.Signature>(),
sounds = new List<Chart.Sound>(),
motions = new List<Chart.Motion>(),
@@ -68,7 +75,7 @@ namespace Cryville.Crtr.Extensions.Malody {
float pbeat = 0f, ctime = 0f;
int[] endbeat = new int[] { 0, 0, 1 };
foreach (var ev in events) {
float cbeat = bp(ev.beat);
float cbeat = ConvertBeat(ev.beat);
ctime += baseBpm == null ? 0 : (cbeat - pbeat) / baseBpm.Value * 60f;
pbeat = cbeat;
if (ev is MalodyChart.Time) {
@@ -105,7 +112,7 @@ namespace Cryville.Crtr.Extensions.Malody {
else throw new NotImplementedException();
}
else {
if (bp(tev.beat) > bp(endbeat)) endbeat = tev.beat;
if (ConvertBeat(tev.beat) > ConvertBeat(endbeat)) endbeat = tev.beat;
var rn = new Chart.Note() {
time = new BeatTime(tev.beat[0], tev.beat[1], tev.beat[2]),
motions = new List<Chart.Motion> {
@@ -113,7 +120,7 @@ namespace Cryville.Crtr.Extensions.Malody {
},
};
if (tev.endbeat != null) {
if (bp(tev.endbeat) > bp(endbeat)) endbeat = tev.endbeat;
if (ConvertBeat(tev.endbeat) > ConvertBeat(endbeat)) endbeat = tev.endbeat;
rn.endtime = new BeatTime(tev.endbeat[0], tev.endbeat[1], tev.endbeat[2]);
longEvents.Add(ev, new StartEventState {
Destination = rn,
@@ -152,7 +159,7 @@ namespace Cryville.Crtr.Extensions.Malody {
public ChartEvent Destination { get; set; }
}
float bp(int[] beat) {
float ConvertBeat(int[] beat) {
return beat[0] + (float)beat[1] / beat[2];
}
}

View File

@@ -43,8 +43,10 @@ namespace Cryville.Crtr {
if (_use[proxy.Target] > 0)
throw new InvalidOperationException("Input already assigned");
if (proxy.Source != null) {
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
proxy.Source.Value.Handler.OnInput += OnInput;
if (_judge != null) {
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
proxy.Source.Value.Handler.OnInput += OnInput;
}
_tproxies.Add(proxy.Target, proxy);
_sproxies.Add(proxy.Source.Value, proxy);
IncrementUseRecursive(name);
@@ -53,7 +55,7 @@ namespace Cryville.Crtr {
}
void Remove(InputProxyEntry proxy) {
var name = proxy.Target;
proxy.Source.Value.Handler.OnInput -= OnInput;
if (_judge != null) _tproxies[name].Source.Value.Handler.OnInput -= OnInput;
_sproxies.Remove(_tproxies[name].Source.Value);
_tproxies.Remove(name);
DecrementUseRecursive(name);

View File

@@ -85,6 +85,19 @@ namespace Cryville.Crtr {
}
return ~num;
}
int BinarySearchFirst(List<JudgeEvent> list, float time, int stack) {
if (list[0].Definition.stack == stack && list[0].StartClip == time) return 0;
int num = 0;
int num2 = list.Count - 1;
while (num <= num2) {
int num3 = num + (num2 - num >> 1);
int num4 = -list[num3].Definition.stack.CompareTo(stack);
if (num4 == 0) num4 = list[num3].StartClip.CompareTo(time);
if (num4 >= 0) num2 = num3 - 1;
else num = num3 + 1;
}
return num + 1;
}
public void Feed(Identifier target, float ft, float tt) {
Forward(target, tt);
var actlist = activeEvs[target];
@@ -103,8 +116,11 @@ namespace Cryville.Crtr {
if (def.scores != null) UpdateScore(def.scores);
if (def.pass != null) Pass(def.pass);
actlist.RemoveAt(index);
index = BinarySearch(actlist, ev.StartClip, def.prop);
if (index < 0) index = ~index;
if (def.stack != def.prop && actlist.Count > 0) {
index = BinarySearchFirst(actlist, ev.StartClip, def.prop);
if (index < 0) index = ~index;
}
else index++;
}
else index++;
}
@@ -150,10 +166,12 @@ namespace Cryville.Crtr {
var key = scoreop.Key;
_etor.ContextSelfValue = scoreSrcs[key.name.Key];
_etor.Evaluate(scoreOps[key.name.Key], scoreop.Value);
scoreSrcs[key.name.Key].Invalidate();
foreach (var s in _rs.scores) {
if (s.Value.value != null) {
_etor.ContextSelfValue = scoreSrcs[s.Key.Key];
_etor.Evaluate(scoreOps[s.Key.Key], s.Value.value);
scoreSrcs[s.Key.Key].Invalidate();
}
}
}

View File

@@ -6,11 +6,13 @@ namespace Cryville.Crtr {
public class Menu : MonoBehaviour {
#pragma warning disable IDE0044
[SerializeField]
private ResourceBrowserMaster m_browserMaster;
ResourceBrowserMaster m_browserMaster;
[SerializeField]
private Animator m_targetAnimator;
Animator m_targetAnimator;
[SerializeField]
private ProgressBar m_progressBar;
ProgressBar m_progressBar;
[SerializeField]
SettingsPanel m_settingsPanel;
#pragma warning restore IDE0044
bool initialized = false;
@@ -19,6 +21,7 @@ namespace Cryville.Crtr {
void Awake() {
Game.Init();
transform.parent.Find("Canvas/Contents").gameObject.SetActive(true);
m_settingsPanel.Target = Settings.Default;
}
void Update() {
if (!initialized) {

View File

@@ -146,6 +146,8 @@ namespace Cryville.Crtr {
_ctxops.Add(IdentifierManager.SharedInstance.Request("attack_timing"), new func_attack_timing(cccb));
_ctxops.Add(IdentifierManager.SharedInstance.Request("enter_timing"), new func_enter_timing(cccb));
_ctxops.Add(IdentifierManager.SharedInstance.Request("release_timing"), new func_release_timing(cccb));
_ctxops.Add(IdentifierManager.SharedInstance.Request("leave_timing"), new func_leave_timing(cccb));
_ctxops.Add(IdentifierManager.SharedInstance.Request("contact_timing"), new func_contact_timing(cccb));
}
static PdtEvaluator() {
_shortops.Add(new PdtOperatorSignature("@", 2), new op_at_2());
@@ -507,6 +509,22 @@ namespace Cryville.Crtr {
return ft > t0 && ft <= t1;
}
}
class func_leave_timing : JudgeFunction {
public func_leave_timing(Func<int, PropSrc> ctxcb) : base(1, ctxcb) { }
protected override bool ExecuteImpl(float fn, float tn, float ft, float tt, Vector3? fv, Vector3? tv) {
if (fv == null || tv == null) return false;
var t1 = GetOperand(0).AsNumber() + tn;
return ft < t1 && tt >= t1;
}
}
class func_contact_timing : JudgeFunction {
public func_contact_timing(Func<int, PropSrc> ctxcb) : base(2, ctxcb) { }
protected override bool ExecuteImpl(float fn, float tn, float ft, float tt, Vector3? fv, Vector3? tv) {
var t0 = GetOperand(0).AsNumber() + fn;
var t1 = GetOperand(1).AsNumber() + tn;
return (fv == null || ft < t1) && (tv == null || tt >= t0);
}
}
#endregion
unsafe static class oputil {
public static float AsNumber(PropSrc src) {

View File

@@ -6,6 +6,7 @@ namespace Cryville.Crtr {
public abstract class PropSrc {
int _type;
byte[] _buf = null;
public void Invalidate() { _buf = null; }
public void Get(out int type, out byte[] value) {
if (_buf == null) InternalGet(out _type, out _buf);
type = _type;

View File

@@ -7,30 +7,41 @@ using UnityEngine;
namespace Cryville.Crtr {
public class SettingsPanel : MonoBehaviour {
[SerializeField]
private GameObject m_categoryPrefab;
GameObject m_categoryPrefab;
private Transform _container;
[SerializeField]
Transform m_container;
#pragma warning disable IDE0051
void Awake() {
_container = transform.Find("Content/__content__");
}
public void Start() {
LoadProperties();
foreach (Transform c in _container) GameObject.Destroy(c.gameObject);
foreach (var c in _categories) {
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab);
obj.transform.SetParent(_container, false);
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Settings.Default);
bool _invalidated = true;
object m_target;
public object Target {
get {
return m_target;
}
set {
if (m_target != value) {
m_target = value;
_invalidated = true;
}
}
}
#pragma warning restore IDE0051
Dictionary<string, List<PropertyInfo>> _categories = null;
public void Update() {
if (!_invalidated) return;
LoadProperties();
foreach (Transform c in m_container) GameObject.Destroy(c.gameObject);
foreach (var c in _categories) {
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab, m_container, false);
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Target);
}
}
Dictionary<string, List<PropertyInfo>> _categories = new Dictionary<string, List<PropertyInfo>>();
public void LoadProperties() {
if (_categories != null) return;
_categories = new Dictionary<string, List<PropertyInfo>>();
foreach (var p in typeof(Settings).GetProperties()) {
_categories.Clear();
_invalidated = false;
if (Target == null) return;
foreach (var p in Target.GetType().GetProperties()) {
bool browsable = true;
string category = "miscellaneous";
foreach (var attr in p.GetCustomAttributes(true)) {

Binary file not shown.