Advertisement
Guest User

SerializableNestedList

a guest
Mar 14th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using UnityEngine;
  2. using System;
  3. using System.Linq;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6.  
  7. [Serializable]
  8. public class SerializableNestedList<T> : ScriptableObject
  9. {
  10.     [SerializeField]
  11.     private List<T> m_values = new List<T>();
  12.     public List<T> List
  13.     {
  14.         get { return m_values; }
  15.         private set { m_values = value; }
  16.     }
  17.  
  18.     public void OnEnable()
  19.     {
  20.         if (m_values == null)
  21.         {
  22.             m_values = new List<T>();
  23.         }
  24.     }
  25.  
  26.     public void Add(T value)
  27.     {
  28.         m_values.Add(value);
  29.     }
  30.  
  31.     public void Remove(T value)
  32.     {
  33.         m_values.Remove(value);
  34.     }
  35.  
  36.     public T this[int i]
  37.     {
  38.         get
  39.         {
  40.             return m_values[i];
  41.         }
  42.         set
  43.         {
  44.             m_values[i] = value;
  45.         }
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement