コード例 #1
0
    private void Start()
    {
        trayInputButton = GetComponentInParent <TrayInputButton>();
        if (trayInputButton != null)
        {
            clickListener = trayInputButton.GetComponent <ButtonClickListener>();
            clickListener.OnClick.AddListener(OnClicked);
        }
        else
        {
            Log.LogError(this, "TrayInputButton not found");
        }
        dispatcher = Service.Get <EventDispatcher>();
        GameObject localPlayerGameObject = ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject;

        if (localPlayerGameObject != null)
        {
            locomotionEventBroadcaster = localPlayerGameObject.GetComponent <LocomotionEventBroadcaster>();
            SlideController component = localPlayerGameObject.GetComponent <SlideController>();
            if (component != null && component.enabled)
            {
                changeState(isSliding: true);
            }
        }
        if (locomotionEventBroadcaster != null)
        {
            locomotionEventBroadcaster.OnControllerChangedEvent += onControllerChanged;
        }
        else
        {
            Log.LogError(this, "LocomotionEventBroadcaster was not found in the scene");
        }
    }
コード例 #2
0
    public void SetUpButton(TrayInputButton trayInputButton)
    {
        GameObject gameObject = Object.Instantiate(ButtonPrefab);

        gameObject.transform.SetParent(trayInputButton.Behaviour.transform, worldPositionStays: false);
        if (trayInputButton.IconSprite != null && trayInputButton.IconTint != null)
        {
            trayInputButton.Icon.enabled       = true;
            trayInputButton.IconSprite.Sprites = new Sprite[ButtonIcons.Length];
            trayInputButton.IconTint.Colors    = new Color[ButtonIcons.Length];
            for (int i = 0; i < ButtonIcons.Length; i++)
            {
                trayInputButton.IconSprite.Sprites[i] = ButtonIcons[i];
                trayInputButton.IconTint.Colors[i]    = IconTints[i];
            }
            trayInputButton.IconSprite.SelectSprite((int)DefaultState);
            trayInputButton.IconTint.SelectColor((int)DefaultState);
        }
        else
        {
            trayInputButton.Icon.enabled = false;
            Log.LogError(this, "Button object did not have an icon sprite or tint selector");
        }
        trayInputButton.DefaultState        = DefaultState;
        trayInputButton.IsBackgroundVisible = IsBackgroundVisible;
        if (!IsBackgroundVisible)
        {
            trayInputButton.GetComponent <Image>().enabled = false;
        }
        TrayInputButton.ButtonState buttonVisualState = DefaultState;
        TrayInputButton.ButtonState buttonState       = DefaultState;
        if (trayInputButton.IsLocked)
        {
            buttonVisualState = trayInputButton.CurrentViewState;
            buttonState       = TrayInputButton.ButtonState.Disabled;
        }
        trayInputButton.InitializeView(DefaultState, buttonVisualState);
        trayInputButton.GetComponent <Button>().interactable = (buttonState != TrayInputButton.ButtonState.Disabled);
        trayInputButton.gameObject.SetActive(value: true);
    }