private void AddButton(ModuleScriptableObject module) { CategoryButton button = Instantiate(menuButtonPrefab, contentPanel).GetComponent <CategoryButton>(); button.GetComponent <RectTransform>().localScale = Vector3.one; button.SetUpButton(module, OnModuleButton); }
private void OnModuleButton(ModuleScriptableObject module) { var canvas = GetComponentInParent <Canvas>().rootCanvas; ModuleItem moduleItem = Instantiate(modulePrefab, canvas.transform).GetComponent <ModuleItem>(); moduleItem.SetUpItem(module, ShipBuilder.SlotSize); ModuleItem.SetSelectedItem(moduleItem); }
public CompressedSlot(SlotItem slot) { GridPos = slot.GridPos; ModuleStartPos = slot.ModuleStartPos; if (slot.Module != null) { Module = slot.Module.Module; } }
public void SetUpItem(ModuleScriptableObject module, float slotSize) { Module = module; icon.overrideSprite = module.Icon; RectTransform rect = GetComponent <RectTransform>(); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, module.Size.x * slotSize); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, module.Size.y * slotSize); rect.localScale = Vector3.one; }
public void SetUpButton(ModuleScriptableObject item, Action <ModuleScriptableObject> onButtonClicked) { icon.overrideSprite = item.Icon; nameText.text = item.Name; OnButtonClicked = () => onButtonClicked?.Invoke(item); }