7
« on: October 25, 2014, 11:40:19 am »
I have read through the forums and tutorials and struggling to get the sender gameobject on button click.
I have a prefab button that is instantiated. There is a button controller which is the target of the tk2duiitem with the OnClick event being the following method
public void LoadGameClicked()
{
Debug.Log ("Load Game Clicked");
}
Which works fine
However if I want to access the parent GameObject so I can interrogate various parameters, classes etc on what to do next I'm not sure how to interpret the message.
For example,
public void LoadGameClicked(GameObject obj)
{
Debug.Log ("Load Game Clicked");
}
Errors with
MissingMethodException: The best match for method LoadGameClicked has some invalid parameter.
System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MonoType.cs:520)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
tk2dUIItem:DoSendMessage(String) (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIItem.cs:246)
tk2dUIItem:Release() (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIItem.cs:266)
tk2dUIManager:CheckInputs() (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIManager.cs:443)
tk2dUIManager:Update() (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIManager.cs:321)
How do I get hold of the gameobject, any assistance would be greatly appreciated?