Hi,
Having trouble with something very simple but I’ve spent hours looking through docs and cannot figure this out.
All I want to do is get the button I just clicked.
ui.Q<Button>("btnAddChoiceNode").RegisterCallback<ClickEvent>(evt =>
{
AssetTools.CreateAsset(typeof(ChoiceNode), m_ActiveScene.ID + Guid.NewGuid(), m_Config.SceneDirectory);
//I Want to get the button that I just clicked here so I can get its binding!!
//(button.binding as Node).AddNode(new ChoiceNode)
});
1/2 fixed. Binding isn’t working though. It works when I bind a property but not when I bind the object.
//this works
txt.BindProperty(so.FindProperty("ID"));
ui.Q<TextField>("txtDescription").BindProperty(so.FindProperty("Description"));
//this doesn't work
Button b = ui.Q<Button>("btnAddChoiceNode");
b.Bind(so);
ui.Q<Button>("btnAddChoiceNode").RegisterCallback<ClickEvent>(evt =>
{
Button b = (evt.currentTarget as Button);
Node node = b.binding as Node;
//binding is null
string nodeName = m_ActiveScene.ID + Guid.NewGuid();
AssetTools.CreateAsset(typeof(ChoiceNode),nodeName, m_Config.SceneDirectory);
ChoiceNode choiceNode = AssetDatabase.LoadAssetAtPath<ChoiceNode>(m_Config.SceneDirectory + nodeName + ".asset");
node.AddNode(choiceNode);
RefreshNodeList();
I’m trying to get the binding of the button to pass into that function, but the binding isn’t working. All good though I just rolled my own and put the button and the “binding” in a dictionary.