static GameObject CreateSliderV(float startOffset = -15, float endOffset = -15) { var go = new GameObject("SliderV", typeof(HImage)); HImage image = go.GetComponent <HImage>(); image.SizeDelta = new Vector2(20, 400); image.compositeType = CompositeType.Slider; var rect = image.transform; var help = go.AddComponent <SliderHelper>(); help.StartOffset.y = startOffset; help.EndOffset.y = endOffset; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Sliced; var Fill = new GameObject("FillImage", typeof(HImage)); image = Fill.GetComponent <HImage>(); image.SizeDelta = new Vector2(20, 400); var son = image.transform; son.SetParent(rect); son.localPosition = Vector3.zero; son.localScale = Vector3.one; son.localRotation = Quaternion.identity; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Filled; image.FillMethod = FillMethod.Vertical; image.MainColor = new Color32(94, 137, 197, 255); var Nob = new GameObject("Nob", typeof(HImage)); image = Nob.GetComponent <HImage>(); image.SizeDelta = new Vector2(30, 30); son = image.transform; son.SetParent(rect); son.localPosition = new Vector3(0, 200 + startOffset, 0); son.localScale = Vector3.one; son.localRotation = Quaternion.identity; image.MainColor = Color.green; image.Sprite = EditorModelManager.FindSprite(icons, ufo); return(go); }
static GameObject CreateSliderH() { var go = new GameObject("SliderH", typeof(HImage)); var image = go.GetComponent <HImage>().Content; image.SizeDelta = new Vector2(400, 20); image.compositeType = CompositeType.Slider; var rect = go.transform; var help = go.AddComponent <SliderHelper>(); help.StartOffset.x = -15; help.EndOffset.x = -15; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Sliced; var Fill = new GameObject("FillImage", typeof(HImage)); image = Fill.GetComponent <HImage>().Content; image.SizeDelta = new Vector2(400, 20); var son = Fill.transform; son.SetParent(rect); son.localPosition = Vector3.zero; son.localScale = Vector3.one; son.localRotation = Quaternion.identity; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Filled; image.FillMethod = FillMethod.Horizontal; image.MainColor = new Color32(94, 137, 197, 255); var Nob = new GameObject("Nob", typeof(HImage)); image = Nob.GetComponent <HImage>().Content; image.SizeDelta = new Vector2(30, 30); son = Nob.transform; son.SetParent(rect); son.localPosition = new Vector3(200, 0, 0); son.localScale = Vector3.one; son.localRotation = Quaternion.identity; image.MainColor = Color.green; image.Sprite = EditorModelManager.FindSprite(icons, leaves); return(go); }
static public void AddScrollX(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; Transform pt = null; if (parent != null) { pt = parent.transform; } UIElement p = UICreator.CreateElement(Vector3.zero, new Vector2(400, 420), "Scroll", pt); var sl = UICreator.CreateHImage(Vector3.zero, new Vector2(400, 400), "ScrollX", p.transform); var scroll = sl.Content; scroll.marginType = MarginType.Margin; scroll.margin.down = 20; scroll.Mask = true; scroll.MainColor = new Color32(224, 224, 224, 255); scroll.eventType = HEventType.UserEvent; scroll.compositeType = CompositeType.ScrollX; scroll.Sprite = EditorModelManager.FindSprite(icons, background); scroll.SprType = SpriteType.Sliced; CreateItem(sl.transform, "Item"); var go = CreateSliderH(); if (parent != null) { var rect = go.transform; rect.SetParent(p.transform); rect.localPosition = new Vector3(200, 0, 0); rect.localScale = Vector3.one; rect.localRotation = Quaternion.identity; } var slider = go.GetComponent <UIElement>().Content; slider.anchorType = AnchorType.Alignment; slider.anchorPointType = AnchorPointType.Down; slider.marginType = MarginType.MarginX; var help = sl.gameObject.AddComponent <ScrollHelper>(); help.Slider = go.transform; }
static public UIElement AddScrollYExtand(UIElement parent) { var scroll = UICreator.CreateHImage(new Vector3(0, 400, 0), new Vector2(400, 800), "ScrollEx", parent); scroll.Mask = true; scroll.MainColor = new Color32(224, 224, 224, 255); scroll.eventType = HEventType.UserEvent; scroll.compositeType = CompositeType.ScrollYExtand; scroll.Sprite = EditorModelManager.FindSprite(icons, background); scroll.SprType = SpriteType.Sliced; scroll.Pivot = new Vector2(0.5f, 1); var bds = UICreator.CreateElement(Vector3.zero, new Vector2(400, 100), "Bodys", scroll); bds.anchorType = AnchorType.Alignment; bds.anchorPointType = AnchorPointType.Top; bds.marginType = MarginType.MarginX; bds.Pivot = new Vector2(0.5f, 1); bds = UICreator.CreateElement(Vector3.zero, new Vector2(400, 100), "Titles", scroll); bds.anchorType = AnchorType.Alignment; bds.anchorPointType = AnchorPointType.Top; bds.marginType = MarginType.MarginX; bds.Pivot = new Vector2(0.5f, 1); CreateItemE(scroll, "Title"); var item = CreateItemE(scroll, "Item"); item.localPosition = new Vector3(0, -100, 0); var tail = CreateItemE(scroll, "Tail"); tail.localPosition = new Vector3(0, -200, 0); var body = new UIElement();//new GameObject("Body"); body.name = "Body"; body.SetParent(scroll); body.localPosition = new Vector3(0, -300, 0); body.SizeDelta = new Vector2(400, 100); body.Pivot = new Vector2(0.5f, 1); body.Mask = true; return(scroll); }
static public UIElement AddRocker(UIElement parent) { var scr = new HImage();//ss.AddComponent<HImage>(); scr.name = "Rocker"; scr.SizeDelta = new Vector2(300, 300); scr.eventType = HEventType.UserEvent; scr.compositeType = CompositeType.Rocker; scr.Sprite = EditorModelManager.FindSprite(icons, circleol); scr.SetParent(parent); var Item = new HImage();//new GameObject("Nob"); Item.name = "Nob"; Item.SizeDelta = new Vector2(100, 100); Item.Sprite = EditorModelManager.FindSprite(icons, circlesm); Item.SetParent(scr); return(scr); }
static public void AddScroll(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; Transform pt = null; if (parent != null) { pt = parent.transform; } var scroll = UICreator.CreateHImage(Vector3.zero, new Vector2(400, 400), "gridScroll", pt); scroll.Mask = true; scroll.MainColor = new Color32(224, 224, 224, 255); scroll.eventType = huqiang.Core.HGUI.HEventType.UserEvent; scroll.compositeType = CompositeType.GridScroll; scroll.Sprite = EditorModelManager.FindSprite(icons, background); scroll.SprType = SpriteType.Sliced; CreateItem(scroll.transform, "Item"); }
static public void AddDesignedDockPanel(MenuCommand menuCommand) { var game = menuCommand.context as GameObject; Transform pt = null; if (game != null) { pt = game.transform; } var dock = CreateDockPanel(pt); dock.name = "DesignedDockPanel"; dock.compositeType = CompositeType.DesignedDockPanel; var drag = UICreator.CreateHImage(Vector3.zero, new Vector2(40, 40), "Drag", dock.transform); drag.Sprite = EditorModelManager.FindSprite(icons, file); CreateAuxiliary(dock.transform); }
static public void AddInputBox(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var go = new GameObject("InputBox", typeof(HImage)); var trans = go.transform; if (parent != null) { trans.SetParent(parent.transform); } trans.localPosition = Vector3.zero; trans.localScale = Vector3.one; trans.localRotation = Quaternion.identity; var img = go.GetComponent <HImage>().Content; img.Mask = true; img.compositeType = CompositeType.InputBox; img.Sprite = EditorModelManager.FindSprite(icons, box); img.SprType = SpriteType.Sliced; img.SizeDelta = new Vector2(400, 100); var help = go.AddComponent <TextInputHelper>(); go = new GameObject("InputText", typeof(TextBox)); var son = go.transform; son.SetParent(trans); son.localPosition = Vector3.zero; son.localScale = Vector3.one; son.localRotation = Quaternion.identity; var txt = go.GetComponent <HText>().Content; txt.SizeDelta = new Vector2(380, 90); txt.marginType = MarginType.Margin; txt.margin = new Margin(5, 5, 5, 5); UICreator.CreateHImage(Vector3.zero, new Vector2(2, 28), "Cursor", son); help.Refresh(); }
static public void AddScrollY(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; Transform pt = null; if (parent != null) { pt = parent.transform; } var scroll = UICreator.CreateHImage(Vector3.zero, new Vector2(400, 400), "ScrollY", pt); scroll.Mask = true; scroll.MainColor = new Color32(224, 224, 224, 255); scroll.eventType = huqiang.Core.HGUI.EventType.UserEvent; scroll.compositeType = CompositeType.ScrollY; scroll.Sprite = EditorModelManager.FindSprite(icons, background); scroll.SprType = SpriteType.Sliced; scroll.Pivot = new Vector2(0.5f, 1); var item = CreateItem(scroll.transform, "Item"); item.transform.localPosition = new Vector3(0, -200, 0); var slider = UICreator.CreateHImage(new Vector3(190, -200, 0), new Vector2(20, 400), "Slider", scroll.transform); slider.eventType = huqiang.Core.HGUI.EventType.UserEvent; slider.compositeType = CompositeType.Slider; slider.Sprite = scroll.Sprite; slider.SprType = SpriteType.Sliced; slider.MainColor = 0x295B7680.ToColor(); var help = slider.gameObject.AddComponent <SliderHelper>(); help.direction = UISlider.Direction.Vertical; var Nob = UICreator.CreateHImage(new Vector3(0, 185, 0), new Vector2(20, 30), "Nob", slider.transform); Nob.MainColor = 0x5F5263ff.ToColor(); Nob.Sprite = EditorModelManager.FindSprite(icons, background); Nob.SprType = SpriteType.Sliced; }
static UIElement CreateSliderV(float startOffset = -15, float endOffset = -15) { HImage image = new HImage(); image.name = "SliderV"; image.SizeDelta = new Vector2(20, 400); image.compositeType = CompositeType.Slider; //var help = go.AddComponent<SliderHelper>(); //help.StartOffset.y = startOffset; //help.EndOffset.y = endOffset; //help.direction = huqiang.UIComposite.UISlider.Direction.Vertical; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Sliced; var Fill = new HImage(); Fill.name = "FillImage"; Fill.SizeDelta = new Vector2(20, 400); Fill.SetParent(image); Fill.localPosition = Vector3.zero; Fill.localScale = Vector3.one; Fill.localRotation = Quaternion.identity; Fill.Sprite = EditorModelManager.FindSprite(icons, background); Fill.SprType = SpriteType.Filled; Fill.FillMethod = FillMethod.Vertical; Fill.MainColor = new Color32(94, 137, 197, 255); var Nob = new HImage(); Nob.name = "Nob"; Nob.SizeDelta = new Vector2(30, 30); Nob.SetParent(image); Nob.localPosition = new Vector3(0, 200 + startOffset, 0); Nob.localScale = Vector3.one; Nob.localRotation = Quaternion.identity; image.MainColor = Color.green; image.Sprite = EditorModelManager.FindSprite(icons, ufo); return(image); }
static UIElement CreateSliderH() { var image = new HImage(); image.name = "SliderH"; image.SizeDelta = new Vector2(400, 20); image.compositeType = CompositeType.Slider; //var help = image.AddComponent<SliderHelper>(); //help.StartOffset.x = -15; //help.EndOffset.x = -15; image.Sprite = EditorModelManager.FindSprite(icons, background); image.SprType = SpriteType.Sliced; var Fill = new HImage(); Fill.name = "FillImage"; Fill.SizeDelta = new Vector2(400, 20); Fill.SetParent(image); Fill.localPosition = Vector3.zero; Fill.localScale = Vector3.one; Fill.localRotation = Quaternion.identity; Fill.Sprite = EditorModelManager.FindSprite(icons, background); Fill.SprType = SpriteType.Filled; Fill.FillMethod = FillMethod.Horizontal; Fill.MainColor = new Color32(94, 137, 197, 255); var Nob = new HImage(); Nob.name = "Nob"; Nob.SizeDelta = new Vector2(30, 30); Nob.SetParent(image); Nob.localPosition = new Vector3(200, 0, 0); Nob.localScale = Vector3.one; Nob.localRotation = Quaternion.identity; image.MainColor = Color.green; image.Sprite = EditorModelManager.FindSprite(icons, leaves); return(image); }
static UIElement CreateItemE(Transform parent, string name) { var mod = UICreator.CreateElement(Vector3.zero, new Vector2(400, 100), name, parent); mod.Pivot = new Vector2(0.5f, 1); var img = UICreator.CreateHImage(Vector3.zero, new Vector2(400, 90), "Image", mod.transform); img.Pivot = new Vector2(0.5f, 1); img.MainColor = new Color32(68, 68, 68, 255); img.eventType = huqiang.Core.HGUI.HEventType.UserEvent; img.Sprite = EditorModelManager.FindSprite(icons, background); img.SprType = SpriteType.Sliced; var txt = UICreator.CreateHText(Vector3.zero, new Vector2(400, 80), "Text", mod.transform); txt.Pivot = new Vector2(0.5f, 1); txt.Text = name; txt.FontSize = 30; txt.TextAnchor = TextAnchor.MiddleLeft; return(mod); }
static public void AddDesignedDockPanel(MenuCommand menuCommand) { var game = menuCommand.context as GameObject; if (game == null) { return; } var obj = CreateDockPanel(game); CreateAuxiliary(obj); var Drag = new GameObject("Drag", typeof(RectTransform), typeof(Image)); var st = Drag.transform as RectTransform; st.SetParent(obj.transform); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 60); var img = Drag.GetComponent <Image>(); img.color = Color.green; img.sprite = EditorModelManager.FindSprite(icons, file); }
static public void AddPopMenu(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var dg = UICreator.CreateElement(Vector3.zero, new Vector2(300, 80), "PopMenu", parent.transform); dg.Content.compositeType = CompositeType.PopMenu; var grid = UICreator.CreateHImage(Vector3.zero, new Vector2(300, 80), "Content", dg.transform); grid.Content.MainColor = new Color32(40, 40, 40, 255); grid.Content.compositeType = CompositeType.PopMenu; var helper = grid.gameObject.AddComponent <StackPanelHelper>(); helper.direction = Direction.Vertical; var item = UICreator.CreateElement(Vector3.zero, new Vector2(300, 60), "Item", dg.transform); item.Content.marginType = MarginType.MarginX; var img = UICreator.CreateHImage(Vector3.zero, new Vector2(300, 60), "Image", item.transform); img.Content.MainColor = new Color32(64, 64, 64, 255); img.Content.marginType = MarginType.Margin; var txt = UICreator.CreateHText(Vector3.zero, new Vector2(200, 60), "Text", item.transform); txt.Content.marginType = MarginType.Margin; txt.Content.margin = new Margin(5, 32, 5, 5); txt.Content.TextAnchor = TextAnchor.MiddleCenter; txt.Content.FontSize = 32; txt.Content.Text = "Item"; img = UICreator.CreateHImage(new Vector3(138, 0, 0), new Vector2(24, 32), "Expand", item.transform); img.Content.anchorType = AnchorType.Alignment; img.Content.anchorPointType = AnchorPointType.Right; img.Content.Sprite = EditorModelManager.FindSprite(icons, "Next"); }
static public void AddDropDown(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var ss = new GameObject("DropDown"); Transform rect = ss.transform; var drop = ss.AddComponent <HImage>(); drop.SizeDelta = new Vector2(300, 60); drop.Sprite = EditorModelManager.FindSprite(icons, background); drop.SprType = SpriteType.Sliced; drop.MainColor = new Color32(224, 224, 224, 255); drop.eventType = huqiang.Core.HGUI.HEventType.UserEvent; drop.compositeType = CompositeType.DropDown; if (parent != null) { rect.SetParent(parent.transform); } rect.localPosition = Vector3.zero; rect.localScale = Vector3.one; rect.localRotation = Quaternion.identity; var txt = UICreator.CreateHText(Vector3.zero, Vector2.zero, "Label", rect); txt.TextAnchor = TextAnchor.MiddleLeft; txt.FontSize = 36; txt.marginType = MarginType.Margin; txt.margin = new Margin(20, 100, 5, 5); txt.Text = "Label"; txt.MainColor = Color.black; var img = UICreator.CreateHImage(Vector3.zero, new Vector2(50, 50), "Arrow", rect); img.SizeDelta = new Vector2(50, 50); img.Sprite = EditorModelManager.FindSprite(icons, diamond); img.anchorPointType = AnchorPointType.Right; img.anchorType = AnchorType.Alignment; img.MainColor = Color.black; var main = UICreator.CreateHImage(new Vector3(0, -34, 0), new Vector2(300, 300), "Scroll", rect); main.Pivot = new Vector2(0.5f, 1); main.Mask = true; main.MainColor = new Color32(224, 224, 224, 255); main.eventType = huqiang.Core.HGUI.HEventType.UserEvent; main.compositeType = CompositeType.ScrollY; main.Sprite = EditorModelManager.FindSprite(icons, background); main.SprType = SpriteType.Sliced; var item = UICreator.CreateElement(new Vector3(0, -150, 0), new Vector2(300, 60), "Item", main.transform); item.eventType = huqiang.Core.HGUI.HEventType.UserEvent; img = UICreator.CreateHImage(Vector3.zero, new Vector2(290, 50), "Image", item.transform); img.Sprite = EditorModelManager.FindSprite(icons, background); img.SprType = SpriteType.Sliced; txt = UICreator.CreateHText(Vector3.zero, Vector2.zero, "Text", item.transform); txt.marginType = MarginType.Margin; txt.margin = new Margin(60, 60, 5, 5); txt.MainColor = Color.black; txt.Text = "Option"; txt.FontSize = 32; txt.TextAnchor = TextAnchor.MiddleLeft; img = UICreator.CreateHImage(Vector3.zero, new Vector2(30, 30), "Check", item.transform); img.Sprite = EditorModelManager.FindSprite(icons, star); img.anchorType = AnchorType.Alignment; img.anchorOffset.x = 20; img.anchorPointType = AnchorPointType.Left; img.MainColor = Color.black; var slider = UICreator.CreateHImage(new Vector3(140, -150, 0), new Vector2(20, 300), "Slider", main.transform); slider.eventType = huqiang.Core.HGUI.HEventType.UserEvent; slider.compositeType = CompositeType.Slider; slider.Sprite = EditorModelManager.FindSprite(icons, background); slider.SprType = SpriteType.Sliced; slider.MainColor = 0x295B7680.ToColor(); var help = slider.gameObject.AddComponent <SliderHelper>(); help.direction = UISlider.Direction.Vertical; var Nob = UICreator.CreateHImage(new Vector3(0, 135, 0), new Vector2(20, 30), "Nob", slider.transform); Nob.MainColor = 0x5F5263ff.ToColor(); Nob.Sprite = EditorModelManager.FindSprite(icons, background); Nob.SprType = SpriteType.Sliced; }
static public void AddPalette(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var palette = new GameObject("Palette"); var main = palette.AddComponent <HImage>(); main.SizeDelta = new Vector2(500, 500); main.eventType = huqiang.Core.HGUI.HEventType.UserEvent; main.compositeType = CompositeType.UIPalette; Transform rect = palette.transform; if (parent != null) { rect.SetParent(parent.transform); } rect.localPosition = Vector3.zero; rect.localScale = Vector3.one; rect.localRotation = Quaternion.identity; var Fill = new GameObject("HTemplate"); var fr = Fill.transform; var ht = Fill.AddComponent <HImage>(); ht.eventType = huqiang.Core.HGUI.HEventType.UserEvent; ht.SizeDelta = new Vector2(256, 256); fr.SetParent(rect); fr.localPosition = Vector3.zero; fr.localScale = Vector3.one; fr.localRotation = Quaternion.identity; var Nob = new GameObject("NobA"); var fn = Nob.transform; fn.SetParent(rect); fn.localPosition = new Vector3(0, -220, 0); fn.localScale = Vector3.one; fn.localRotation = Quaternion.identity; var img = Nob.AddComponent <HImage>(); img.SizeDelta = new Vector2(44, 44); var aim = img.Sprite = EditorModelManager.FindSprite(icons, Aim); Nob = new GameObject("NobB"); fn = Nob.transform; fn.SetParent(rect); fn.localPosition = new Vector3(-128, 128, 0); fn.localScale = Vector3.one; fn.localRotation = Quaternion.identity; img = Nob.AddComponent <HImage>(); img.SizeDelta = new Vector2(24, 24); img.Sprite = aim; var Slider = new GameObject("Slider"); fn = Slider.transform; fn.SetParent(rect); fn.localPosition = new Vector3(0, -285, 0); fn.localScale = Vector3.one; fn.localRotation = Quaternion.identity; img = Slider.AddComponent <HImage>(); img.eventType = huqiang.Core.HGUI.HEventType.UserEvent; img.compositeType = CompositeType.Slider; img.SizeDelta = new Vector2(400, 20); Nob = new GameObject("Nob"); fn = Nob.transform; fn.SetParent(Slider.transform); fn.localPosition = new Vector3(200, 0, 0); fn.localScale = Vector3.one; img = Nob.AddComponent <HImage>(); img.SizeDelta = new Vector2(30, 30); img.MainColor = new Color(1, 1, 1, 1f); img.Sprite = aim; palette.AddComponent <PaletteHelper>().Initial(); }
static public UIElement AddDropDown(UIElement parent) { var drop = new HImage();//new GameObject("DropDown"); drop.name = "DropDown"; drop.SizeDelta = new Vector2(300, 60); drop.Sprite = EditorModelManager.FindSprite(icons, background); drop.SprType = SpriteType.Sliced; drop.MainColor = new Color32(224, 224, 224, 255); drop.eventType = HEventType.UserEvent; drop.compositeType = CompositeType.DropDown; drop.SetParent(parent); var txt = UICreator.CreateHText(Vector3.zero, Vector2.zero, "Label", drop); txt.TextAnchor = TextAnchor.MiddleLeft; txt.FontSize = 36; txt.marginType = MarginType.Margin; txt.margin = new Margin(20, 100, 5, 5); txt.Text = "Label"; txt.MainColor = Color.black; var img = UICreator.CreateHImage(Vector3.zero, new Vector2(50, 50), "Arrow", drop); img.SizeDelta = new Vector2(50, 50); img.Sprite = EditorModelManager.FindSprite(icons, diamond); img.anchorPointType = AnchorPointType.Right; img.anchorType = AnchorType.Alignment; img.MainColor = Color.black; var main = UICreator.CreateHImage(new Vector3(0, -34, 0), new Vector2(300, 300), "Scroll", drop); main.Pivot = new Vector2(0.5f, 1); main.Mask = true; main.MainColor = new Color32(224, 224, 224, 255); main.eventType = HEventType.UserEvent; main.compositeType = CompositeType.ScrollY; main.Sprite = EditorModelManager.FindSprite(icons, background); main.SprType = SpriteType.Sliced; var item = UICreator.CreateElement(new Vector3(0, -150, 0), new Vector2(300, 60), "Item", main); item.eventType = HEventType.UserEvent; img = UICreator.CreateHImage(Vector3.zero, new Vector2(290, 50), "Image", item); img.Sprite = EditorModelManager.FindSprite(icons, background); img.SprType = SpriteType.Sliced; txt = UICreator.CreateHText(Vector3.zero, Vector2.zero, "Text", item); txt.marginType = MarginType.Margin; txt.margin = new Margin(60, 60, 5, 5); txt.MainColor = Color.black; txt.Text = "Option"; txt.FontSize = 32; txt.TextAnchor = TextAnchor.MiddleLeft; img = UICreator.CreateHImage(Vector3.zero, new Vector2(30, 30), "Check", item); img.Sprite = EditorModelManager.FindSprite(icons, star); img.anchorType = AnchorType.Alignment; img.anchorOffset.x = 20; img.anchorPointType = AnchorPointType.Left; img.MainColor = Color.black; var slider = UICreator.CreateHImage(new Vector3(140, -150, 0), new Vector2(20, 300), "Slider", main); slider.eventType = HEventType.UserEvent; slider.compositeType = CompositeType.Slider; slider.Sprite = EditorModelManager.FindSprite(icons, background); slider.SprType = SpriteType.Sliced; slider.MainColor = 0x295B7680.ToColor(); //var help = slider.gameObject.AddComponent<SliderHelper>(); //help.direction = huqiang.UIComposite.UISlider.Direction.Vertical; var Nob = UICreator.CreateHImage(new Vector3(0, 135, 0), new Vector2(20, 30), "Nob", slider); Nob.MainColor = 0x5F5263ff.ToColor(); Nob.Sprite = EditorModelManager.FindSprite(icons, background); Nob.SprType = SpriteType.Sliced; return(drop); }
static public void AddDropdownEx(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var drop = new GameObject("DropdownEx", typeof(RectTransform)); RectTransform dt = drop.transform as RectTransform; if (parent != null) { dt.SetParent(parent.transform); } dt.sizeDelta = new Vector2(400, 60); var Label = new GameObject("Label", typeof(RectTransform), typeof(Text)); var st = Label.transform as RectTransform; st.SetParent(dt); st.localPosition = new Vector3(-30, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(340, 40); var txt = Label.GetComponent <Text>(); txt.color = Color.white; txt.fontSize = 32; txt.text = "Label"; txt.alignment = TextAnchor.MiddleCenter; var Close = new GameObject("Menu", typeof(RectTransform), typeof(Image)); st = Close.transform as RectTransform; st.SetParent(dt); st.localPosition = new Vector3(170, 0, 0); st.localScale = new Vector3(1, 1, 1); st.sizeDelta = new Vector2(48, 36); var img = Close.GetComponent <Image>(); img.color = Color.white; img.sprite = EditorModelManager.FindSprite(icons, list); var ss = new GameObject("Scroll", typeof(RectTransform)); RectTransform rect = ss.transform as RectTransform; rect.sizeDelta = new Vector2(400, 400); rect.SetParent(dt); rect.localPosition = new Vector3(0, -230, 0); rect.localScale = Vector3.one; ss.AddComponent <RectMask2D>(); var Item = new GameObject("Item", typeof(RectTransform)); var fr = Item.transform as RectTransform; fr.sizeDelta = new Vector2(400, 80); fr.SetParent(rect); fr.localPosition = Vector3.zero; fr.localScale = Vector3.one; Label = new GameObject("Label", typeof(RectTransform), typeof(Text)); st = Label.transform as RectTransform; st.SetParent(fr); st.localPosition = new Vector3(-30, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(400, 60); txt = Label.GetComponent <Text>(); txt.color = Color.white; txt.fontSize = 32; txt.text = "Label"; txt.alignment = TextAnchor.MiddleCenter; dt.localPosition = Vector3.zero; dt.localScale = Vector3.one; }
static public void AddLayout(MenuCommand menuCommand) { Sprite bk = EditorModelManager.FindSprite(icons, background); GameObject parent = menuCommand.context as GameObject; var layout = new GameObject("Layout", typeof(RectTransform)); RectTransform rect = layout.transform as RectTransform; rect.sizeDelta = new Vector2(1920, 1080); if (parent != null) { rect.SetParent(parent.transform); } var sse = layout.AddComponent <SizeScaleEx>(); sse.anchorType = AnchorType.Cneter; sse.sizeType = SizeType.Margin; sse.parentType = ParentType.Tranfrom; sse.DesignSize = new Vector2(1920, 1080); var AreaLevel = new GameObject("AreaLevel", typeof(RectTransform)); AreaLevel.transform.SetParent(rect); var LineLevel = new GameObject("LineLevel", typeof(RectTransform)); LineLevel.transform.SetParent(rect); var Line = new GameObject("Line", typeof(RectTransform), typeof(Image)); Line.transform.SetParent(rect); Line.GetComponent <Image>().color = new Color32(64, 64, 64, 255); var Area = new GameObject("Area", typeof(RectTransform), typeof(Image)); Area.transform.SetParent(rect); Area.GetComponent <Image>().color = Color.black; var Auxiliary = new GameObject("Auxiliary", typeof(RectTransform)); Auxiliary.transform.SetParent(rect); var Content = new GameObject("Content", typeof(RectTransform)); Content.transform.SetParent(Auxiliary.transform); var Head = new GameObject("Head", typeof(RectTransform), typeof(RectMask2D)); Head.transform.SetParent(Auxiliary.transform); (Head.transform as RectTransform).sizeDelta = new Vector2(100, 60); var Cover = new GameObject("Cover", typeof(RectTransform), typeof(RawImage)); Cover.transform.SetParent(Auxiliary.transform); Cover.GetComponent <RawImage>().color = new Color32(128, 128, 128, 128); var Docker = new GameObject("Docker", typeof(RectTransform)); Docker.transform.SetParent(Auxiliary.transform); var Center = new GameObject("Center", typeof(RectTransform), typeof(Image)); var st = Center.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = Vector3.zero; st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 100); var img = Center.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Left = new GameObject("Left", typeof(RectTransform), typeof(Image)); st = Left.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(-90, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 100); img = Left.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Top = new GameObject("Top", typeof(RectTransform), typeof(Image)); st = Top.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(0, 90, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 60); img = Top.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Right = new GameObject("Right", typeof(RectTransform), typeof(Image)); st = Right.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(90, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 100); img = Right.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Down = new GameObject("Down", typeof(RectTransform), typeof(Image)); st = Down.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(0, -90, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 60); img = Down.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Item = new GameObject("Item", typeof(RectTransform)); Item.transform.SetParent(Auxiliary.transform); var Label = new GameObject("Label", typeof(RectTransform), typeof(Text)); st = Label.transform as RectTransform; st.SetParent(Item.transform); st.localPosition = new Vector3(-20, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(200, 40); var txt = Label.GetComponent <Text>(); txt.color = Color.white; txt.fontSize = 32; txt.text = "Label"; txt.alignment = TextAnchor.MiddleLeft; var Close = new GameObject("Close", typeof(RectTransform), typeof(Image)); st = Close.transform as RectTransform; st.SetParent(Item.transform); st.localPosition = new Vector3(100, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(48, 48); img = Close.GetComponent <Image>(); img.color = Color.white; img.sprite = EditorModelManager.FindSprite(icons, close); var Drag = new GameObject("Drag", typeof(RectTransform), typeof(Image)); st = Drag.transform as RectTransform; st.SetParent(rect); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 60); img = Drag.GetComponent <Image>(); img.color = Color.green; img.sprite = EditorModelManager.FindSprite(icons, file); rect.localScale = Vector3.one; rect.localPosition = Vector3.zero; }
static public void AddPalette(MenuCommand menuCommand) { GameObject parent = menuCommand.context as GameObject; var palette = new GameObject("Palette", typeof(RectTransform)); RectTransform rect = palette.transform as RectTransform; rect.sizeDelta = new Vector2(500, 500); if (parent != null) { rect.SetParent(parent.transform); } rect.localPosition = Vector3.zero; rect.localScale = Vector3.one; palette.AddComponent <RawImage>(); var Fill = new GameObject("HTemplate", typeof(RectTransform)); var fr = Fill.transform as RectTransform; fr.sizeDelta = new Vector2(256, 256); fr.SetParent(rect); fr.localPosition = Vector3.zero; fr.localScale = Vector3.one; Fill.AddComponent <RawImage>(); var Nob = new GameObject("NobA", typeof(RectTransform)); var fn = Nob.transform as RectTransform; fn.sizeDelta = new Vector2(44, 44); fn.SetParent(rect); fn.localPosition = new Vector3(0, -220, 0); fn.localScale = Vector3.one; var img = Nob.AddComponent <Image>(); var aim = img.sprite = EditorModelManager.FindSprite(icons, Aim); Nob = new GameObject("NobB", typeof(RectTransform)); fn = Nob.transform as RectTransform; fn.sizeDelta = new Vector2(24, 24); fn.SetParent(rect); fn.localPosition = new Vector3(-128, 128, 0); fn.localScale = Vector3.one; Nob.AddComponent <Image>().sprite = aim; var Slider = new GameObject("Slider", typeof(RectTransform)); fn = Slider.transform as RectTransform; fn.sizeDelta = new Vector2(400, 20); fn.SetParent(rect); fn.localPosition = new Vector3(0, -285, 0); fn.localScale = Vector3.one; Slider.AddComponent <RawImage>(); Nob = new GameObject("Nob", typeof(RectTransform)); fn = Nob.transform as RectTransform; fn.sizeDelta = new Vector2(30, 30); fn.SetParent(Slider.transform); fn.localPosition = new Vector3(200, 0, 0); fn.localScale = Vector3.one; img = Nob.AddComponent <Image>(); img.color = new Color(1, 1, 1, 1f); img.sprite = aim; palette.AddComponent <PaletteHelper>().Initial(); }
static void CreateAuxiliary(GameObject parent) { Sprite bk = EditorModelManager.FindSprite(icons, background); var rect = parent.transform; var Auxiliary = new GameObject("Auxiliary", typeof(RectTransform)); Auxiliary.transform.SetParent(rect); CreateDockTabControl(Auxiliary); var ss = Auxiliary.AddComponent <SizeScaleEx>(); ss.marginType = MarginType.Margin; var Cover = new GameObject("Cover", typeof(RectTransform), typeof(RawImage)); Cover.transform.SetParent(Auxiliary.transform); Cover.GetComponent <RawImage>().color = new Color32(128, 128, 128, 128); var Docker = new GameObject("Docker", typeof(RectTransform)); Docker.transform.SetParent(Auxiliary.transform); var Center = new GameObject("Center", typeof(RectTransform), typeof(Image)); var st = Center.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = Vector3.zero; st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 100); var img = Center.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Left = new GameObject("Left", typeof(RectTransform), typeof(Image)); st = Left.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(-90, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 100); img = Left.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Top = new GameObject("Top", typeof(RectTransform), typeof(Image)); st = Top.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(0, 90, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 60); img = Top.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Right = new GameObject("Right", typeof(RectTransform), typeof(Image)); st = Right.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(90, 0, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(60, 100); img = Right.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; var Down = new GameObject("Down", typeof(RectTransform), typeof(Image)); st = Down.transform as RectTransform; st.SetParent(Docker.transform); st.localPosition = new Vector3(0, -90, 0); st.localScale = Vector3.one; st.sizeDelta = new Vector2(100, 60); img = Down.GetComponent <Image>(); img.color = new Color32(59, 87, 255, 128); img.sprite = bk; }
static void CreateDockTabControl(GameObject parent) { var tab = new GameObject("TabControl", typeof(RectTransform)); tab.transform.SetParent(parent.transform); var ss = tab.AddComponent <SizeScaleEx>(); ss.marginType = MarginType.Margin; var Head = new GameObject("Head", typeof(RectTransform)); Head.transform.SetParent(tab.transform); (Head.transform as RectTransform).sizeDelta = new Vector2(100, 60); var Items = new GameObject("Items", typeof(RectTransform)); Items.transform.SetParent(Head.transform); Items.transform.localPosition = Vector3.zero; (Items.transform as RectTransform).sizeDelta = new Vector2(100, 50); ss = Items.AddComponent <SizeScaleEx>(); ss.marginType = MarginType.MarginX; Items.AddComponent <UILayout>().type = huqiang.UI.LayoutType.StackPanelH; Items.AddComponent <RectMask2D>(); var Item = new GameObject("Item", typeof(RectTransform)); Item.transform.SetParent(Head.transform); Item.transform.localPosition = Vector3.zero; (Item.transform as RectTransform).sizeDelta = new Vector2(100, 50); var back = new GameObject("Back", typeof(RectTransform)); back.transform.SetParent(Item.transform); var img = back.AddComponent <Image>(); img.color = 0x2555FFff.ToColor(); ss = back.AddComponent <SizeScaleEx>(); ss.marginType = MarginType.MarginY; var label = new GameObject("Label", typeof(RectTransform)); label.transform.SetParent(Item.transform); (label.transform as RectTransform).sizeDelta = new Vector2(60, 50); label.transform.localPosition = new Vector3(-20, 0, 0); var txt = label.AddComponent <EmojiText>(); txt.alignment = TextAnchor.MiddleLeft; txt.fontSize = 30; var clo = new GameObject("Close", typeof(RectTransform)); clo.transform.SetParent(Item.transform); (clo.transform as RectTransform).sizeDelta = new Vector2(40, 40); clo.transform.localPosition = new Vector3(30, 0, 0); img = clo.AddComponent <Image>(); img.color = Color.white; img.sprite = EditorModelManager.FindSprite(icons, close); var line = new GameObject("Line", typeof(RectTransform)); line.transform.SetParent(Head.transform); (line.transform as RectTransform).sizeDelta = new Vector2(100, 4); line.transform.localPosition = new Vector3(0, -24, 0); ss = line.AddComponent <SizeScaleEx>(); ss.marginType = MarginType.MarginX; img = line.AddComponent <Image>(); img.color = 0x5379FFff.ToColor(); var content = new GameObject("Content", typeof(RectTransform)); content.transform.SetParent(tab.transform); content.transform.localPosition = Vector3.zero; }