Ejemplo n.º 1
0
    //This function adds button to the List
    private void AddButtons()
    {
        for (int i = 0; i < itemList.Length; i++)
        {
            string language = itemList[i];

            Button newButton = Instantiate(PrefabButton);
            newButton.transform.SetParent(ContentPanel, false);

            ButtonLanguage sampleButton = newButton.GetComponent <ButtonLanguage>();
            sampleButton.Setup(language);
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 在对话框中显示提示,等待用户输入文本或单击按钮,然后返回包含文本框内容的字符串。
        /// </summary>
        /// <param name="Prompt">String类型的变量或表达式,作为消息显示在对话框中</param>
        /// <param name="Caption">String类型的变量或表达式,作为对话框的标题</param>
        /// <param name="DefaultValue">String类型的变量或表达式,作为文本框的默认值</param>
        /// <param name="CancelButtonEnabled">指示取消按钮是否可用</param>
        /// <param name="ButtonLanguage">指示按钮所使用的语言</param>
        /// <returns>返回值为字符串</returns>
        public static string InputBox(string Prompt, string Caption, string DefaultValue, CancelButtonEnabled CancelButtonEnabled, ButtonLanguage ButtonLanguage)
        {
            if (Prompt.Length > PromptLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Prompt的长度不可超过" + PromptLengthMAX + "个字符");
                throw iex;
            }
            if (Caption.Length > CaptionLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Caption的长度不可超过" + CaptionLengthMAX + "个字符");
                throw iex;
            }
            if (DefaultValue.Length > DefaultValueLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数DefaultValue的长度不可超过" + DefaultValueLengthMAX + "个字符");
                throw iex;
            }
            string Value;
            Input  fi = Input.fi;

            fi.Caption.Text  = Prompt;
            fi.Text          = Caption;
            fi.Value         = DefaultValue;
            fi.txtValue.Text = fi.Value;
            if (CancelButtonEnabled == CancelButtonEnabled.Invisible)
            {
                fi.Cancel.Enabled = false;
            }
            if (ButtonLanguage == ButtonLanguage.Chinese)
            {
                fi.OK.Text     = "确定(&O)";
                fi.Cancel.Text = "取消(&C)";
            }
            else if (ButtonLanguage == ButtonLanguage.English)
            {
                fi.OK.Text     = "&OK";
                fi.Cancel.Text = "&Cancel";
            }
            //else if (ButtonLanguage == ButtonLanguage.Japanese)
            //{
            //    fi.OK.Text = "かくてい";
            //    fi.Cancel.Text = "キヤソセル";
            //}
            fi.Height = Math.Max(240, fi.Caption.Height + 100);
            fi.ShowDialog();
            Value = fi.Value;
            if (AutoInitialization)
            {
                Initialization();
            }
            return(Value);
        }