- Home /
New UI Is active but not drawing
I'm using a tooltip script to enable/disable the tooltip window when it's over slots that contain a script telling it to do so (inventory/loot/equipment, etc.) To keep the tooltip from erroneously staying open if the inventory for example is closed I have:
PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(false);
turning the tooltip off when the inventory window gets OnDisable(). The problem is then turning the inventory back on... It won't... I can see it enabling properly in the inspector and the canvas outline/wireframe is even drawing, all of its subcomponent are properly active, but it draws nothing in the game window nor scene view. If the tooltip is not active when I close the inventory I can open/close it without draw problems, so I assume it has something to do with the tooltip, but don't see anything amiss... If I change something else, like disabling the whole UI and re-enable it via the inspector then it will draw fine for me...
here's the entire tooltip script:
public class TooltipUI : MonoBehaviour {
public Text tooltipText;
void OnEnable () {
transform.position = new Vector3(Input.mousePosition.x + 20, Input.mousePosition.y, 0);
}
void Update () {
transform.position = new Vector3(Input.mousePosition.x + 20, Input.mousePosition.y, 0);
}
public void SetText (string str) {
tooltipText.text = str;
}
}
here is the line from Update() in the PlayerInput script making the action:
if (Input.GetKeyDown(KeyCode.I)) { PlayerData.mainUI.GetComponent<MainUI>().inventoryUI.SetActive(!PlayerData.mainUI.GetComponent<MainUI>().inventoryUI.activeSelf); }
there's really nothing very difficult going on. The two heirarchies are as follows:
MainUI -> Windows -> InventoryUI
MainUI -> TooltipUI
this keeps the tooltip always ontop of the Inventory.
the ContainerSlot script on the inventory slots has the following script, though it shouldn't make any difference as to whether the inventory window will render or not...??
public void OnPointerEnter (PointerEventData eventData) {
if (location == loc.inventory) {
if (PlayerData.inventory[slot] != null) {
PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.GetComponent<TooltipUI>().SetText(PlayerData.inventory[slot]._item.Tooltip());
PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(true);
}
}
else if (location == loc.equipment) {
if (PlayerData.equipment[slot] != null) {
PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.GetComponent<TooltipUI>().SetText(PlayerData.equipment[slot]._item.Tooltip());
PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(true);
}
}
}
I R confused, bug?
First thing to do is add some Debug.Logs in there to make sure that OnPointerEnter is firing:
Debug.Log("Set Active in loc.inventory called");
// and in the equipment
Debug.Log("Set Active in loc.equipment called");
See if it's actually being called.
everything is being called fine. the loc variable lets the TooltipUI window know whether it's handling inventory items or character equipment items or loot window items, etc. doesn't actually affect the EquipmentUI. I can run in un-maximized and see the window turning on and off fine. I can pause and see that it (the EquipmentUI window), all of it's parents, and all of children are properly active. The outline is drawing, but it's contents are all invisible. see attached pics... kind of hard with just words.
I still have this problem.
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.I)) { PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().inventoryUI.SetActive(!PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().inventoryUI.activeSelf); }
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.C)) { PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().equipmentUI.SetActive(!PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().equipmentUI.activeSelf); }
It's very simple script, I don't have to push them at the same time or anything. Yet sometimes they completely stop responding. As posted above, they are properly activating/deactivating in the inspector, but stop actually drawing themselves.
It's to the point where I'm going to have to start just refreshing the whole GUI to try and stop it. I'll go post on the bug forum a link to here. If it were to happen in build it would be a complete gamebreaker...