private static GameObject GetWidgetViaCenterTorso(MechLabSlotsSettings.WidgetSettings settings, GameObject centerTorso) { return(centerTorso.transform.parent.GetChild(settings.ShortLabel)?.gameObject); }
internal static void SetupWidget( string id, ref MechLabLocationWidget?topWidget, MechLabPanel mechLabPanel, MechLabLocationWidget armWidget, MechLabSlotsSettings.WidgetSettings settings ) { GameObject go; if (topWidget == null) { var template = mechLabPanel.centerTorsoWidget; go = Object.Instantiate(template.gameObject, null); go.name = id; go.SetActive(settings.Enabled); { var vlg = go.GetComponent <VerticalLayoutGroup>(); vlg.padding = new RectOffset(0, 0, 0, 3); vlg.spacing = 4; } go.transform.Find("layout_armor").gameObject.SetActive(false); go.transform.Find("layout_hardpoints").gameObject.SetActive(false); go.transform.Find("layout_locationText/txt_structure").gameObject.SetActive(false); go.transform.Find("layout_locationText/txt_location").GetComponent <TextMeshProUGUI>().text = settings.Label; topWidget = go.GetComponent <MechLabLocationWidget>(); } else { go = topWidget.gameObject; } var parent = armWidget.transform.parent; go.transform.SetParent(parent, false); go.transform.SetAsFirstSibling(); go.GetComponent <LayoutElement>().ignoreLayout = true; { var rect = go.GetComponent <RectTransform>(); rect.localPosition = new Vector3(0, 0); rect.pivot = new Vector2(0, 0); rect.anchoredPosition = new Vector2(0, -MechLabSlotsFeature.settings.MechLabArmTopPadding + 20); } { var clg = parent.GetComponent <VerticalLayoutGroup>(); clg.padding = new RectOffset(0, 0, MechLabSlotsFeature.settings.MechLabArmTopPadding, 0); } topWidget.Init(mechLabPanel); var layout = new WidgetLayout(topWidget); MechLabSlotsFixer.ModifyLayoutSlotCount(layout, settings.Slots); { var mechRectTransform = parent.parent.GetComponent <RectTransform>(); LayoutRebuilder.ForceRebuildLayoutImmediate(mechRectTransform); } }