public TrayInputButtonGroup Create(TrayInputButtonGroup trayInputButtonGroupAsset, Transform parent)
        {
            TrayInputButtonGroup trayInputButtonGroup = Object.Instantiate(trayInputButtonGroupAsset, parent);

            if (trayInputButtonGroup.Buttons.Length != InputButtonDefinitions.Length)
            {
                Log.LogError(this, "Number of button containers does not match the number of button definitions");
            }
            else
            {
                for (int i = 0; i < InputButtonDefinitions.Length; i++)
                {
                    trayInputButtonGroup.Buttons[i].Index = i;
                    if (InputButtonDefinitions[i] != null)
                    {
                        InputButtonDefinitions[i].SetUpButton(trayInputButtonGroup.Buttons[i]);
                        if (ButtonStateOverrides != null && ButtonStateOverrides.Length > i && ButtonStateOverrides[i] != TrayInputButton.ButtonState.None)
                        {
                            trayInputButtonGroup.Buttons[i].InitializeView(ButtonStateOverrides[i]);
                        }
                    }
                    else
                    {
                        trayInputButtonGroup.Buttons[i].InitializeView(TrayInputButton.ButtonState.Disabled);
                        trayInputButtonGroup.Buttons[i].gameObject.SetActive(value: false);
                    }
                }
            }
            return(trayInputButtonGroup);
        }
예제 #2
0
        private IEnumerator replaceButtons(InputButtonGroupDefinition newButtonGroupDefinition)
        {
            AssetRequest <TrayInputButtonGroup> assetRequest = Content.LoadAsync(newButtonGroupDefinition.TemplateContentKey);

            yield return(assetRequest);

            if (!(RightContainer == null))
            {
                if (RightContainer.childCount > 0)
                {
                    clearChildren(RightContainer);
                }
                yield return(new WaitForEndOfFrame());

                currentGroupDefinition = newButtonGroupDefinition;
                overrideDefinitions.Clear();
                trayInputButtonGroup = newButtonGroupDefinition.Create(assetRequest.Asset, RightContainer);
                Service.Get <EventDispatcher>().DispatchEvent(default(ControlsScreenEvents.ControlLayoutLoadComplete));
            }
        }