10using System.Collections.Generic;
27 public abstract class MultiTypedReference<BaseType> where BaseType : class {
29 public abstract BaseType
Value {
get;
set; }
32 public static class MultiTypedReferenceUtil {
35 public const string ID_NAME_TABLE =
"abcdefghijklmnopqrstuvwxyz";
37 public static SerializedProperty GetReferenceProperty(SerializedProperty property) {
38 var indexProp =
property.FindPropertyRelative(
"_index");
39 int indexValue = indexProp.intValue;
40 if (indexValue == -1) {
44 string listPropName =
"_" + ID_NAME_TABLE[indexValue];
45 var listProp =
property.FindPropertyRelative(listPropName);
46 return listProp.GetArrayElementAtIndex(0);
51 public class MultiTypedReference<BaseType,
A,
B> : MultiTypedReference<BaseType>
52 where BaseType : class
60 private List<A> _a =
new List<A>();
63 private List<B> _b =
new List<B>();
80 public sealed
override BaseType
Value {
105 throw new Exception(
"Invalid index " +
_index);
112 }
else if (obj is
A) {
115 }
else if (obj is
B) {
119 throw new ArgumentException(
"The type " + obj.GetType().Name +
" is not supported by this reference.");
125 where BaseType : class
131 private List<C> _c =
new List<C>();
145 return base.internalGet();
154 base.internalSetAfterClear(obj);
160 where BaseType : class
167 private List<D> _d =
new List<D>();
181 return base.internalGet();
190 base.internalSetAfterClear(obj);
Represents a single reference to a value of type BaseType.
virtual BaseType internalGet()
override void internalSetAfterClear(BaseType obj)
virtual void internalSetAfterClear(BaseType obj)
override BaseType internalGet()