本文整理汇总了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;
}
示例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;
}