-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathReadOnlyClassValues.cs
More file actions
71 lines (61 loc) · 2.07 KB
/
Copy pathReadOnlyClassValues.cs
File metadata and controls
71 lines (61 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using UnityEngine;
namespace AnySerialize
{
[AnySerializable]
public class Class
{
public int Int;
public float Float;
public GenericClass<AnotherClass, int> GenericClass { get; }
public PlainClass PlainClass { get; }
public override string ToString()
{
return $"{nameof(Class)}: {nameof(Int)}={Int}, {nameof(Float)}={Float}, {nameof(GenericClass)}={GenericClass}, {nameof(PlainClass)}={PlainClass}";
}
}
[AnySerializable]
public class AnotherClass
{
[AnySerialize(typeof(AnyNullableClass<Class>))]
public Class ClassProperty { get; }
public int Value;
public override string ToString()
{
return $"{nameof(AnotherClass)}: {nameof(Value)}={Value}, {nameof(ClassProperty)}={(ClassProperty == null ? "null" : ClassProperty.ToString())}";
}
}
[AnySerializable]
public class GenericClass<T0, T1>
{
public T0 Field;
public T1 Property { get; }
public override string ToString()
{
return $"{nameof(GenericClass<T0, T1>)}<{typeof(T0)},{typeof(T1)}>: {nameof(Field)}={Field}, {nameof(Property)}={Property}";
}
}
[Serializable]
public class PlainClass
{
public int Int;
public float Float;
public double[] DoubleArray;
public override string ToString()
{
return $"PlainClass: {nameof(Int)}={Int}, {nameof(Float)}={Float}, {nameof(DoubleArray)}={string.Join(",", DoubleArray)}";
}
}
public class ReadOnlyClassValues : MonoBehaviour
{
[AnySerialize] public Class Foo { get; }
[AnySerialize] public GenericClass<int, long> GenericClass { get; }
[AnySerialize] public AnotherClass AnotherClass { get; }
[AnySerialize] public PlainClass Plain { get; }
[AnySerialize(typeof(AnyNullableClass<PlainClass>))] public PlainClass PlainNullable { get; }
private void Awake()
{
this.JsonLog();
}
}
}