public static GameObject CreateDropdown(Transform aParent) { var go = DefaultControls.CreateDropdown(GetStandardResources()); go.transform.SetParent(aParent); return(go); }
public static Dropdown CreateDropdown(string objectName = "New Dropdown", Transform parent = null, string label = "Label") { GameObject go = DefaultControls.CreateDropdown(resources); go.name = objectName; foreach (Text text in go.GetComponentsInChildren <Text>(true)) { text.font = defaultFont; text.resizeTextForBestFit = true; text.resizeTextMinSize = 2; text.resizeTextMaxSize = 100; text.alignment = TextAnchor.MiddleLeft; if (text.name.Equals("Label")) { text.rectTransform.SetRect(Vector2.zero, Vector2.one, new Vector2(10f, 6f), new Vector2(-25f, -7f)); } else { text.rectTransform.SetRect(Vector2.zero, Vector2.one, new Vector2(20f, 1f), new Vector2(-10f, -2f)); } } go.transform.SetParent(parent, false); return(go.GetComponent <Dropdown>()); }
static public void AddDropdown(MenuCommand menuCommand) { GameObject go; using (new FactorySwapToEditor()) go = DefaultControls.CreateDropdown(MenuOptions.GetStandardResources()); MenuOptions.PlaceUIElementRoot(go, menuCommand); }
static public void AddDropdown(MenuCommand menuCommand) { GameObject go = DefaultControls.CreateDropdown(GetStandardResources()); PlaceUIElementRoot(go, menuCommand); var Label = go.transform.Find("Label").GetComponent <Text>(); var Arrow = go.transform.Find("Arrow").GetComponent <Image>(); var Template = go.transform.Find("Template").GetComponent <Image>(); var Viewport = Template.transform.Find("Viewport").GetComponent <Image>(); var Item = Viewport.transform.Find("Content").transform.Find("Item").GetComponent <Toggle>(); var Item_Background = Item.transform.Find("Item Background").GetComponent <Image>(); var Item_Checkmark = Item.transform.Find("Item Checkmark").GetComponent <Image>(); var Item_Label = Item.transform.Find("Item Label").GetComponent <Text>(); Label.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Label.supportRichText = CustomizeUGUICreate.IsRich; Label.material = CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) : Label.material; Item_Label.material = CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Label.gameObject) : Item_Label.material; Item_Label.supportRichText = CustomizeUGUICreate.IsRich; Arrow.sprite = CustomizeUGUICreate.GetDefalutSprite(Arrow.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Arrow.gameObject) : Arrow.sprite; Arrow.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Arrow.material = CustomizeUGUICreate.GetDefalutMaterial(Arrow.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Arrow.gameObject) : Arrow.material; Template.sprite = CustomizeUGUICreate.GetDefalutSprite(Template.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Template.gameObject) : Arrow.sprite; Template.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Template.material = CustomizeUGUICreate.GetDefalutMaterial(Template.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Template.gameObject) : Template.material; Viewport.sprite = CustomizeUGUICreate.GetDefalutSprite(Viewport.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Viewport.gameObject) : Viewport.sprite; Viewport.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Viewport.material = CustomizeUGUICreate.GetDefalutMaterial(Viewport.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Viewport.gameObject) : Viewport.material; Item_Background.sprite = CustomizeUGUICreate.GetDefalutSprite(Item_Background.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Item_Background.gameObject) : Item_Background.sprite; Item_Background.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Item_Background.material = CustomizeUGUICreate.GetDefalutMaterial(Item_Background.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Background.gameObject) : Item_Background.material; Item_Checkmark.sprite = CustomizeUGUICreate.GetDefalutSprite(Item_Checkmark.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(Item_Checkmark.gameObject) : Item_Checkmark.sprite; Item_Checkmark.raycastTarget = CustomizeUGUICreate.IsRayCastTarget; Item_Checkmark.material = CustomizeUGUICreate.GetDefalutMaterial(Item_Checkmark.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(Item_Checkmark.gameObject) : Item_Checkmark.material; var goImage = go.GetComponent <Image>(); goImage.sprite = CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutSprite(goImage.gameObject) : goImage.sprite; goImage.material = CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) ? CustomizeUGUICreate.GetDefalutMaterial(goImage.gameObject) : goImage.material; }
public static int CreateDropdown_s(IntPtr l) { int result; try { DefaultControls.Resources resources; LuaObject.checkValueType <DefaultControls.Resources>(l, 1, out resources); GameObject o = DefaultControls.CreateDropdown(resources); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static Dropdown CreateDropdown(string objectName = "New Dropdown", Transform parent = null) { GameObject go = DefaultControls.CreateDropdown(resources); go.name = objectName; var texts = go.GetComponentsInChildren <Text>(true); for (var i = 0; i < texts.Length; i++) { Text text = texts[i]; text.font = defaultFont; text.resizeTextForBestFit = true; text.resizeTextMinSize = 2; text.resizeTextMaxSize = 100; text.alignment = TextAnchor.MiddleLeft; if (text.name.Equals("Label")) { text.rectTransform.SetRect(Vector2.zero, Vector2.one, new Vector2(10f, 6f), new Vector2(-25f, -7f)); } else { text.rectTransform.SetRect(Vector2.zero, Vector2.one, new Vector2(20f, 1f), new Vector2(-10f, -2f)); } } go.transform.SetParent(parent, false); var rects = go.GetComponentsInChildren <ScrollRect>(true); for (var i = 0; i < rects.Length; i++) { rects[i].scrollSensitivity = scrollSensitivity; } return(go.GetComponent <Dropdown>()); }
// More advanced controls below //[MenuItem("GameObject/UI/Dropdown", false, 2035)] static public void AddDropdown(MenuCommand menuCommand) { GameObject go = DefaultControls.CreateDropdown(GetStandardResources()); PlaceUIElementRoot(go, menuCommand); }