Пример #1
0
    /// <summary>
    /// 创建输入文本
    /// </summary>
    /// <returns>The input field.</returns>
    /// <param name="imgurl">Imgurl.</param>
    /// <param name="tip">Tip.</param>
    public UIInputField CreateInputField(string imgurl, string tip)
    {
        InputField go = CreateUI <InputField> ();

        AppendComponent <Image> (go);

        UIText placeholder = CreateText(tip, 16);

        placeholder.name = "Placeholder";
        AddChild(go, placeholder);

        UIText text = CreateText("", 16);

        text.SupportRichText = false;
        AddChild(go, text);

        UIInputField ui = AppendControl <UIInputField> (go);

        ui.TargetGraphic  = go.image;
        ui.Background.Url = imgurl;
        ui.Placeholder    = placeholder.GetComponent <Text>();
        ui.LabelComponent = text.GetComponent <Text>();
        ui.InputType      = InputField.InputType.Standard;

        return(ui);
    }
Пример #2
0
        public DisplayNameDialog(int screenWidth, int screenHeight)
        {
            int centerScreenX = screenWidth >> 1;
            int centerScreenY = screenHeight >> 1;

            int width = (int)(Constants.DisplayNameDialog_Width * screenWidth);
            int height = (int)(Constants.DisplayNameDialog_Height * screenHeight);
            int topMargin = (int)(Constants.DisplayNameDialog_MarginTopBottom * screenHeight);
            int lineSpace = (int)(Constants.DisplayNameDialog_LineSpace * screenHeight);
            int inputWidth = (int)(Constants.DisplayNameDialog_InputWidth * screenWidth);
            int inputHeight = (int)(Constants.DisplayNameDialog_InputHeight * screenHeight);
            int buttonWidth = (int)(Constants.DisplayNameDialog_ButtonWidth * screenWidth);
            int buttonHeight= (int)(Constants.DisplayNameDialog_ButtonHeight * screenHeight);

            m_Rect = new Rectangle(centerScreenX - (width >> 1), centerScreenY - (height >> 1), width, height);

            m_szTitle = "Choose a display name";
            Vector2 size = Assets.DialogFont.MeasureString(m_szTitle);
            m_vTitlePosition = new Vector2(centerScreenX - (size.X * 0.5f), m_Rect.Top + topMargin);

            m_szSecondaryText = "Pick a name for other players to see you as";
            m_vSecondaryPosition.Y = m_vTitlePosition.Y + size.Y + lineSpace;
            size = Assets.HelpFont.MeasureString(m_szSecondaryText);
            m_vSecondaryPosition.X = centerScreenX - (size.X * 0.5f);

            m_Input = new UIInputField(new Rectangle(centerScreenX - (inputWidth >> 1), (int)(m_vSecondaryPosition.Y + size.Y + lineSpace + lineSpace), inputWidth, inputHeight));
            m_Input.Focused = true;

            int buttonY = m_Input.Rect.Bottom + lineSpace;
            height = (buttonY + buttonHeight + topMargin) - m_Rect.Top;
            m_Buttons = new UIButton[2];
            m_Buttons[0] = new UIButton(0, "Done", Assets.HelpFont, new Rectangle(centerScreenX + (buttonWidth >> 1), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
            m_Buttons[1] = new UIButton(1, "Cancel", Assets.HelpFont, new Rectangle(centerScreenX - ((buttonWidth >> 1) + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
        }
Пример #3
0
        public SignInDialog(int screenWidth, int screenHeight)
        {
            m_iCenterDialogX = (screenWidth >> 1);
            int centerY = (screenHeight >> 1);

            int width = (int)(Constants.SignInDialog_Width * screenWidth);
            int height = (int)(Constants.SignInDialog_Height * screenHeight);
            int left = m_iCenterDialogX - (width >> 1);
            int top = centerY - (height >> 1);
            m_Rect = new Rectangle(left, top, width, height);

            int margin = (int)(Constants.SignInDialog_Margin * screenHeight);

            m_szTitleText = "Sign In";
            Vector2 titleSize = Assets.MenuFont.MeasureString(m_szTitleText);
            m_vTitlePosition = new Vector2(m_iCenterDialogX - (titleSize.X * 0.5f), m_Rect.Top + margin);

            int inputFieldWidth = (int)(Constants.SignInDialog_InputWidth * screenWidth);
            int inputFieldLeft = m_Rect.Left + (int)(Constants.SignInDialog_InputLeft * screenWidth);
            int inputFieldTop = m_Rect.Top + (int)(Constants.SignInDialog_InputTop * screenHeight);
            m_szEmailText = "Email:";
            Vector2 emailSize = Assets.HelpFont.MeasureString(m_szEmailText);
            m_vEmailLabelPosition = new Vector2(inputFieldLeft - (emailSize.X + 2), inputFieldTop);
            m_Email = new UIInputField(new Rectangle(inputFieldLeft, inputFieldTop, inputFieldWidth, (int)emailSize.Y));

            int passwordY = m_Email.Rect.Bottom + margin;
            m_szPasswordText = "Password:"******"Remember Me", inputFieldLeft, m_Password.Rect.Bottom + margin, screenHeight);

            int authY = m_RememberMe.Rect.Bottom + (int)(Constants.SignInDialog_AuthGap * screenHeight);
            int authSize = (int)(Constants.SignInDialog_AuthSize * screenHeight);
            m_AuthButtons = new UIButton[2];
            m_AuthButtons[0] = new UIButton(0, null, null, new Rectangle(m_iCenterDialogX - ((authSize >> 1) + authSize), authY, authSize, authSize), Assets.Facebook);
            m_AuthButtons[1] = new UIButton(1, null, null, new Rectangle(m_iCenterDialogX + (authSize >> 1), authY, authSize, authSize), Assets.Google);

            m_StatusColor = Color.White;
            m_fStatusTextY = m_AuthButtons[0].Rect.Bottom + (int)(Constants.SignInDialog_StatusGap * screenHeight);

            int btnY = m_Rect.Bottom - (int)(Constants.SignInDialog_ButtonGap * screenHeight);
            int btnX = (int)(Constants.SignInDialog_ButtonGapLeft * screenWidth);
            int btnLargeW = (int)(Constants.SignInDialog_ButtonWidthLarge * screenWidth);
            int btnSmallW = (int)(Constants.SignInDialog_ButtonWidthSmall * screenWidth);
            int btnH = (int)(Constants.SignInDialog_ButtonHeight * screenHeight);
            m_DialogButtons = new UIButton[3];
            m_DialogButtons[0] = new UIButton(0, "Sign In", Assets.DialogFont, new Rectangle(m_iCenterDialogX - (btnLargeW >> 1), btnY, btnLargeW, btnH), Assets.ScrollBar);
            m_DialogButtons[1] = new UIButton(1, "Exit", Assets.DialogFont, new Rectangle(m_Rect.Left + btnX, btnY, btnSmallW, btnH), Assets.ScrollBar);
            m_DialogButtons[2] = new UIButton(2, "Skip", Assets.DialogFont, new Rectangle(m_Rect.Right - (btnSmallW + btnX), btnY, btnSmallW, btnH), Assets.ScrollBar);

            m_Email.Focused = true;

            m_bInputEnabled = true;
            int waitSize = (int)(Constants.SignInDialog_WaitIconSize * screenHeight);
            int waitSpace = (int)(Constants.SignInDialog_WaitIconSpace * screenHeight);
            m_WaitRect = new Rectangle(m_DialogButtons[2].Rect.Right - waitSize, m_DialogButtons[2].Rect.Top - (waitSpace + waitSize), waitSize, waitSize);
        }
Пример #4
0
        /// <summary>
        /// (Protected) Adds a new <see cref="UIInputField"/> control on the page.
        /// </summary>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="text">Text</param>
        /// <param name="fontTile">The tile to use for this control's font. Font tiles must follow one another on the tilemap (but can be on multiple rows) and provide all the ASCII characters in the 32 (white space) to 126 (~) range.</param>
        /// <param name="color">Color</param>
        /// <param name="tilemap">Font tile tilemap</param>
        /// <returns>An <see cref="UIInputField"/> control</returns>
        protected UIInputField AddInputBox(int x, int y, string text, int fontTile, RGBColor color, int tilemap = 0)
        {
            UIInputField control = AddControl <UIInputField>(x, y, color, tilemap);

            control.Text     = text;
            control.FontTile = fontTile;
            return(control);
        }
Пример #5
0
 private void InitGui()
 {
     inputFieldCom             = FindComponent <UIInputField>("InputField");
     sliderCom                 = FindComponent <Slider>("Slider");
     _viewModel.rootActiveSelf = false;
     _viewModel.leftText       = minValue.ToString();
     //inputFieldCom.onValidateFailed = () => { splitUIAdapter.ShowIllegalTip(); };
 }
Пример #6
0
    public override void OnInspectorGUI()
    {
        UIInputField inputField = target as UIInputField;

        EditorTools.DrawUpdateKeyTextField(inputField);

        base.OnInspectorGUI();
    }
Пример #7
0
        protected override void InternalShowKeyboard(UIInputField inputField)
        {
            m_CurrentInput = inputField;
            InputMethodManager inputMethodManager = (InputMethodManager)Activity1.Instance.Application.GetSystemService(Context.InputMethodService);

            inputMethodManager.ShowSoftInput(Activity1.Instance.TheGame.Services.GetService <View>(), ShowFlags.Forced);
            inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
        }
Пример #8
0
        public UICreateSaveFile(Transform transform, Texture2D sprite, Screen screen, EventArg onClose) : base(transform, sprite, screen)
        {
            this.onClose = onClose;

            SetColor(new Color(56, 56, 56));

            saveFileNameInputField = AddUIElement(new UIInputField(
                                                      new Transform(new Vector2(0, -transform.Height / 2f + 37.5f), new Vector2(transform.Width, 75)),
                                                      ContentHelper.Arial_Font,
                                                      "Save file name",
                                                      20,
                                                      TextAlign.MiddleLeft,
                                                      5,
                                                      ContentHelper.Box4x4_Sprite,
                                                      screen
                                                      ));

            saveFileNameInputField.SetColor(new Color(28, 28, 28));

            playerNameInputField = AddUIElement(new UIInputField(
                                                    new Transform(new Vector2(0, -transform.Height / 2f + 112.5f), new Vector2(transform.Width, 75)),
                                                    ContentHelper.Arial_Font,
                                                    "Player name",
                                                    20,
                                                    TextAlign.MiddleLeft,
                                                    5,
                                                    ContentHelper.Box4x4_Sprite,
                                                    screen
                                                    ));

            playerNameInputField.SetColor(new Color(28, 28, 28));

            //Create button:
            AddUIElement(new UIButton(
                             new Transform(new Vector2(-55, transform.Height / 2f + 35), new Vector2(100, 50)),
                             ContentHelper.Arial_Font,
                             "Create",
                             TextAlign.MiddleCenter,
                             0,
                             ContentHelper.Box4x4_Sprite,
                             new EventArg0(CreateSaveFile),
                             screen
                             )).SetColor(new Color(28, 28, 28));

            //Close button:
            AddUIElement(new UIButton(
                             new Transform(new Vector2(55, transform.Height / 2f + 35), new Vector2(100, 50)),
                             ContentHelper.Arial_Font,
                             "Close",
                             TextAlign.MiddleCenter,
                             0,
                             ContentHelper.Box4x4_Sprite,
                             onClose,
                             screen
                             )).SetColor(new Color(28, 28, 28));
        }
Пример #9
0
    static void AddUIInputField(MenuCommand menuCommand)
    {
        GameObject root  = new GameObject("UIInputField");
        UIImage    image = root.AddComponent <UIImage>();

        image.sprite = inputFieldRes;
        image.type   = Image.Type.Sliced;
        RectTransform rootRect = root.GetComponent <RectTransform>();

        rootRect.sizeDelta = _textSize;

        GameObject childText = new GameObject("UIText");

        childText.transform.SetParent(root.transform, false);
        UIText text = childText.AddComponent <UIText>();

        text.text            = "";
        text.color           = new Color(0.1960784f, 0.1960784f, 0.1960784f, 1f);
        text.supportRichText = false;
        text.raycastTarget   = false;
        RectTransform textRectTransform = childText.GetComponent <RectTransform>();

        textRectTransform.anchorMin = Vector2.zero;
        textRectTransform.anchorMax = Vector2.one;
        textRectTransform.sizeDelta = Vector2.zero;
        textRectTransform.offsetMin = new Vector2(10, 6);
        textRectTransform.offsetMax = new Vector2(-10, -7);

        GameObject childPlaceholder = new GameObject("Placeholder");

        childPlaceholder.transform.SetParent(root.transform, false);
        UIText placeholder = childPlaceholder.AddComponent <UIText>();

        placeholder.text          = "Enter text...";
        placeholder.raycastTarget = false;
        Color placeholderColor = text.color;

        placeholderColor.a *= 0.5f;
        placeholder.color   = placeholderColor;
        RectTransform placeholderRectTransform = childPlaceholder.GetComponent <RectTransform>();

        placeholderRectTransform.anchorMin = Vector2.zero;
        placeholderRectTransform.anchorMax = Vector2.one;
        placeholderRectTransform.sizeDelta = Vector2.zero;
        placeholderRectTransform.offsetMin = new Vector2(10, 6);
        placeholderRectTransform.offsetMax = new Vector2(-10, -7);

        UIInputField inputField = root.AddComponent <UIInputField>();

        inputField.textComponent = text;
        inputField.placeholder   = placeholder;
        inputField.transition    = Selectable.Transition.None;

        PlaceUIElementRoot(menuCommand, root);
    }
Пример #10
0
        protected override void OnInitialize(object[] parameters)
        {
            AddFrame(0, 0, UI.Game.Renderer.TileCount.Width, UI.Game.Renderer.TileCount.Height, (int)TileID.Frame, RGBColor.Goldenrod);
            AddLabel(2, 2, "UI CONTROLS DEMO", (int)TileID.Font, RGBColor.PaleGoldenrod);

            InputField            = AddInputField(2, 4, "Your text here", (int)TileID.Font, RGBColor.White);
            InputField.MaxLength  = 32;
            InputField.ReadInputs = true;

            AddLabel(2, UI.Game.Renderer.TileCount.Height - 3, "ESC / Gamepad B button: Back", (int)TileID.Font, RGBColor.PaleGoldenrod);
        }
Пример #11
0
    public override void OnInspectorGUI()
    {
        UIInputField txt = target as UIInputField;

        txt.IsAutoClose = EditorGUILayout.Toggle("IsAutoClose", txt.IsAutoClose);
        int controlID = EditorGUILayout.IntField("ControlID", txt.controlID);

        if (txt.controlID != controlID)
        {
            txt.controlID = controlID;
        }
        base.OnInspectorGUI();
    }
Пример #12
0
 void Start()
 {
     AccountText                       = Utility.GameUtility.FindDeepChild <UIInputField>(gameObject, "AccountInputField");
     PasswordText                      = Utility.GameUtility.FindDeepChild <UIInputField> (gameObject, "PassWordInputField");
     RepeatePassInputField             = Utility.GameUtility.FindDeepChild <UIInputField> (gameObject, "RepeatPassWordInputField");
     AccountText.contentType           = UnityEngine.UI.InputField.ContentType.Custom;
     PasswordText.contentType          = UnityEngine.UI.InputField.ContentType.Password;
     RepeatePassInputField.contentType = UnityEngine.UI.InputField.ContentType.Password;
     BackBtn = Utility.GameUtility.FindDeepChild <UIButton> (gameObject, "BackBtn");
     AddClick(BackBtn.gameObject, OnClickBackBtn);
     SureBtn = Utility.GameUtility.FindDeepChild <UIButton> (gameObject, "SureButton");
     AddClick(SureBtn.gameObject, OnClickSureBtn);
 }
Пример #13
0
    public override void Initalize()
    {
        base.Initalize();
        AccountText   = Utility.GameUtility.FindDeepChild <UIInputField>(gameObject, "AccountInputField");
        PasswordText  = Utility.GameUtility.FindDeepChild <UIInputField>(gameObject, "PassWordInputField");
        FogetPassWord = Utility.GameUtility.FindDeepChild <UIText>(gameObject, "FogetPassWord");
        SureButton    = Utility.GameUtility.FindDeepChild <UIButton>(gameObject, "SureButton");
        AddClick(SureButton.gameObject, OnClickSureButton);

        RegisterButton = Utility.GameUtility.FindDeepChild <UIButton>(gameObject, "RegisterButton");
        AddClick(RegisterButton.gameObject, OnClickRegisterButton);

        AccountList = Utility.GameUtility.FindDeepChild <UIScrollView>(gameObject, "Account");
    }
Пример #14
0
 static int OnSubmit(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIInputField obj = (UIInputField)ToLua.CheckObject <UIInputField>(L, 1);
         UnityEngine.EventSystems.BaseEventData arg0 = (UnityEngine.EventSystems.BaseEventData)ToLua.CheckObject <UnityEngine.EventSystems.BaseEventData>(L, 2);
         obj.OnSubmit(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #15
0
 static int EndEdit(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIInputField obj  = (UIInputField)ToLua.CheckObject(L, 1, typeof(UIInputField));
         string       arg0 = ToLua.CheckString(L, 2);
         obj.EndEdit(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #16
0
    static int get_enableValueChangeEvent(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj = (UIInputField)o;
            bool         ret = obj.enableValueChangeEvent;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index enableValueChangeEvent on a nil value"));
        }
    }
Пример #17
0
    static int set_enableValueChangeEvent(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj  = (UIInputField)o;
            bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.enableValueChangeEvent = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index enableValueChangeEvent on a nil value"));
        }
    }
Пример #18
0
    static int set_uiMod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj  = (UIInputField)o;
            UIMod        arg0 = (UIMod)ToLua.CheckUnityObject(L, 2, typeof(UIMod));
            obj.uiMod = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uiMod on a nil value" : e.Message));
        }
    }
Пример #19
0
    static int set_IsFilterEmoji(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj  = (UIInputField)o;
            bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.IsFilterEmoji = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsFilterEmoji on a nil value" : e.Message));
        }
    }
Пример #20
0
    static int set_uiMod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj  = (UIInputField)o;
            UIMod        arg0 = (UIMod)ToLua.CheckObject <UIMod>(L, 2);
            obj.uiMod = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uiMod on a nil value"));
        }
    }
Пример #21
0
    static int get_controlID(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj = (UIInputField)o;
            int          ret = obj.controlID;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index controlID on a nil value"));
        }
    }
Пример #22
0
    static int get_IsFilterEmoji(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj = (UIInputField)o;
            bool         ret = obj.IsFilterEmoji;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsFilterEmoji on a nil value" : e.Message));
        }
    }
Пример #23
0
    static int set_controlID(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj  = (UIInputField)o;
            int          arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.controlID = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index controlID on a nil value"));
        }
    }
Пример #24
0
    static int get_uiMod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIInputField obj = (UIInputField)o;
            UIMod        ret = obj.uiMod;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uiMod on a nil value"));
        }
    }
Пример #25
0
 static int ValidateInput(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         UIInputField obj  = (UIInputField)ToLua.CheckObject(L, 1, typeof(UIInputField));
         string       arg0 = ToLua.CheckString(L, 2);
         int          arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         char         arg2 = (char)LuaDLL.luaL_checknumber(L, 4);
         char         o    = obj.ValidateInput(arg0, arg1, arg2);
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #26
0
        public static GameObject CreateInputField(UIDefaultControls.Resources resources)
        {
            GameObject gameObject = UIDefaultControls.CreateUIElementRoot("UIInputField", UIDefaultControls.s_ThickElementSize);
//			GameObject gameObject2 = UIDefaultControls.CreateUIObject ("Placeholder", gameObject);
            GameObject gameObject3 = UIDefaultControls.CreateUIObject("UILabel", gameObject);
            UISprite   image       = gameObject.AddComponent <UISprite> ();

            image.sprite = resources.inputField;
            image.type   = UISprite.Type.Sliced;
            image.color  = UIDefaultControls.s_DefaultSelectableColor;
            UIInputField inputField = gameObject.AddComponent <UIInputField> ();

            UIDefaultControls.SetDefaultColorTransitionValues(inputField);
            UILabel text = gameObject3.AddComponent <UILabel> ();

            text.text            = string.Empty;
            text.supportRichText = false;
            UIDefaultControls.SetDefaultTextValues(text);
//			UILabel text2 = gameObject2.AddComponent<UILabel> ();
//			text2.text = "Enter text...";
//			text.UseRTSprite = false;
//			text2.fontStyle =  FontStyle.BoldAndItalic;
//			Color color = text.color;
//			color.a *= 0.5f;
//			text2.color = color;
            RectTransform component = gameObject3.GetComponent <RectTransform> ();

            component.anchorMin = (Vector2.zero);
            component.anchorMax = (Vector2.one);
            component.sizeDelta = (Vector2.zero);
            component.offsetMin = (new Vector2(10, 6));
            component.offsetMax = (new Vector2(-10, -7));
//			RectTransform component2 = gameObject2.GetComponent<RectTransform> ();
//			component2.anchorMin =(Vector2.zero);
//			component2.anchorMax =(Vector2.one);
//			component2.sizeDelta =(Vector2.zero);
//			component2.offsetMin =(new Vector2 (10, 6));
//			component2.offsetMax =(new Vector2 (-10, -7));
            inputField.textComponent = text;
//			inputField.placeholder = text2;
            return(gameObject);
        }
Пример #27
0
    public void Start()
    {
        inputFieldSeed      = new UIInputField(InputFieldSeed);
        toggleRandomizeSeed = new UIToggle(ToggleRandomizeSeed);
        buttonStart         = new UIButton(ButtonCreateWorld);

        inputFieldSeed.UpdatePlaceholder("Enter world seed...");
        inputFieldSeed.AddListener(() =>
        {
            World.StringSeed = inputFieldSeed.Instance.text;
        });

        toggleRandomizeSeed.AddListener(() =>
        {
            World.RandomizeSeed = !World.RandomizeSeed;
        });

        buttonStart.AddListener(() =>
        {
            StartCoroutine(Utils.LoadAsynchronously("Loading"));
        });
    }
Пример #28
0
    public override bool Init()
    {
        if (base.Init() == false)
        {
            return(false);
        }

        image_bg   = GetComponent <Image>();
        inputfield = GetComponentInChildren <UIInputField>();
        foreach (UIElement e in GetComponentsInChildren <UIElement>())
        {
            if (e.GetUIType() == UIType.TEXT_LABEL)
            {
                text_label = e.GetComponent <Text>();
                break;
            }
        }

        AddCallbackOnChanged(OnChanged);
        AddCallbackOnEntered(OnEntered);

        return(true);
    }
Пример #29
0
        public UIData(Transform root, Transform tr)
        {
            Vector2 piv = new Vector2(0.5f, 0.5f);

            if (tr is RectTransform)
            {
                piv = (tr as RectTransform).pivot;
            }
            Vector2 pos = root.InverseTransformPoint(tr.position);

            name          = tr.name;
            pivot         = new Float2(piv.x, piv.y);
            scale         = new Float2(tr.localScale.x, tr.localScale.y);
            position      = new Int2(pos.x, pos.y);
            localPosition = new Int2(tr.localPosition.x * 1, tr.localPosition.y * 1);
            go            = tr.gameObject;

            Component comp = tr.GetComponent <SpriteRenderer>();

            if (comp != null)
            {
                SpriteRenderer c = comp as SpriteRenderer;
                if (c.sprite != null)
                {
                    component = new UIComponentSprite(c.sprite.name, Utill.Utill.ColorToHex(c.color), c.color.a
                                                      , comp.GetComponent <UIInteractive>() != null ? true : false);
                }
                else
                {
                    component = new UIComponentSprite("null", Utill.Utill.ColorToHex(c.color), c.color.a
                                                      , comp.GetComponent <UIInteractive>() != null ? true : false);
                    (component as UIComponentSprite).width  = (tr as RectTransform).sizeDelta.x;
                    (component as UIComponentSprite).height = (tr as RectTransform).sizeDelta.y;
                }
            }

            comp = tr.GetComponent <Image>();
            if (comp != null)
            {
                Image  image  = comp as Image;
                Button button = tr.GetComponent <Button>();

                if (button != null)
                {
                    string    normal     = "";
                    string    over       = "";
                    string    push       = "";
                    string    disabled   = "";
                    int       transition = 0;
                    bool      isBorder   = false;
                    IntBorder border     = new IntBorder();
                    int       width      = 0;
                    int       height     = 0;

                    if (image.type == Image.Type.Sliced)
                    {
                        isBorder = true;
                        float   rate = image.sprite.pixelsPerUnit / 100f;
                        Vector4 bor  = image.sprite.border;
                        bor   /= rate;
                        border = new IntBorder(bor);
                        width  = (int)image.rectTransform.sizeDelta.x;
                        height = (int)image.rectTransform.sizeDelta.y;
                    }


                    if (button.transition == Selectable.Transition.SpriteSwap)
                    {
                        transition = 2;
                        normal     = image.sprite.name;
                        over       = button.spriteState.highlightedSprite != null ? button.spriteState.highlightedSprite.name : normal;
                        push       = button.spriteState.pressedSprite != null ? button.spriteState.pressedSprite.name : normal;
                        disabled   = button.spriteState.disabledSprite != null ? button.spriteState.disabledSprite.name : "";
                        component  = new UIComponentButton(transition, normal, over, push, disabled);

                        if (isBorder)
                        {
                            UIComponentButton componentButton = component as UIComponentButton;
                            componentButton.isBorder = isBorder;
                            componentButton.border   = border;
                            componentButton.width    = width;
                            componentButton.height   = height;
                        }
                    }
                    else if (button.transition == Selectable.Transition.ColorTint)
                    {
                        transition = 1;
                        normal     = "0x" + Utill.Utill.ColorToHex(button.colors.normalColor);
                        over       = "0x" + Utill.Utill.ColorToHex(button.colors.highlightedColor);
                        push       = "0x" + Utill.Utill.ColorToHex(button.colors.pressedColor);
                        disabled   = "0x" + Utill.Utill.ColorToHex(button.colors.disabledColor);
                        component  = new UIComponentButton(transition, normal, over, push, disabled);
                        UIComponentButton componentButton = component as UIComponentButton;
                        componentButton.spriteName = image.sprite.name;

                        if (isBorder)
                        {
                            componentButton.isBorder = isBorder;
                            componentButton.border   = border;
                            componentButton.width    = width;
                            componentButton.height   = height;
                        }
                    }
                }
                else if (image.sprite != null && image.type == Image.Type.Sliced)
                {
                    float   rate = image.sprite.pixelsPerUnit / 100f;
                    Vector4 bor  = image.sprite.border;
                    bor /= rate;

                    component = new UIComponentSpriteBorder(image.sprite.name
                                                            , new IntBorder(bor)
                                                            , image.rectTransform.sizeDelta.x
                                                            , image.rectTransform.sizeDelta.y
                                                            , Utill.Utill.ColorToHex(image.color)
                                                            , image.color.a
                                                            , comp.GetComponent <UIInteractive>() != null ? true : false
                                                            );
                }
                else if (image.sprite != null && image.type == Image.Type.Tiled)
                {
                    float rate = image.sprite.pixelsPerUnit / 100f;

                    component = new UIComponentSpriteTiled(image.sprite.name
                                                           , image.rectTransform.sizeDelta.x
                                                           , image.rectTransform.sizeDelta.y
                                                           , Utill.Utill.ColorToHex(image.color)
                                                           , image.color.a
                                                           , comp.GetComponent <UIInteractive>() != null ? true : false
                                                           );
                }
                else
                {
                    //component = new UIComponentSprite(image.sprite.name, Utill.Utill.ColorToHex(image.color), image.color.a
                    //    , comp.GetComponent<UIInteractive>() != null ? true : false);

                    if (image.sprite != null)
                    {
                        component = new UIComponentSprite(image.sprite.name, Utill.Utill.ColorToHex(image.color), image.color.a
                                                          , comp.GetComponent <UIInteractive>() != null ? true : false);
                    }
                    else
                    {
                        component = new UIComponentSprite("null", Utill.Utill.ColorToHex(image.color), image.color.a
                                                          , comp.GetComponent <UIInteractive>() != null ? true : false);
                        (component as UIComponentSprite).width  = (tr as RectTransform).sizeDelta.x;
                        (component as UIComponentSprite).height = (tr as RectTransform).sizeDelta.y;
                    }
                }
            }

            comp = tr.GetComponent <Text>();
            if (comp != null)
            {
                Text text  = comp as Text;
                int  width = 0;

                if (text.horizontalOverflow == HorizontalWrapMode.Wrap)
                {
                    width = (int)text.rectTransform.sizeDelta.x;
                }

                bool isNormal = tr.GetComponent <UINormalFont>() == null ? false : true;

                string align = text.alignment.ToString().Replace("Upper", "").Replace("Middle", "").Replace("Lower", "");
                component = new UIComponentText(text.font.name, text.text.Replace("\n", "\\n").Replace("\r", ""), text.fontSize
                                                , Utill.Utill.ColorToHex(text.color), align.ToLower(), width, isNormal);
            }

            comp = tr.GetComponent <UIInputField>();
            if (comp != null)
            {
                UIInputField  input = comp as UIInputField;
                RectTransform rtr   = comp.GetComponent <RectTransform>();
                component = new UIComponentInput(input.placeholder, (int)rtr.sizeDelta.x, (int)rtr.sizeDelta.y
                                                 , input.fontSize, Utill.Utill.ColorToHex(input.fontColor), Utill.Utill.ColorToHex(input.placeholderColor)
                                                 , input.isTextArea, input.isPassword, input.isNumberOnly);
            }

            comp = tr.GetComponent <UIScroll>();
            if (comp != null)
            {
                UIScroll scroll = comp as UIScroll;
                component = new UIComponentScroll(scroll.scrollArea.name, scroll.scrollMask.name,
                                                  scroll.scrollbar_bar.name, scroll.scrollbar_bg.name);
            }

            comp = tr.GetComponent <UIMask>();
            if (comp != null)
            {
                RectTransform rtr = comp.GetComponent <RectTransform>();
                component = new UIComponentMask((int)rtr.sizeDelta.x, (int)rtr.sizeDelta.y);
            }

            comp = tr.GetComponent <UIToggleGroup>();
            if (comp != null)
            {
                UIToggleGroup tg = comp as UIToggleGroup;
                component = new UIComponentToggleGroup(tg.toggles, tg.defaultIndex);
            }

            int count = tr.childCount;

            for (int i = 0; i < count; i++)
            {
                children.Add(new UIData(root, tr.transform.GetChild(i)));
            }
        }