public void Load(SaveData data) { string origPrefix = data.Prefix; // save original Prefix before editing it ClearEffects(); int count = int.Parse(data.Get("count")); for (int i = 0; i < count; i++) { data.Prefix = origPrefix + "effect_" + i + "_"; string typeName = data.Get("classType"); IEffect effect = null; Type type = Type.GetType(typeName); if (type.BaseType == typeof(ScriptableObject)) // need to call CreateInstance from ScriptableObject { effect = (IEffect)ScriptableObject.CreateInstance(type); } else { effect = (IEffect)Activator.CreateInstance(type); } effect.Load(data); AddEffect(effect); } }