private static void CreateObject(string line) { Type type; switch (line.GetWord(0, " ")) { case PP.OBJECT_VARIABLE: type = typeof(Variable); break; case PP.OBJECT_TIMER: type = typeof(Timer); break; case PP.OBJECT_SOUND: type = typeof(SoundObj); break; default: // We have to include this for the compiler only, it's impossible to reach. type = typeof(object); break; } object obj = Activator.CreateInstance(type); List <KeyValuePair <string, string> > inputs = BreakLine(line); foreach (KeyValuePair <string, string> pair in inputs) { /*if (pair.Key == PP.PARAM_PATH) * { * ((SoundObj)obj).Sound = Resources.LoadAssetAtPath(pair.Value, typeof(AudioClip)) as AudioClip; * } * else * {*/ Debug.Log("Setting: " + pair.Key + " -> " + pair.Value); SetProperty(obj, pair.Key, pair.Value); //} } switch (line.GetWord(0, " ")) { case PP.OBJECT_VARIABLE: CurrentPhase.AddVariable((Variable)obj); break; case PP.OBJECT_TIMER: CurrentPhase.AddTimer((Timer)obj); break; case PP.OBJECT_SOUND: CurrentPhase.AddSound((SoundObj)obj); break; } }