Exemplo n.º 1
0
        /// <summary>
        /// Initializes a button that is already in the scroll view.
        /// </summary>
        public void Initialize(OnClickCallback onClickCB, object data)
        {
            m_OnClickCB = onClickCB;
            m_Data      = data;

            GetComponent <Toggle>().group = transform.parent.GetComponent <ToggleGroup>();
        }
Exemplo n.º 2
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (Size == Size.None)
            {
                Size = Size.ExtraSmall;
            }

            var onClick = OnClick;

            OnClick = EventCallback.Factory.Create <MouseEventArgs>(this, async e =>
            {
                if (!IsDisabled)
                {
                    if (onClick.HasDelegate)
                    {
                        await onClick.InvokeAsync(e);
                    }

                    if (Item != null && OnClickCallback != null)
                    {
                        await OnClickCallback.Invoke(Item);
                    }
                    if (Item != null && OnClickWithoutRenderCallback != null)
                    {
                        await OnClickWithoutRenderCallback.Invoke(Item);
                    }
                }
            });
        }
Exemplo n.º 3
0
 public override void Click(Point point)
 {
     if (rect.Contains(point))
     {
         if (OnClickCallback != null)
         {
             OnClickCallback.Invoke();
         }
     }
 }
            public static ComponentEntry CreateEntry(HierarchyComponentData item, OnClickCallback onClick, OnClickCallback onDoubleClick, bool buttonIsClickable, Color color)
            {
                string name = item.Name;

                if (item is HierarchyComponentFolder)
                {
                    name = $"/{name}";
                }
                return(new ComponentEntry(string.Empty, name, onClick, onDoubleClick, buttonIsClickable, item, color));
            }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new button and adds it to a scroll view (or other container).
        /// </summary>
        public void Initialize(Transform parent, Sprite spriteToDisplay, OnClickCallback onClickCB, object data)
        {
            m_OnClickCB = onClickCB;
            m_Data      = data;

            transform.SetParent(parent);
            GetComponent <Toggle>().group = parent.GetComponent <ToggleGroup>();

            m_SpriteImage.sprite = spriteToDisplay;
        }
Exemplo n.º 6
0
    public virtual void SetParams(string text, string caption, OnClickCallback callback, params System.Object[] args)
    {
        if (string.IsNullOrEmpty(caption))
        {
            caption = Localization.Localize("IDS_TITLE_GLOBAL_NOTICE");
        }
        labelCaption.text = caption;
        labelText.text    = text;

        _buttonClicked = callback;
    }
Exemplo n.º 7
0
    /// <summary>
    /// Sets the contents of the Action Interface, prompting the user for an AP amount.
    /// </summary>
    /// <param name="description">Description of the action.</param>
    /// <param name="minAp">The minimum amount of AP that can be selected.</param>
    /// <param name="maxAp">The maximum amount of AP that can be selected.</param>
    /// <param name="okCallback">Callback to run if the player presses 'OK'.</param>
    /// <param name="cancelCallback">Callback to run if the player presses 'CANCEL'.</param>
    public void GetAPForAction(string description, int minAp, int maxAp,
	                           OnClickCallback okCallback, OnClickCallback cancelCallback)
    {
        handleOkClick = okCallback;
        handleCancelClick = cancelCallback;
        actionDescriptionText.text = description;
        apSlider.minValue = minAp;
        apSlider.maxValue = maxAp;
        apSlider.value = minAp;
        apSliderText.text = minAp.ToString();
    }
Exemplo n.º 8
0
    public override void SetParams(string text, string caption, OnClickCallback callback, params System.Object[] args)
    {
        base.SetParams(text, caption, callback, args);

        UIMessageBox.OnInputCallback inputCallback = args[0] as UIMessageBox.OnInputCallback;

        labelCaption.text = caption;
        labelText.text    = text;
        inputBox.text     = Localization.instance.Get("IDS_INPUT_HERE");
        inputBox.maxChars = k_max_input_length;
        _inputClicked     = inputCallback;
    }
Exemplo n.º 9
0
        private async Task OnClickedAsync(MouseEventArgs e)
        {
            var js = await _jsTask.Value;

            IsSelected = true;
            if (e.Button == 0 && !NodeModel.IsFile)
            {
                await js.InvokeVoidAsync("toggle", Id);
            }

            await OnClickCallback.InvokeAsync(this);
        }
 private ComponentEntry(
     string objectName,
     string labelText,
     OnClickCallback onClick,
     OnClickCallback onDoubleClick,
     bool buttonIsClickable,
     HierarchyComponentData item,
     Color color)
     : base(objectName, labelText, onClick, onDoubleClick, buttonIsClickable)
 {
     item_  = item;
     color_ = color;
 }
Exemplo n.º 11
0
        public Task OnClicked()
        {
            if (Question.IsAnswerSelected)
            {
                return(Task.CompletedTask);
            }

            IsClicked = true;

            Reveal();

            Question.SelectAnswer(Answer);

            return(OnClickCallback.InvokeAsync(Answer));
        }
Exemplo n.º 12
0
    public override void SetParams(string text, string caption, OnClickCallback callback, params System.Object[] args)
    {
        if (args[0] is ItemData)
        {
            itemInfoPanel.gameObject.SetActive(true);
            tattooInfoPanel.gameObject.SetActive(false);

            itemInfoPanel.DisplayItemInfo(args[0] as ItemData);
        }
        else if (args[0] is string)
        {
            itemInfoPanel.gameObject.SetActive(false);
            tattooInfoPanel.gameObject.SetActive(true);

            tattooInfoPanel.DisplayTattooInfo(args[0] as string);
        }
    }
    void ShowError(string title, string text, string buttonText = null, OnClickCallback callbackClickFunc = null)
    {
        popupButton.onClick.AddListener(ButtonClicked);

        this.popupTitle.text = title;
        this.popupText.text  = text;
        if (buttonText != null)
        {
            this.popupButtonText.text = buttonText;
        }

        this.baseGameObject.SetActive(true);

        if (callbackClickFunc != null)
        {
            onClickCallback += callbackClickFunc;
        }
    }
Exemplo n.º 14
0
    // For every children transform under our panel, find the button and add on click
    private void AddListenerToButton(Transform Panel, OnClickCallback Callback, OnClickAdditionCallback AdditionalCallback)
    {
        if (Panel == null)
        {
            Debug.Log("You did not assign panel in the inspector");
        }

        int i = 0;

        foreach (Transform t in Panel)
        {
            int currentIndex = i;

            Button b = t.GetComponent <Button>();
            b.onClick.AddListener(() => Callback(currentIndex));
            AdditionalCallback(t, currentIndex);
            i++;
        }
    }
Exemplo n.º 15
0
    protected override void OnAwake()
    {
        base.OnAwake();

        this.transform.SetActive(false);

        if (ok.Text != null)
        {
            ok.Text.text = "OK";
        }

        if (cancel.Text != null)
        {
            cancel.Text.text = "Cancel";
        }


        if (ok.Button != null)
        {
            ok.Button.onClick.RemoveAllListeners();
            ok.Button.onClick.AddListener(() =>
            {
                if (OnClickCallback != null)
                {
                    OnClickCallback.Invoke(ok.Id);
                }
            });
        }

        if (cancel.Button != null)
        {
            cancel.Button.onClick.RemoveAllListeners();
            cancel.Button.onClick.AddListener(() =>
            {
                if (OnClickCallback != null)
                {
                    OnClickCallback.Invoke(cancel.Id);
                }
            });
        }
    }
Exemplo n.º 16
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (Size == Size.None)
            {
                Size = Size.ExtraSmall;
            }

            OnClickButton = EventCallback.Factory.Create <MouseEventArgs>(this, async e =>
            {
                if (IsAsync)
                {
                    ButtonIcon = LoadingIcon;
                    IsDisabled = true;
                }
                if (OnClickWithoutRender != null)
                {
                    await OnClickWithoutRender.Invoke();
                }
                if (OnClick.HasDelegate)
                {
                    await OnClick.InvokeAsync(e);
                }
                if (Item != null && OnClickWithoutRenderCallback != null)
                {
                    await OnClickWithoutRenderCallback.Invoke(Item);
                }
                if (Item != null && OnClickCallback != null)
                {
                    await OnClickCallback.Invoke(Item);
                }
                if (IsAsync)
                {
                    ButtonIcon = Icon;
                    IsDisabled = false;
                }
            });
        }
    public override void SetParams(string text, string caption, OnClickCallback callback, params System.Object[] args)
    {
        base.SetParams(text, caption, callback, args);

        List <ItemInventory> itemList = args[0] as List <ItemInventory>;

        //find the grid
        GameObject goGrid = this.transform.FindChild("Panel/ItemContainer/Grid").gameObject;

        _itemList = new List <UICommonDisplayItem>();

        foreach (ItemInventory ii in itemList)
        {
            GameObject go = NGUITools.AddChild(goGrid, commonItemPrefab);

            UICommonDisplayItem cdt = go.GetComponent <UICommonDisplayItem>();

            cdt.SetData(ii.ItemID, ii.Count);

            _itemList.Add(cdt);
        }
    }
 public static void PopupAlert(string title, string text, string buttonText = null, OnClickCallback callbackClickFunc = null)
 {
     (GameManager.Instance.popupManager.Clone() as PopupManager).ShowError(title, text, buttonText, callbackClickFunc);
 }
Exemplo n.º 19
0
 public void AddOnClickListener(OnClickCallback callback)
 {
     onClickEvent += callback;
 }