public void Activate(Item_Product product) { var item = product.Product; if (item is Item_Equipment) { var equip = item as Item_Equipment; itemEffects = new UI_ItemEffect[equip.ItemEffects.Length]; var xOffset = 0.0f; var index = 0; foreach (var e in equip.ItemEffects) { itemEffects[index] = UI_ItemEffect.CreateInstance(RectTransform, e, xOffset, out float width); index++; xOffset += width + 10; } } }
public void SetEffects(Item_Equipment_Effect[] effects) { var index = 0; var xSpacing = 20.0f; var xOffset = xSpacing; Effects = new UI_ItemEffect[effects.Length]; foreach (var e in effects) { var effect = UI_ItemEffect .CreateInstance(RectTransform, e, xOffset, out float outWidth); Effects[index] = effect; xOffset += outWidth; xOffset += xSpacing; index++; } }