public override void gaxb_init() { gameObject = new GameObject("<ClearButton/>", typeof(RectTransform)); canvasRenderer = gameObject.AddComponent <CanvasRenderer> (); graphic = gameObject.AddComponent <InvisibleHitGraphic> (); #if !UNITY_4_6 graphic.color = Color.clear; #endif button = gameObject.AddComponent <Button> (); PlanetUnityButtonHelper.SetOnTouchUp(this, button, onTouchUp); PlanetUnityButtonHelper.SetOnTouchDown(this, button, null); }
public override void gaxb_complete() { // 0) create a content game object to place all of our children into contentObject = new GameObject("ScrollRectContent", typeof(RectTransform)); for (int i = gameObject.transform.childCount - 1; i >= 0; i--) { Transform t = gameObject.transform.GetChild(i); t.SetParent(contentObject.transform, false); } contentObject.transform.SetParent(gameObject.transform, false); contentObject.layer = LayerMask.NameToLayer("UI"); // 1) point the scroll rect at our content object scroll.content = (RectTransform)contentObject.transform; // 2) set the size of the contentObject to the largest rect containing all of our children CalculateContentSize(); // 3) fix the position of the contentObject so it the scroll is at the top... RectTransform myRectTransform = (RectTransform)contentObject.transform; myRectTransform.pivot = new Vector2(0, 1); myRectTransform.anchorMin = myRectTransform.anchorMax = new Vector2(0, 1); myRectTransform.anchoredPosition = Vector2.zero; if (gameObject.GetComponent <Graphic> () == null) { InvisibleHitGraphic invisibleHitGraphic = gameObject.AddComponent <InvisibleHitGraphic> (); #if !UNITY_4_6 invisibleHitGraphic.color = Color.clear; #endif } base.gaxb_complete(); }