void Start() { GameObject block = UIController.instance.SelectedBlock; if (!block) { Debug.LogError("No selected block"); return; } Cultivable cultivable = block.GetComponent <Cultivable>(); if (!cultivable) { Debug.LogError("Selected block is not cultivable"); return; } if (seedOptions.Length == 0) { Debug.LogError("No seed available"); return; } seedsDropDown.ClearOptions(); foreach (Seed seed in seedOptions) { seedsDropDown.options.Add(new Dropdown.OptionData(seed.name)); } button.onClick.AddListener(() => AddPlantTask(block)); }
public bool Initialize(ICommandArgs args) { PlantCommandArgs commandArgs = args as PlantCommandArgs; if (commandArgs == null) { Abort(); throw new UnityException("Wrong type of args"); } seed = commandArgs.seed; cultivable = commandArgs.node.GetBlock().GetComponent <Cultivable>(); if (!cultivable) { Abort(); Debug.LogError("Tried to plant a non cultivable object"); return(false); } TickSystem.Subscribe(Plant); return(true); }