public override void LoadIntoPUGameObject(PUScrollRect parent, object data) { base.LoadIntoPUGameObject(parent, data); if (puGameObject.rectTransform.rect.width == 0) { if (IsHeader()) { puGameObject.rectTransform.sizeDelta = simpleTable.headerSize.Value; } else { puGameObject.rectTransform.sizeDelta = simpleTable.cellSize.Value; } } }
public virtual void LoadIntoPUGameObject(PUScrollRect parent, object data) { scrollRect = parent; cellData = data; string xmlPath = XmlPath(); if (xmlPath != null) { puGameObject = (PUGameObject)PlanetUnity2.loadXML(PlanetUnityResourceCache.GetAsset <TextAsset>(xmlPath).bytes, parent.contentObject, null); // 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); } } else { puGameObject = new PUGameObject(); puGameObject.SetFrame(0, 0, 0, 60, 0, 0, "bottom,left"); puGameObject.LoadIntoPUGameObject(parent); puGameObject.gameObject.transform.SetParent(parent.contentObject.transform, false); } puGameObject.parent = table; // 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(scrollRect.Scope(), name, args); }); cellGameObject = puGameObject.gameObject; cellTransform = cellGameObject.transform as RectTransform; tableTransform = scrollRect.rectTransform; tableContentTransform = scrollRect.contentObject.transform as RectTransform; UpdateContents(); }
public virtual void LoadIntoPUGameObject(PUScrollRect parent, object data) { scrollRect = parent; cellData = data; string xmlPath = XmlPath (); if (xmlPath != null) { puGameObject = (PUGameObject)PlanetUnity2.loadXML (PlanetUnityOverride.xmlFromPath (xmlPath), parent.contentObject, null); // 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); } } else { puGameObject = new PUGameObject (); puGameObject.SetFrame (0, 0, 0, 60, 0, 0, "bottom,stretch"); puGameObject.LoadIntoPUGameObject (parent); puGameObject.gameObject.transform.SetParent(parent.contentObject.transform, false); } if (IsHeader () && this is PUSimpleTableCell == false) { PUTableHeaderScript script = (PUTableHeaderScript)puGameObject.gameObject.AddComponent (typeof(PUTableHeaderScript)); script.table = table; script.tableCell = this; } puGameObject.parent = table; // 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(scrollRect.Scope(), name, args); }); cellGameObject = puGameObject.gameObject; cellTransform = cellGameObject.transform as RectTransform; tableTransform = scrollRect.rectTransform; tableContentTransform = scrollRect.contentObject.transform as RectTransform; UpdateContents (); }