Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        CurrentToolTipPlacement = new ToolTipPlacementData();

        uiElementsDict = new Dictionary <ToolTipElementID, ToolTipUIElement> ();

        ToolTipUIElement smallTextUI = new ToolTipUIElement();

        smallTextUI.elementID              = ToolTipElementID.SmallToolTipText;
        smallTextUI.elementType            = ToolTipElementType.Text;
        smallTextUI.textElement            = smallText;
        smallTextUI.uiElementRectTransform = smallText.rectTransform;
        smallTextUI.textElement.text       = "";

        ToolTipUIElement detailedTextUI = new ToolTipUIElement();

        detailedTextUI.elementID              = ToolTipElementID.DetailedToolTipText;
        smallTextUI.elementType               = ToolTipElementType.Text;
        detailedTextUI.textElement            = detailedText;
        detailedTextUI.uiElementRectTransform = detailedText.rectTransform;
        detailedTextUI.textElement.text       = "";

        ToolTipUIElement smallImageUI = new ToolTipUIElement();

        smallImageUI.elementID              = ToolTipElementID.SmallDescriptionImage;
        smallImageUI.elementType            = ToolTipElementType.Image;
        smallImageUI.imageElement           = smallImage;
        smallImageUI.uiElementRectTransform = smallImage.rectTransform;

        uiElementsDict.Add(ToolTipElementID.SmallToolTipText, smallTextUI);
        uiElementsDict.Add(ToolTipElementID.DetailedToolTipText, detailedTextUI);
        uiElementsDict.Add(ToolTipElementID.SmallDescriptionImage, smallImageUI);

        toolTipRectTransform = GetComponent <RectTransform> ();
    }
Exemplo n.º 2
0
    //Need to move things from start to Initialize
    public void Initialize()
    {
        if (bgImage == null)
        {
            Debug.LogError("bgImage is Null, it should never be null");
        }

        if (smallText == null)
        {
            Debug.LogError("smallText is Null, it should never be null");
        }

        if (detailedText == null)
        {
            Debug.LogError("detailedText is Null, it should never be null");
        }

        if (smallImage == null)
        {
            Debug.LogError("smallImage is Null, it should never be null");
        }

        CurrentToolTipPlacement = new ToolTipPlacementData();

        uiElementsDict = new Dictionary <ToolTipElementID, ToolTipUIElement> ();

        ToolTipUIElement smallTextUI = new ToolTipUIElement();

        smallTextUI.elementID              = ToolTipElementID.SmallToolTipText;
        smallTextUI.elementType            = ToolTipElementType.Text;
        smallTextUI.textElement            = smallText;
        smallTextUI.uiElementRectTransform = smallText.rectTransform;
        smallTextUI.textElement.text       = "";

        ToolTipUIElement detailedTextUI = new ToolTipUIElement();

        detailedTextUI.elementID              = ToolTipElementID.DetailedToolTipText;
        smallTextUI.elementType               = ToolTipElementType.Text;
        detailedTextUI.textElement            = detailedText;
        detailedTextUI.uiElementRectTransform = detailedText.rectTransform;
        detailedTextUI.textElement.text       = "";

        ToolTipUIElement smallImageUI = new ToolTipUIElement();

        smallImageUI.elementID              = ToolTipElementID.SmallDescriptionImage;
        smallImageUI.elementType            = ToolTipElementType.Image;
        smallImageUI.imageElement           = smallImage;
        smallImageUI.uiElementRectTransform = smallImage.rectTransform;

        uiElementsDict.Add(ToolTipElementID.SmallToolTipText, smallTextUI);
        uiElementsDict.Add(ToolTipElementID.DetailedToolTipText, detailedTextUI);
        uiElementsDict.Add(ToolTipElementID.SmallDescriptionImage, smallImageUI);

        toolTipRectTransform = GetComponent <RectTransform> ();

        toolTipRectTransform.localScale = new Vector3(0, 0, 0);

        UpdateRectTransform();
    }
 private void InitializeToolTipPlacements()
 {
     TLTR = new ToolTipPlacementData(UIElementHorizontalPlacement.Left, UIElementVerticalPlacement.Top, UIElementHorizontalDirection.LeftToRight);
     TRTR = new ToolTipPlacementData(UIElementHorizontalPlacement.Right, UIElementVerticalPlacement.Top, UIElementHorizontalDirection.LeftToRight);
     TRTL = new ToolTipPlacementData(UIElementHorizontalPlacement.Right, UIElementVerticalPlacement.Top, UIElementHorizontalDirection.RightToLeft);
     BLTR = new ToolTipPlacementData(UIElementHorizontalPlacement.Left, UIElementVerticalPlacement.Bottom, UIElementHorizontalDirection.LeftToRight);
     BRTR = new ToolTipPlacementData(UIElementHorizontalPlacement.Right, UIElementVerticalPlacement.Bottom, UIElementHorizontalDirection.LeftToRight);
     BRTL = new ToolTipPlacementData(UIElementHorizontalPlacement.Right, UIElementVerticalPlacement.Bottom, UIElementHorizontalDirection.RightToLeft);
 }
    public ToolTipPlacementData(ToolTipPlacementData other)
    {
        // by default we want the tool tip to be anchored at the bottom left (0,0)
        // and pivoted at the top left (0,1), this means that horizontal placement will be Left,
        // Vertical Placement to be bottom and direction to be Left To Right

        HorizontalPlacement = other.HorizontalPlacement;
        VerticalPlacement   = other.VerticalPlacement;
        HorizontalDirection = other.HorizontalDirection;

        UpdatePivotAndAnchors();
    }
Exemplo n.º 5
0
    public void UpdateToolTipPlacement(ToolTipPlacementData requiredPlacement)
    {
        CurrentToolTipPlacement.VerticalPlacement   = requiredPlacement.VerticalPlacement;
        CurrentToolTipPlacement.HorizontalPlacement = requiredPlacement.HorizontalPlacement;
        CurrentToolTipPlacement.HorizontalDirection = requiredPlacement.HorizontalDirection;
        CurrentToolTipPlacement.RequiredAnchorMax   = requiredPlacement.RequiredAnchorMax;
        CurrentToolTipPlacement.RequiredAnchorMin   = requiredPlacement.RequiredAnchorMin;
        CurrentToolTipPlacement.RequiredPivot       = requiredPlacement.RequiredPivot;

        toolTipRectTransform.pivot     = requiredPlacement.RequiredPivot;
        toolTipRectTransform.anchorMax = requiredPlacement.RequiredAnchorMax;
        toolTipRectTransform.anchorMin = requiredPlacement.RequiredAnchorMin;
        CheckAndFitWithinScreenBounds();
    }
Exemplo n.º 6
0
    // Primarily this function recieves the data from the controller and performs basic validation
    // If we have some valid data then we setup the tool tip object and copy the data
    public bool SetupToolTip(ToolTipData data, ToolTipPlacementData placementToBeUsed)
    {
        //Check if the data object is valid
        if (data == null)
        {
            Debug.LogError("SimpleToolTipObj::Tool Tip Data Validation failed, data was NULL, This should never be null ");
            return(false);
        }

        ////Check if the bare minimum data is present (small tool tip text)
        //if (data.HasElement (ToolTipElementID.SmallToolTipText))
        //{
        //	// if we have the right data copy it to our variables
        //	smallText.text = data.GetElement(ToolTipElementID.SmallToolTipText);
        //	//selectedAnchor = SelectAnchor (anchorToBeUsed, data);
        //	gameObject.transform.position = new Vector3 (posToBeUsed.x, posToBeUsed.y, 0);
        //	//CalculatePosition (posToBeUsed, selectedAnchor);
        //	//CalculateSize ();
        //	return true;
        //}
        //else
        //{
        //	return false;
        //}

        // We dont position the tool tip yet since it will be positioned when it start appearing (after the tipAppearingDelay)
        ResetToolTip();

        // Check if the bare minimum data is present (small tool tip text)
        if (!data.HasElement(ToolTipElementID.SmallToolTipText))
        {
            // cannot setup the tool tip return false
            return(false);
        }
        uiElementsDict [ToolTipElementID.SmallToolTipText].textElement.text = data.GetElement(ToolTipElementID.SmallToolTipText);
        uiElementsDict [ToolTipElementID.SmallToolTipText].UpdateElement();

        if (data.HasElement(ToolTipElementID.SmallDescriptionImage))
        {
            //Debug.Log ("ToolTipObjTest::SetupToolTip:Data has small image: "+data.GetElement (ToolTipElementID.SmallDescriptionImage));

            Sprite tempSprite = Resources.Load(data.GetElement(ToolTipElementID.SmallDescriptionImage), typeof(Sprite)) as Sprite;
            if (tempSprite != null)
            {
                //Debug.Log ("ToolTipObjTest::SetupToolTip:small image: "+tempSprite);
                //Debug.Log ("ToolTipObjTest::SetupToolTip:small image size: "+tempSprite.rect.size );
                uiElementsDict[ToolTipElementID.SmallDescriptionImage].imageElement.sprite = tempSprite;
                uiElementsDict[ToolTipElementID.SmallDescriptionImage].UpdateElement();
            }
            else
            {
                Debug.Log("<color=orange>ToolTipObjTest::SetupToolTip:Could not load image with name: " + data.GetElement(ToolTipElementID.SmallDescriptionImage) + "</color>");
            }
        }
        if (data.HasElement(ToolTipElementID.DetailedToolTipText))
        {
            uiElementsDict [ToolTipElementID.DetailedToolTipText].textElement.text = data.GetElement(ToolTipElementID.DetailedToolTipText);
            uiElementsDict [ToolTipElementID.DetailedToolTipText].UpdateElement();
        }

        UpdateToolTip();
        return(true);
    }
Exemplo n.º 7
0
 public static Vector2 CalculatePosition(Vector2 posToBeUsed, ToolTipPlacementData preferredPlacement)
 {
     return(Vector2.zero);
 }