예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (_curLayer != null)
        {
            if (InteractionManager.HasItemId(_id))
            {
                if (_curLayer.UILayer.IsCurrentLayer)
                {
                    // register this item pos to interaction manager
                    InteractionManager.SetItemPos(_id, Camera.main.WorldToViewportPoint(centerObj.transform.position));

                    float deltaSelectSpeed = _selectSpeed * Time.deltaTime;
                    /***** focus, select ui update *****/
                    float progress = InteractionManager.GetItemHighlightProgress(_id);

                    // set now progress
                    InteractionManager.SetItemProg(_id, progress);

                    float focusStart = _sSettings.FocusStart;                     // trigger focus percent = 80%
                    if (progress > focusStart && !_curLayer.UILayer.IsAnimating)  // is focusing
                    {
                        float focusProg = Mathf.Lerp(0, 1, progress - focusStart);

                        // focus, select event process
                        if (focusProg == 1 && _isNearestItem)                           // all focus, is selecting
                        {
                            if (_selectProg < 1.0f)
                            {
                                _selectProg += deltaSelectSpeed;
                            }

                            // item click evnet
                            if (_selectProg >= 1.0f)
                            {
                                _selectProg = 1.0f;

                                if (_execType == ActionExecType.Once)
                                {
                                    if (!_isSelected)                                       // select action is triggered just once
                                    {
                                        _isSelected = true;
                                        _selectableItem.SelectAction();
                                    }
                                }
                                else if (_execType == ActionExecType.DuringSelecting)
                                {
                                    _selectableItem.SelectAction();
                                }
                            }
                            // select ui update
                            _uiArcItemBg.UpdateMesh(0.0f, 0.0f, _backgroundColor);
                            _uiArcItemFs.UpdateMesh(_innerRadius + (_thickness * _selectProg), _innerRadius + (_thickness * focusProg), _focusingColor);
                            _uiArcItemSt.UpdateMesh(_innerRadius, _innerRadius + (_thickness * _selectProg), _selectingColor);
                        }
                        else
                        {
                            _selectProg = 0.0f;
                            _isSelected = false;
                            if (_isNearestItem)
                            {
                                _selectProg = 0.05f;
                                _uiArcItemBg.UpdateMesh(_innerRadius + (_thickness * focusProg), _outerRadius, _backgroundColor);
                                _uiArcItemFs.UpdateMesh(_innerRadius + (_thickness * 0.05f), _innerRadius + (_thickness * focusProg), _focusingColor);
                                _uiArcItemSt.UpdateMesh(_innerRadius, _innerRadius + (_thickness * 0.05f), _selectingColor);
                            }
                            else
                            {
                                // focus ui update
                                _uiArcItemBg.UpdateMesh(_innerRadius + (_thickness * focusProg), _outerRadius, _backgroundColor);
                                _uiArcItemFs.UpdateMesh(_innerRadius, _innerRadius + (_thickness * focusProg), _focusingColor);
                                _uiArcItemSt.UpdateMesh(0.0f, 0.0f, _selectingColor);
                            }
                        }
                    }
                    else                         // is non focusing
                                                 // general ui update
                    {
                        _uiArcItemBg.UpdateMesh(_innerRadius, _outerRadius, _backgroundColor);
                        _uiArcItemFs.UpdateMesh(0.0f, 0.0f, _focusingColor);
                        _uiArcItemSt.UpdateMesh(0.0f, 0.0f, _selectingColor);
                    }

                    /****************************************/
                }
                else
                {
                    // register this item pos to interaction manager
                    InteractionManager.SetItemPos(_id, Vector3.one * 999);
                }
            }
        }
    }
예제 #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 (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;
		}
		
	}
예제 #3
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;
        }
    }