You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
968 B
C#
30 lines
968 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UniLinq;
|
|
using UnityEngine;
|
|
|
|
namespace ConformalDecals.Tweakables {
|
|
public class TweakableDataCollection : IEnumerable<TweakableData>, ISerializationCallbackReceiver {
|
|
public readonly Dictionary<string, TweakableData> tweakables = new Dictionary<string, TweakableData>();
|
|
|
|
[SerializeField] private TweakableData[] _serializedTweakables;
|
|
|
|
public IEnumerator<TweakableData> GetEnumerator() {
|
|
return tweakables.Values.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() {
|
|
return GetEnumerator();
|
|
}
|
|
|
|
public void OnBeforeSerialize() {
|
|
_serializedTweakables = tweakables.Values.ToArray();
|
|
}
|
|
|
|
public void OnAfterDeserialize() {
|
|
foreach (var tweakable in _serializedTweakables) {
|
|
tweakables.Add(tweakable.name, tweakable);
|
|
}
|
|
}
|
|
}
|
|
} |