コード例 #1
0
 private void HandleChangeRecipe(RecipeBubbleUI recipeBubbleUi)
 {
     if (OnRecipeChange != null)
     {
         OnRecipeChange(recipeBubbleUi.Recipe);
     }
 }
コード例 #2
0
        private void Load()
        {
            var            recipes = _playerRecipes.KnowRecipes;
            RecipeBubbleUI first   = null;

            // create icons
            foreach (Crafting.Recipe recipe in recipes)
            {
                var bubble = Instantiate(_recipeBubblePrefab);
                bubble.transform.SetParent(_layoutGroup.transform);
                bubble.SetRecipe(recipe);

                bubble.Toggle.group = _toggleGroup;

                bubble.Toggle.onValueChanged.AddListener(value => {
                    if (value)
                    {
                        HandleChangeRecipe(bubble);
                    }
                    ;
                });

                if (first == null)
                {
                    first = bubble;
                }
            }

            // select first icon
            if (first != null)
            {
                first.Toggle.isOn = true;
            }
        }