当前位置: 首页>>代码示例>>C#>>正文


C# UIComponent.AttachUIComponent方法代码示例

本文整理汇总了C#中UIComponent.AttachUIComponent方法的典型用法代码示例。如果您正苦于以下问题:C# UIComponent.AttachUIComponent方法的具体用法?C# UIComponent.AttachUIComponent怎么用?C# UIComponent.AttachUIComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIComponent的用法示例。


在下文中一共展示了UIComponent.AttachUIComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateColorField

        public static UIColorField CreateColorField(UIComponent parent)
        {
            //UIColorField colorField = parent.AddUIComponent<UIColorField>();
            // Creating a ColorField from scratch is tricky. Cloning an existing one instead.
            // Probably doesn't work when on main menu screen and such as no ColorField exists.
            UIColorField colorField = UnityEngine.Object.Instantiate<GameObject>(UnityEngine.Object.FindObjectOfType<UIColorField>().gameObject).GetComponent<UIColorField>();
            parent.AttachUIComponent(colorField.gameObject);

            colorField.size = new Vector2(40f, 26f);
            colorField.normalBgSprite = "ColorPickerOutline";
            colorField.hoveredBgSprite = "ColorPickerOutlineHovered";
            colorField.selectedColor = Color.black;
            colorField.pickerPosition = UIColorField.ColorPickerPosition.RightAbove;

            return colorField;
        }
开发者ID:GRANTSWIM4,项目名称:Cimtographer,代码行数:16,代码来源:UIUtils.cs

示例2: CreatSliderWithLabel

        /*
        public static UISlider CreatSliderWithLabel(out UILabel label, UIComponent parent, string labelText, float width)
        {
            var labelWidth = Mathf.Round(width * LABEL_RELATIVE_WIDTH);

            var slider = UIUtil.CreateSlider(parent);
            slider.relativePosition = new Vector3(labelWidth + COLUMN_PADDING, 0);
            slider.width = width - labelWidth - COLUMN_PADDING;

            label = AddLabel(parent, labelText, labelWidth, dropDown.height);

            return slider;
        }*/
        public static UIPanel CreateSlider(UIComponent parent, string text, float min, float max, float step, float defaultValue, [NotNull] OnValueChanged eventCallback)
        {
            if (eventCallback == null) throw new ArgumentNullException(nameof(eventCallback));

            UIPanel uIPanel = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kSliderTemplate)) as UIPanel;
            uIPanel.position = Vector3.zero;

            uIPanel.Find<UILabel>("Label").text = text;

            UISlider uISlider = uIPanel.Find<UISlider>("Slider");
            uISlider.minValue = min;
            uISlider.maxValue = max;
            uISlider.stepSize = step;
            uISlider.value = defaultValue;
            uISlider.eventValueChanged += delegate (UIComponent c, float val)
            {
                eventCallback(val);
            };
            return uIPanel;
        }
开发者ID:boformer,项目名称:NetworkSkins,代码行数:33,代码来源:UIUtil.cs


注:本文中的UIComponent.AttachUIComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。