本文整理汇总了C#中UIPanel.AttachUIComponent方法的典型用法代码示例。如果您正苦于以下问题:C# UIPanel.AttachUIComponent方法的具体用法?C# UIPanel.AttachUIComponent怎么用?C# UIPanel.AttachUIComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIPanel
的用法示例。
在下文中一共展示了UIPanel.AttachUIComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start()
{
base.Start();
_checkBox = AddUIComponent<UICustomCheckbox>();
_colorFieldPanel = AddUIComponent<UIPanel>();
_colorFieldPanel.size = new Vector2(17, 17);
_colorFieldPanel.relativePosition = new Vector3(22, 0);
_color = Instantiate(FindObjectOfType<UIColorField>().gameObject).GetComponent<UIColorField>();
_colorFieldPanel.AttachUIComponent(_color.gameObject);
_color.name = "ColorPickerLine" + LineID;
_color.size = new Vector2(17, 17);
_color.relativePosition = new Vector3(0, 0);
_color.pickerPosition = UIColorField.ColorPickerPosition.RightAbove;
_color.eventSelectedColorChanged += (component, value) => TransportUtil.SetLineColor(LineID, value);
_name = AddUIComponent<UILabel>();
_stops = AddUIComponent<UILabel>();
_passengers = AddUIComponent<UILabel>();
_trips = AddUIComponent<UILabel>();
_vehicles = AddUIComponent<UILabel>();
_deleteButton = AddUIComponent<UIButton>();
_deleteButton.size = new Vector2(17, 17);
_deleteButton.tooltip = "Delete line";
_deleteButton.normalFgSprite = "buttonclose";
_deleteButton.pressedFgSprite = "buttonclosepressed";
_deleteButton.hoveredFgSprite = "buttonclosehover";
_deleteButton.isVisible = true;
_checkBox.relativePosition = new Vector3(5, 0);
_name.relativePosition = new Vector3(43, 0);
_stops.relativePosition = new Vector3(170, 0);
_passengers.relativePosition = new Vector3(225, 0);
_trips.relativePosition = new Vector3(320, 0);
_vehicles.relativePosition = new Vector3(401, 0);
_deleteButton.relativePosition = new Vector3(435, 0);
_name.textColor = new Color32(185, 221, 254, 255);
_stops.textColor = new Color32(185, 221, 254, 255);
_passengers.textColor = new Color32(185, 221, 254, 255);
_trips.textColor = new Color32(185, 221, 254, 255);
_vehicles.textColor = new Color32(185, 221, 254, 255);
_checkBox.size = new Vector2(12, 12);
// event handler
_checkBox.eventClick += (component, param) =>
{
_checkBox.IsChecked = !_checkBox.IsChecked;
if (!_checkBox.IsChecked)
TransportUtil.HideTransportLine(LineID);
else
TransportUtil.ShowTransportLine(LineID);
};
_name.eventClick += (component, param) =>
WorldInfoPanel.Show<PublicTransportWorldInfoPanel>(TransportUtil.GetFirstLineStop(LineID), InstanceID);
_name.eventMouseHover += (component, param) =>
{
TransportUtil.SelectTransportLine(LineID);
_name.textColor = TransportUtil.GetLineColor(LineID);
};
_name.eventMouseLeave += (component, param) =>
{
TransportUtil.DeselectTransportLine(LineID);
_name.textColor = new Color32(185, 221, 254, 255);
};
_deleteButton.eventClick += (component, param) =>
Singleton<TransportManager>.instance.ReleaseLine(LineID);
// scale label texts
_name.textScale = 0.8f;
_stops.textScale = 0.8f;
_passengers.textScale = 0.8f;
_trips.textScale = 0.8f;
_vehicles.textScale = 0.8f;
_deleteButton.textScale = 0.8f;
// zebra stripes background
backgroundSprite = "GenericPanelLight";
if (IsOdd)
color = new Color32(150, 150, 150, 255);
else
color = new Color32(130, 130, 130, 255);
// center elements in row
UIComponent[] children = GetComponentsInChildren<UIComponent>();
foreach (UIComponent child in children)
{
if (child == this) continue;
child.pivot = UIPivotPoint.MiddleLeft;
child.transformPosition = new Vector3(child.transformPosition.x, GetBounds().center.y, 0);
}
//.........这里部分代码省略.........
示例2: HookGUI
private void HookGUI()
{
//m_distictName = UIView.Find<UITextField>("DistrictName");
Debug.Print("Hooking");
m_panel = (UIPanel)UIView.Find<UITextField>("DistrictName").parent.parent;
//m_panel = UIView.Find<UIPanel>("(Library) ZonedBuildingWorldInfoPanel");
Debug.Print (m_panel.cachedName);
m_demandSprite = (UISlicedSprite)GameObject.Instantiate(UIView.Find<UISlicedSprite> ("DemandBack"));
m_demandSprite.name = "DistrictRCIDemand";
m_demandSprite.cachedName = "DistrictRCIDemand";
m_demandSprite.Show();
m_panel.AttachUIComponent(m_demandSprite.gameObject);
m_demandSprite.relativePosition = new Vector3(m_panel.width - m_demandSprite.width - 10f,m_panel.height - m_demandSprite.height - 24f);
m_panel.eventVisibilityChanged += (component, value) => {Update();};
//m_panel.eventAnchorChanged += (component, value) => {Update();};
//m_panel.eventPositionChanged += (component, value) => {Update();};
//m_panel.eventMouseMove += (component, value) => {Update();};
UIView.Find<UITextField> ("DistrictName").eventTextChanged += (component, value) => {Update();};
}