public static T AddComponent <T>(this GameObject o, ActionContainer ctor) where T : Component { bool a = o.activeSelf; o.SetActive(false); T c = o.AddComponent <T>(); object[] prms = new object[ctor.args.Length]; for (int ai = 0; ai < ctor.args.Length; ai++) { if (ctor.args[ai] != typeof(T)) { prms[ai] = o.GetComponentOrThis(ctor.args[ai]); } else { prms[ai] = c; } } ctor.DynamicInvoke(prms); o.SetActive(a); return(c); }
public static GameObject Dissolve(this GameObject o, ActionContainer i) { var prms = new object[i.args.Length]; for (int ai = 0; ai < i.args.Length; ai++) { prms[ai] = o.GetComponentOrThis(i.args[ai]); } i.DynamicInvoke(prms); return(o); }