当前位置: 首页>>代码示例>>C#>>正文


C# InputField.Rebuild方法代码示例

本文整理汇总了C#中InputField.Rebuild方法的典型用法代码示例。如果您正苦于以下问题:C# InputField.Rebuild方法的具体用法?C# InputField.Rebuild怎么用?C# InputField.Rebuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputField的用法示例。


在下文中一共展示了InputField.Rebuild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: gaxb_init

    public override void gaxb_init()
    {
        // We call Text's gaxb_init, which creates the appropriate text component on gameObject
        base.gaxb_init ();

        textGameObject = gameObject;

        // Next, we create a new gameObject, and put the Text-created gameObject inside me
        gameObject = new GameObject ("<InputField/>", typeof(RectTransform));

        canvasRenderer = gameObject.AddComponent<CanvasRenderer> ();
        field = gameObject.AddComponent<InputField> ();

        // Move the text to be the child of the input field
        textGameObject.transform.SetParent (gameObject.transform, false);
        textGameObject.FillParentUI ();

        text.supportRichText = false;
        text.alignment = TextAnchor.UpperLeft;

        field.transition = Selectable.Transition.None;

        field.textComponent = text;

        if (contentType == PlanetUnity2.InputFieldContentType.standard) {
            field.contentType = InputField.ContentType.Standard;
        } else if (contentType == PlanetUnity2.InputFieldContentType.autocorrected) {
            field.contentType = InputField.ContentType.Autocorrected;
        } else if (contentType == PlanetUnity2.InputFieldContentType.integer) {
            field.contentType = InputField.ContentType.IntegerNumber;
        } else if (contentType == PlanetUnity2.InputFieldContentType.number) {
            field.contentType = InputField.ContentType.DecimalNumber;
        } else if (contentType == PlanetUnity2.InputFieldContentType.alphanumeric) {
            field.contentType = InputField.ContentType.Alphanumeric;
        } else if (contentType == PlanetUnity2.InputFieldContentType.name) {
            field.contentType = InputField.ContentType.Name;
        } else if (contentType == PlanetUnity2.InputFieldContentType.email) {
            field.contentType = InputField.ContentType.EmailAddress;
        } else if (contentType == PlanetUnity2.InputFieldContentType.password) {
            field.contentType = InputField.ContentType.Password;
        } else if (contentType == PlanetUnity2.InputFieldContentType.pin) {
            field.contentType = InputField.ContentType.Pin;
        } else if (contentType == PlanetUnity2.InputFieldContentType.custom) {
            field.contentType = InputField.ContentType.Custom;

            field.onValidateInput += ValidateInput;
        }

        if (lineType == PlanetUnity2.InputFieldLineType.single) {
            field.lineType = InputField.LineType.SingleLine;
        } else if (lineType == PlanetUnity2.InputFieldLineType.multiSubmit) {
            field.lineType = InputField.LineType.MultiLineSubmit;
        } else if (lineType == PlanetUnity2.InputFieldLineType.multiNewline) {
            field.lineType = InputField.LineType.MultiLineNewline;
        }

        if (placeholder != null) {
            placeholderText = new PUText ();
            placeholderText.value = this.placeholder;
            placeholderText.LoadIntoPUGameObject (this);

            placeholderText.text.horizontalOverflow = this.text.horizontalOverflow;
            placeholderText.text.verticalOverflow = this.text.verticalOverflow;

            placeholderText.text.alignment = this.text.alignment;
            placeholderText.text.font = this.text.font;
            placeholderText.text.fontSize = this.text.fontSize;
            placeholderText.text.fontStyle = this.text.fontStyle;
            placeholderText.text.color = this.text.color - new Color(0,0,0,0.5f);
            placeholderText.text.lineSpacing = this.text.lineSpacing;

            placeholderText.gameObject.FillParentUI ();

            field.placeholder = placeholderText.text;
        }

        if (limit != null) {
            field.characterLimit = (int)limit;
        }

        if (selectionColor != null) {
            field.selectionColor = selectionColor.Value;
        }

        // This is probably not the best way to do this, but 4.60.f1 removed the onSubmit event
        field.onEndEdit.AddListener ((value) => {
            if(onValueChanged != null){
                NotificationCenter.postNotification (Scope (), this.onValueChanged, NotificationCenter.Args("sender", this));
            }
        });

        foreach (Object obj in gameObject.GetComponentsInChildren<DetectTextClick>()) {
            GameObject.Destroy (obj);
        }

        field.Rebuild (CanvasUpdate.LatePreRender);
    }
开发者ID:jun-nishikawa-grm,项目名称:PlanetUnity2,代码行数:97,代码来源:PUInputField.cs


注:本文中的InputField.Rebuild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。