I have a script which is a Scriptable Object, and I’m trying to use SendMessage in it (to create a tooltip effect). I use this code in other scripts (Mono scripts), but it won’t recognize SendMessage in this context. Can someone help me out with this? Thanks!
if (Event.current.type == EventType.Repaint GUI.tooltip != lastTooltip)
{
if (lastTooltip != "")
SendMessage(lastTooltip + "OnMouseOut", SendMessageOptions.DontRequireReceiver);
if (GUI.tooltip != "")
SendMessage(GUI.tooltip + "OnMouseOver", SendMessageOptions.DontRequireReceiver);
lastTooltip = GUI.tooltip;
}
P.S. I’ve tried to create an instance of the Scriptable Object, then use “instance.SendMessage”, but that didn’t work.
EDIT: I’ve gotten it to work by simply referencing an existing Monobehaviour:
GUIController GC = Camera.main.GetComponent<GUIController>();
if (Event.current.type == EventType.Repaint GUI.tooltip != lastTooltip)
{
if (lastTooltip != "")
GC.SendMessage(lastTooltip + "OnMouseOut", SendMessageOptions.DontRequireReceiver);
if (GUI.tooltip != "")
GC.SendMessage(GUI.tooltip + "OnMouseOver", SendMessageOptions.DontRequireReceiver);
lastTooltip = GUI.tooltip;
}
It seems like a bit of a hack, but it gets the job done. Any thoughts on a more “proper” way of doing this?