public void SetLinkedMachine(GameObject machine) { CraftingManagerRecipe craftingManagerRecipe; CraftingManagerFixed craftingManagerFixed; if (machine == null) { this.craftingManagerFixed = null; this.craftingManagerRecipe = null; this.inventoryFixed = null; this.inventoryRecipe = null; GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelIn); } else if (machine.TryGetComponent(out craftingManagerFixed)) { this.craftingManagerRecipe = null; this.craftingManagerFixed = craftingManagerFixed; recipeSelector.SetActive(false); inventoryFixed = machine.GetComponent <InventoryFixed>(); inventoryRecipe = null; GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelOut); } else if (machine.TryGetComponent(out craftingManagerRecipe)) { this.craftingManagerFixed = null; this.craftingManagerRecipe = craftingManagerRecipe; recipeSelector.SetActive(true); inventoryRecipe = machine.GetComponent <InventoryRecipe>(); inventoryFixed = null; GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelOut); recipePanel.GetComponent <CraftingUI>().SetLinkedInventory(inventoryRecipe); } }
// Start is called before the first frame update void Start() { inventory = GetComponent <InventoryFixed>(); if (inventory == null) //if there is no inventory, this can't do anything and should not exist { Destroy(this); } }