private void generateEquippedPartItems() { const float itemAnchorStep = 1f / 5f; for (int i = 0; i < handler.EquippedParts.Count; ++i) { PartSlot slot = handler.EquippedParts[i]; EquippedPartsItem item = handler.EquippedPartsItemPool.GetObject().GetComponent <EquippedPartsItem>(); item.transform.SetParent(handler.EquippedPartsItemRoot, false); Vector2 anchorMin = new Vector2(0, 1 - (i + 1) * itemAnchorStep); Vector2 anchorMax = new Vector2(1, 1 - (i) * itemAnchorStep); RectTransform rect = item.GetComponent <RectTransform>(); rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; rect.offsetMin = new Vector2(); rect.offsetMax = new Vector2(); rect.localScale = new Vector3(1, 1, 1); item.Init(slot, handler); item.GetComponent <Button>().onClick.AddListener(delegate { equippedItemSelected(item); }); items.Add(item); } }
private void equippedItemSelected(EquippedPartsItem partsItem) { handler.PickedPartsItem = partsItem; handler.GotoState(CustomizationHandler.StateType.OtherItemSelect); }