public virtual void LoadIntoPUGameObject(PUTable parent, object data, int baseRenderQueue) { table = parent; cellData = data; puGameObject = (PUGameObject)PlanetUnity.loadXML (PlanetUnityOverride.xmlFromPath(XmlPath ()), parent, NotificationCenter.Args ("baseRenderQueue", baseRenderQueue)); // Attach all of the PlanetUnity objects try { FieldInfo field = this.GetType ().GetField ("scene"); if (field != null) { field.SetValue (this, puGameObject); } puGameObject.performOnChildren (val => { PUGameObject oo = val as PUGameObject; if (oo != null && oo.title != null) { field = this.GetType ().GetField (oo.title); if (field != null) { field.SetValue (this, oo); } } return true; }); } catch (Exception e) { UnityEngine.Debug.Log ("TableCell error: " + e); } try { // Attach all of the named GameObjects FieldInfo[] fields = this.GetType ().GetFields (); foreach (FieldInfo field in fields) { if (field.FieldType == typeof(GameObject)) { GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll (typeof(GameObject)); foreach (GameObject pObject in pAllObjects) { if (pObject.name.Equals (field.Name)) { field.SetValue (this, pObject); } } } } } catch (Exception e) { UnityEngine.Debug.Log ("TableCell error: " + e); } if (IsHeader ()) { PUTableHeaderScript script = (PUTableHeaderScript)puGameObject.gameObject.AddComponent (typeof(PUTableHeaderScript)); script.table = table; script.tableCell = this; } // We want to bridge all notifications to my scope; this allows developers to handle notifications // at the table cell level, or at the scene controller level, with ease NotificationCenter.addObserver (this, "*", puGameObject, (args,name) => { NotificationCenter.postNotification(table.scope(), name, args); }); }