Exemple #1
0
        public static void GetStringFromDialog(string title, string instructions, object target,
                                               Func <string, bool> ValidatorF, Action <string, object> onAccept, Action onCancel)
        {
            GameObject dialog = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("GetStringDialog"));

            UnityUIUtil.FindTextAndSet(dialog, "Title", title);
            UnityUIUtil.FindTextAndSet(dialog, "InfoText", instructions);

            Button cancelButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "Cancel", () => {
                if (onCancel != null)
                {
                    onCancel();
                }
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            var input = UnityUIUtil.FindInput(dialog, "TextEntry");

            Button okButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "OK", () => {
                if (input.text.Length == 0)
                {
                    return;
                }
                if (ValidatorF != null && ValidatorF(input.text) == false)
                {
                    return;
                }

                onAccept(input.text, target);
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            input.Select();

            MainUICanvas.AddChild(dialog, false);
        }
Exemple #2
0
    // Use this for initialization
    public void Start()
    {
        dimensionPanel      = this.gameObject.FindChildByName("DimensionPanel", true);
        dimensionText       = UnityUIUtil.FindText(this.gameObject, "DimensionText");
        dimensionInput      = UnityUIUtil.FindInput(this.gameObject, "DimensionInput");
        dimensionInput.text = InitialDimension.ToString("F4");
        if (message_mode == 0)
        {
            dimensionText.text = "The imported mesh is very small. Maybe the units are not mm? You can select other units or enter a new height in the field below.";
        }
        else if (message_mode == 1)
        {
            dimensionText.text = "The imported mesh is taller than the print volume. You can enter a new height in the field below, or select the original units or a new height.";
        }
        else if (message_mode == 2)
        {
            dimensionText.text = "The imported mesh is much larger than the print bed. You can enter a new height in the field below, or select the original units or a new height.";
        }

        inchButton   = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "InchButton", on_dimension_inch);
        meterButton  = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "MeterButton", on_dimension_meter);
        FiveCMButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "FiveButton", on_dimension_fivecm);
        TenCMButton  = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "TenButton", on_dimension_tencm);

        polycountPanel      = this.gameObject.FindChildByName("PolycountPanel", true);
        polycountText       = UnityUIUtil.FindText(this.gameObject, "PolycountText");
        polycountInput      = UnityUIUtil.FindInput(this.gameObject, "PolycountInput");
        polycountInput.text = InitialPolycount.ToString();

        tenKButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "TenKButton", () => { polycountInput.text = "25000"; });
        if (InitialPolycount < 10000)
        {
            tenKButton.interactable = false;
        }
        hundredKButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "HundredKButton", () => { polycountInput.text = "100000"; });
        if (InitialPolycount < 100000)
        {
            hundredKButton.interactable = false;
        }
        twofiftyKButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "TwoFiftyKButton", () => { polycountInput.text = "250000"; });
        if (InitialPolycount < 250000)
        {
            twofiftyKButton.interactable = false;
        }
        millionButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "MillionButton", () => { polycountInput.text = "1000000"; });
        if (InitialPolycount < 1000000)
        {
            millionButton.interactable = false;
        }

        skipButton  = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "SkipButton", on_skip);
        applyButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "ApplyButton", on_apply);


        if (SetDimension == false)
        {
            dimensionPanel.SetVisible(false);
            dimensionText.gameObject.SetVisible(false);
        }
        if (SetPolycount == false)
        {
            polycountPanel.SetVisible(false);
            polycountText.gameObject.SetVisible(false);
        }
    }