Пример #1
0
    public override void Rendering()
    {
        /***** rendering *****/
        // make renderer gameobject
        rendererObj = new GameObject("Renderer");
        rendererObj.transform.SetParent(_parentObj.transform, false);

        // center pivot position setting
        centerObj = new GameObject("Center");
        centerObj.transform.SetParent(rendererObj.transform, false);
        centerObj.transform.localPosition = new Vector3(0, 0, _sSettings.InnerRadius + (_sSettings.Thickness / 2));

        // build arc item background ui
        backgroundObj = new GameObject("Background");
        backgroundObj.transform.SetParent(rendererObj.transform, false);
        focusingObj = new GameObject("Focusing");
        focusingObj.transform.SetParent(rendererObj.transform, false);
        selectingObj = new GameObject("Selecting");
        selectingObj.transform.SetParent(rendererObj.transform, false);

        _uiArcItemBg = backgroundObj.AddComponent <UIArcItem> ();
        _uiArcItemBg.Build(_sSettings);
        _uiArcItemBg.UpdateMesh(_innerRadius, _outerRadius, _backgroundColor);

        _uiArcItemFs = focusingObj.AddComponent <UIArcItem> ();
        _uiArcItemFs.Build(_sSettings);

        _uiArcItemSt = selectingObj.AddComponent <UIArcItem> ();
        _uiArcItemSt.Build(_sSettings);


        // build item label ui
        labelObj = new GameObject("Label");
        labelObj.transform.SetParent(rendererObj.transform, false);
        labelObj.transform.localPosition = new Vector3(0, 0, (_sSettings.InnerRadius + ((_sSettings.Thickness) / 2) - 0.1f));
        labelObj.transform.localRotation = Quaternion.FromToRotation(Vector3.back, Vector3.right);
        labelObj.transform.localScale    = new Vector3(1, 1, 1);

        UIItemLabel _uiItemLabel = labelObj.AddComponent <UIItemLabel>();

        _uiItemLabel.SetAttributes(_label, _sSettings.TextFont, _sSettings.TextSize, _sSettings.TextColor, (_sSettings.Thickness - 0.2f) * 500.0f);
        _uiItemLabel.SetTextAlignment(_textAlignment);

        // rotate text for easy read
        if (_textRotation == TextRotationType.Upright)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, -90.0f));
        }
        else if (_textRotation == TextRotationType.Upsidedown)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, 90.0f));
        }
        else if (_textRotation == TextRotationType.Right)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, 180.0f));
        }

        // each type's ui
        switch (_itemType)
        {
        case (ItemType.Parent):
            GameObject labelHasChildObj = new GameObject("HasChildArrow");
            labelHasChildObj.transform.SetParent(rendererObj.transform, false);
            labelHasChildObj.transform.localPosition = new Vector3(0, 0, (_sSettings.InnerRadius + _sSettings.Thickness) * 0.95f);
            labelHasChildObj.transform.localRotation = Quaternion.FromToRotation(Vector3.back, Vector3.right);
            labelHasChildObj.transform.localScale    = new Vector3(1, 1, 1);

            UIHasChild uiLabelHasChild = labelHasChildObj.AddComponent <UIHasChild>();
            uiLabelHasChild.SetAttributes("▶", _sSettings.TextFont, _sSettings.TextSize, _sSettings.TextColor);

            break;

        case (ItemType.NormalButton):

            break;

        default:
            break;
        }
    }
Пример #2
0
    public override void Rendering()
    {
        /***** rendering *****/
        // make renderer gameobject
        rendererObj = new GameObject("Renderer");
        rendererObj.transform.SetParent(_parentObj.transform, false);

        // center pivot position setting
        centerObj = new GameObject("Center");
        centerObj.transform.SetParent(rendererObj.transform, false);
        centerObj.transform.localPosition = new Vector3(_width / 2, _height / 2, 0);

        // build arc item background ui
        backgroundObj = new GameObject("Background");
        backgroundObj.transform.SetParent(rendererObj.transform, false);
        focusingObj = new GameObject("Focusing");
        focusingObj.transform.SetParent(rendererObj.transform, false);
        selectingObj = new GameObject("Selecting");
        selectingObj.transform.SetParent(rendererObj.transform, false);

        _uiStickItemBg = backgroundObj.AddComponent <UIStickItem> ();
        _uiStickItemBg.Build(_sSettings);
        _uiStickItemBg.UpdateMesh(_width, _height, 0.0f, 0.0f, _backgroundColor);

        _uiStickItemFs = focusingObj.AddComponent <UIStickItem> ();
        _uiStickItemFs.Build(_sSettings);

        _uiStickItemSt = selectingObj.AddComponent <UIStickItem> ();
        _uiStickItemSt.Build(_sSettings);

        // build item label ui
        labelObj = new GameObject("Label");
        labelObj.transform.SetParent(rendererObj.transform, false);
        labelObj.transform.localPosition = new Vector3(_sSettings.ItemWidth / 2 - 0.1f, _sSettings.ItemHeight / 2, 0);
        labelObj.transform.localRotation = Quaternion.FromToRotation(Vector3.back, Vector3.down);
        labelObj.transform.localScale    = new Vector3(1, 1, 1);

        UIItemLabel _uiItemLabel = labelObj.AddComponent <UIItemLabel>();

        _uiItemLabel.SetAttributes(_label, _sSettings.TextFont, _sSettings.TextSize, _sSettings.TextColor, (_sSettings.ItemWidth - 0.2f) * 500.0f);
        _uiItemLabel.SetTextAlignment(_textAlignment);

        // rotate text for easy read
        if (_textRotation == TextRotationType.Left)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, 90.0f));
        }
        else if (_textRotation == TextRotationType.Upsidedown)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, 180.0f));
        }
        else if (_textRotation == TextRotationType.Right)
        {
            _uiItemLabel.RotateText(new Vector3(0.0f, 0.0f, -90.0f));
        }

        // each types ui
        switch (_itemType)
        {
        case (ItemType.Parent):
            GameObject labelHasChildObj = new GameObject("HasChildArrow");
            labelHasChildObj.transform.SetParent(rendererObj.transform, false);
            if (_direction == StickShortcutDirection.Horizontal)
            {
                labelHasChildObj.transform.localPosition = new Vector3(_sSettings.ItemWidth / 2, _sSettings.ItemHeight * 0.9f, 0);
                labelHasChildObj.transform.localRotation = Quaternion.FromToRotation(Vector3.down, Vector3.forward);
                labelHasChildObj.transform.localScale    = new Vector3(0.6f, 0.6f, 0.6f);
            }
            else if (_direction == StickShortcutDirection.Vertical)
            {
                labelHasChildObj.transform.localPosition = new Vector3(_sSettings.ItemWidth * 0.9f, _sSettings.ItemHeight / 2, 0);
                labelHasChildObj.transform.localRotation = Quaternion.FromToRotation(Vector3.down, Vector3.forward);
                labelHasChildObj.transform.localScale    = new Vector3(1, 1, 1);
            }

            UIHasChild uiLabelHasChild = labelHasChildObj.AddComponent <UIHasChild>();
            uiLabelHasChild.SetAttributes((_direction == StickShortcutDirection.Horizontal)?"▲":"▶", _sSettings.TextFont, _sSettings.TextSize, _sSettings.TextColor);

            break;

        case (ItemType.NormalButton):

            break;

        default:
            break;
        }
    }