private void AddEffect() { if (m_effectsList == null) { return; } //init effect list & fetch effect based on selected index if (m_ActiveEffects == null) { m_ActiveEffects = new List <SerializedObject>(); } AbstractEffect currentEffect = m_effectsList[m_selectedEffectIndex]; //init serialized object list & add new serialized object if (m_serializedObjects == null) { m_serializedObjects = new List <SerializedObject>(); } SerializedObject currentSObj = new SerializedObject(currentEffect); m_serializedObjects.Add(currentSObj); m_ActiveEffects.Add(currentSObj); //Store serialized object & effect in a dictionary if (m_SerializedObject_effectMap == null) { m_SerializedObject_effectMap = new Dictionary <SerializedObject, AbstractEffect>(); } m_SerializedObject_effectMap.Add(currentSObj, currentEffect); //store properties in a dictionary, also set execution order if (m_indexProperty_map == null) { m_indexProperty_map = new Dictionary <int, List <SerializedProperty> >(); } FieldInfo[] fieldInfo; fieldInfo = currentEffect.GetType().GetFields(); List <SerializedProperty> tempList = new List <SerializedProperty>(); foreach (FieldInfo info in fieldInfo) { SerializedProperty tempProperty = currentSObj.FindProperty(info.Name); if (info.Name == "ExecutionOrder") { tempProperty.intValue = m_executionOrder; } if (info.Name == "ID") { tempProperty.intValue = m_executionOrder; } tempList.Add(tempProperty); } currentSObj.ApplyModifiedProperties(); m_indexProperty_map.Add(m_executionOrder, tempList); m_executionOrder++; }
public bool manages(AbstractEffect c) { return(c.GetType() == effect.GetType()); }