Example #1
0
        // Down
        override protected void OnPointerDownBasic(PointerEventData tPointer, bool tFromScrollView)
        {
            base.OnPointerDownBasic(tPointer, tFromScrollView);

            m_PointerId = tPointer.pointerId;

            m_BasePosition = GetLocalPosition(tPointer);

            frame.SetPosition(m_BasePosition);
            frame.SetSize(frameWidth, frameWidth);

            m_Volume        = 0;
            m_Direction     = Vector2.zero;
            m_DeltaPosition = Vector2.zero;

            float thumbWidth = frameWidth * thumbScale;

            thumb.SetPosition(0, 0);
            thumb.SetSize(thumbWidth, thumbWidth);

            frame.SetActive(true);

            if (m_OnValueChangedAction != null)
            {
                m_OnValueChangedAction(Identity, this, m_Volume, m_Direction);
            }
        }
Example #2
0
        //-----------------------------------------------------------

        /// <summary>
        /// 各派生クラスでの初期化処理を行う(メニューまたは AddView から生成される場合のみ実行れる)
        /// </summary>
        /// <param name="tOption"></param>
        override protected void OnBuild(string tOption = "")
        {
            SetAnchorToLeftStretch();
            Vector2 tSize = GetCanvasSize();

            if (tSize.x > 0 && tSize.y > 0)
            {
                _w = tSize.x * 0.5f;
            }
            SetPivot(0, 0);

            Image tImage = _image;

            tImage.color = new Color32(255, 255, 255, 32);

            isCanvasGroup  = true;
            isEventTrigger = true;

            UIAtlasSprite tAtlas = UIAtlasSprite.Create("uGUIHelper/Textures/UISimpleJoystick");

            UIImage tFrame = AddView <UIImage>("Frame");

            tFrame.SetAnchorToLeftBottom();
            tFrame.sprite = tAtlas["UISimpleJoystick_Frame_Type_0"];
            tFrame.SetSize(frameWidth, frameWidth);
            frame = tFrame;

            float thumbWidth = frameWidth * thumbScale;

            UIImage tThumb = tFrame.AddView <UIImage>("Thumb");

            tThumb.SetAnchorToCenter();
            tThumb.sprite = tAtlas["UISimpleJoystick_Thumb_Type_0"];
            tThumb.SetSize(thumbWidth, thumbWidth);
            thumb = tThumb;

//			DestroyImmediate( tAtlas ) ;
        }
Example #3
0
        //---------------------------------------------

        // 各派生クラスでの初期化処理を行う(メニューまたは AddView から生成される場合のみ実行れる)
        override protected void OnBuild(string option = "")
        {
            Toggle toggle = _toggle;

            if (toggle == null)
            {
                toggle = gameObject.AddComponent <Toggle>();
            }
            if (toggle == null)
            {
                // 異常
                return;
            }

            //-------------------------

            Vector2 tSize = GetCanvasSize();

            if (tSize.x > 0 && tSize.y > 0)
            {
                SetSize(tSize.y * 0.25f, tSize.y * 0.05f);
            }

            // Background
            background = AddView <UIImage>("Background");
            background.SetAnchorToLeftMiddle();
            background.SetPosition(_h * 0.5f, 0);
            background.SetSize(_h, _h);
            background.sprite     = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultFrame");
            background.type       = Image.Type.Sliced;
            background.fillCenter = true;

            background.raycastTarget = true;                    // 必須

            if (isCanvasOverlay == true)
            {
                background.material = Resources.Load <Material>("uGUIHelper/Shaders/UI-Overlay-Default");
            }

            toggle.targetGraphic = background._image;

            // Checkmark
            checkmark = background.AddView <UIImage>("Checkmark");
            checkmark.SetAnchorToCenter();
            checkmark.SetSize(_h, _h);
            checkmark.sprite = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultCheck");

            if (isCanvasOverlay == true)
            {
                checkmark.material = Resources.Load <Material>("uGUIHelper/Shaders/UI-Overlay-Default");
            }

            toggle.graphic = checkmark._image;

            // Label
            label = AddView <UIText>("Label");
            label.SetAnchorToLeftMiddle();
            label.SetPosition(_h * 1.2f, 0);
            label.SetPivot(0, 0.5f);
            //		label.text = "Toggle" ;
            label.fontSize = ( int )(_h * 0.75f);

            if (isCanvasOverlay == true)
            {
                label.material = Resources.Load <Material>("uGUIHelper/Shaders/UI-Overlay-Default");
            }

            //----------------------------------------

            // 親にグループがアタッチされていればグループとみなす
            ToggleGroup toggleGroup = GetComponentInParent <ToggleGroup>();

            if (toggleGroup != null)
            {
                toggle.group = toggleGroup;
            }

            //----------------------------------------

            ResetRectTransform();
        }
Example #4
0
        /// <summary>
        /// 各派生クラスでの初期化処理を行う(メニューまたは AddView から生成される場合のみ実行れる)
        /// </summary>
        /// <param name="tOption"></param>
        override protected void OnBuild(string tOption = "")
        {
            Dropdown tDropdown = _dropdown;

            if (tDropdown == null)
            {
                tDropdown = gameObject.AddComponent <Dropdown>();
            }
            if (tDropdown == null)
            {
                // 異常
                return;
            }

            Image tImage = _image;

            //------------------------------------------

            Vector2 tSize = GetCanvasSize();

            if (tSize.x > 0 && tSize.y > 0)
            {
                SetSize(tSize.y * 0.28f, tSize.y * 0.05f);
            }

            ColorBlock tColorBlock = tDropdown.colors;

            tColorBlock.fadeDuration = 0.1f;
            tDropdown.colors         = tColorBlock;

            tImage.sprite = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultButton");
            tImage.color  = Color.white;
            tImage.type   = Image.Type.Sliced;

            // 初期のオプションを追加する
            Dropdown.OptionData tDataA = new Dropdown.OptionData();
            tDataA.text = "Option A";
            tDropdown.options.Add(tDataA);
            Dropdown.OptionData tDataB = new Dropdown.OptionData();
            tDataB.text = "Option B";
            tDropdown.options.Add(tDataB);
            Dropdown.OptionData tDataC = new Dropdown.OptionData();
            tDataC.text = "Option C";
            tDropdown.options.Add(tDataC);

            // Label
            UIText tLabel = AddView <UIText>("Label", "FitOff");

            tLabel.text = tDropdown.options[0].text;
            tLabel.SetAnchorToStretch();
            tLabel.SetMargin(10, 25, 7, 6);
            tLabel._text.alignment = TextAnchor.MiddleLeft;
//			tLabel._text.fontSize = 0 ;
            tLabel._text.color = new Color32(50, 50, 50, 255);

            tDropdown.captionText = tLabel._text;


            // Arrow
            UIImage tArrow = AddView <UIImage>("Arrow");

            tArrow.sprite = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultArrowDown");
            tArrow.color  = Color.white;
            tArrow.type   = Image.Type.Sliced;

            tArrow.SetAnchorToRightMiddle();
            tArrow.SetPosition(-18, 0);
            float s = _h * 0.6f;

            tArrow.SetSize(s, s);


            // ScrollView
            UIScrollView tScrollView = AddView <UIScrollView>("Template", "Dropdown");

            tScrollView.SetAnchorToStretchBottom();
            tScrollView.SetPosition(0, 2);
            tScrollView.SetSize(0, _h * 5);
            tScrollView.SetPivot(0.5f, 1.0f);
            //		tScrollView.SetColor( 0xFFFFFFFF ) ;
            tScrollView.isVerticalScrollber = true;
            tScrollView._scrollRect.verticalScrollbarSpacing = -2;

            tScrollView.content._h = _h;

            tDropdown.template = tScrollView._rectTransform;

            // テンプレートアイテムを1つ追加する
            tScrollView.dropdownItem._h = _h;

            // 最後に無効化
            tScrollView.SetActive(false);

            ResetRectTransform();
        }
Example #5
0
        // 各派生クラスでの初期化処理を行う(メニューまたは AddView から生成される場合のみ実行れる)
        override protected void OnBuild(string tOption = "")
        {
            Slider tSlider = _slider;

            if (tSlider == null)
            {
                tSlider = gameObject.AddComponent <Slider>();
            }
            if (tSlider == null)
            {
                // 異常
                return;
            }

            //---------------------------------

            Direction tDirection = Direction.Unknown;

            if (tOption.ToLower() == "h")
            {
                tDirection = Direction.Horizontal;
            }
            else
            if (tOption.ToLower() == "v")
            {
                tDirection = Direction.Vertical;
            }

            Vector2 tSize = GetCanvasSize();

            if (tSize.x > 0 && tSize.y > 0)
            {
                float s;
                if (tSize.x <= tSize.y)
                {
                    s = tSize.x;
                }
                else
                {
                    s = tSize.y;
                }

                if (tDirection == Direction.Horizontal)
                {
                    SetSize(s * 0.25f, s * 0.05f);
                    tSlider.direction = Slider.Direction.LeftToRight;
                }
                else
                if (tDirection == Direction.Vertical)
                {
                    SetSize(s * 0.05f, s * 0.25f);
                    tSlider.direction = Slider.Direction.BottomToTop;
                }
            }

            ResetRectTransform();

            UIImage tBackground = AddView <UIImage>("Background");

            if (tDirection == Direction.Horizontal)
            {
                tBackground.SetAnchorMinAndMax(0.00f, 0.25f, 1.00f, 0.75f);
            }
            else
            if (tDirection == Direction.Vertical)
            {
                tBackground.SetAnchorMinAndMax(0.25f, 0.00f, 0.75f, 1.00f);
            }
            tBackground.SetMargin(0, 0, 0, 0);
            tBackground.sprite     = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultFrame");
            tBackground.type       = Image.Type.Sliced;
            tBackground.fillCenter = true;
            tBackground.SetSize(0, 0);

            UIView tFillArea = AddView <UIView>("Fill Area");

            if (tDirection == Direction.Horizontal)
            {
                tFillArea.SetAnchorMinAndMax(0.00f, 0.25f, 1.00f, 0.75f);
                tFillArea.SetMargin(5, 15, 0, 0);
            }
            else
            if (tDirection == Direction.Vertical)
            {
                tFillArea.SetAnchorMinAndMax(0.25f, 0.00f, 0.75f, 1.00f);
                tFillArea.SetMargin(0, 0, 5, 15);
            }

            UIImage tFill = tFillArea.AddView <UIImage>("Fill");

            tFill.SetAnchorMinAndMax(0.00f, 0.00f, 1.00f, 1.00f);
            tFill.sprite     = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultButton");
            tFill.type       = Image.Type.Sliced;
            tFill.fillCenter = true;
            if (tDirection == Direction.Horizontal)
            {
                tFill.SetMargin(-5, -5, 0, 0);
            }
            else
            if (tDirection == Direction.Vertical)
            {
                tFill.SetMargin(0, 0, -5, -5);
            }

            tSlider.fillRect = tFill._rectTransform;


            UIView tHandleSlideArea = AddView <UIView>("Handle Slide Area");

            tHandleSlideArea.SetAnchorToStretch();
            if (tDirection == Direction.Horizontal)
            {
                tHandleSlideArea.SetMargin(10, 10, 0, 0);
            }
            else
            if (tDirection == Direction.Vertical)
            {
                tHandleSlideArea.SetMargin(0, 0, 10, 10);
            }

            UIImage tHandle = tHandleSlideArea.AddView <UIImage>("Handle");

            if (tDirection == Direction.Horizontal)
            {
                tHandle.SetAnchorToRightStretch();
                tHandle._x = 0;
                tHandle._w = _h * 1.0f;
                tHandle.SetMarginY(0, 0);
            }
            else
            if (tDirection == Direction.Vertical)
            {
                tHandle.SetAnchorToStretchTop();
                tHandle._y = 0;
                tHandle._h = _w * 1.0f;
                tHandle.SetMarginX(0, 0);
            }

            tHandle.sprite = Resources.Load <Sprite>("uGUIHelper/Textures/UIDefaultButton");

            tSlider.targetGraphic = tHandle._image;
            tSlider.handleRect    = tHandle._rectTransform;
        }