Skip to content

Commit 6abd24e

Browse files
authored
fix multi-dim list (#24)
1 parent 2826db4 commit 6abd24e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityEngine;
5+
6+
namespace AnySerialize
7+
{
8+
[Serializable, AnySerializePriority(5000)]
9+
public class ReadOnlyAnyList<T, [AnyConstraintType] TAny> : IReadOnlyAny<List<T>> where TAny : IReadOnlyAny<T>
10+
{
11+
[SerializeField] private List<TAny> _value = default!;
12+
private List<T> _cache = new();
13+
public List<T> Value
14+
{
15+
get
16+
{
17+
#if !UNITY_EDITOR
18+
if (_cache.Count == _value.Count) return _cache;
19+
#endif
20+
_cache.Clear();
21+
_cache.AddRange(_value.Select(v => v.Value));
22+
return _cache;
23+
}
24+
}
25+
}
26+
}

Packages/com.quabug.any-serialize/Runtime/ReadOnlyAnyList.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.quabug.any-serialize/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.quabug.any-serialize",
33
"description": "Generate serializable code of any properties for Unity3D serializer",
4-
"version": "0.2.1",
4+
"version": "0.2.2",
55
"unity": "2021.3",
66
"displayName": "AnySerialize",
77
"type": "library",

0 commit comments

Comments
 (0)