public bool SetupToolTip(ToolTipData data) { ResetToolTip(); if (!data.HasElement(ToolTipElementID.SmallToolTipText)) { 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; //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(); } if (data.HasElement(ToolTipElementID.DetailedToolTipText)) { uiElementsDict [ToolTipElementID.DetailedToolTipText].textElement.text = data.GetElement(ToolTipElementID.DetailedToolTipText); uiElementsDict [ToolTipElementID.DetailedToolTipText].UpdateElement(); } UpdateToolTip(); return(true); }
// 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); }