Hi, decided to use forums for abit since discord seems quite busy.
I'm having big trouble getting a custom ItemActionWithAsyncFuncActionPanel to work properly. I have multiple characters and when I click equip on my actions panel, I want another action panel to open up (like in assign to hotbar panel) that lists "Current, (list of all characters), Cancel" action buttons.
This is what I have so far and it's not working:
This prints out the buttons nicely, so if I my party has 2 characters it looks like this: "Current, Mage, Warrior, Cancel", so that part works. But pressing the buttons is where it all breaks. I have this in InvokeWithAwaitedValue:
The only button that works is "Current" that prints out "-1" properly at the Debug.Log. But for some reason all the other buttons print out "2", why is that? What am I doing wrong?
I'm having big trouble getting a custom ItemActionWithAsyncFuncActionPanel to work properly. I have multiple characters and when I click equip on my actions panel, I want another action panel to open up (like in assign to hotbar panel) that lists "Current, (list of all characters), Cancel" action buttons.
This is what I have so far and it's not working:
C#:
protected override void InvokeActionInternal (ItemInfo itemInfo, ItemUser itemUser) {
// Clear old actions
m_AsyncFuncActions.Clear ();
// If we're equipping, show the async panel
if (Name == "Equip") {
// Add "Current" option, that has value of -1. This means currently selected character.
m_AsyncFuncActions.Add (new AsyncFuncAction<int> ("Current", () => -1));
// Loop through players party and add a asyncfuncaction
for (int i = 0; i < Database.Instance.PlayerParty.Count; i++) {
m_AsyncFuncActions.Add (new AsyncFuncAction<int> ((Database.Instance.PlayerParty [i].Name).ToString (), () => i));
}
base.InvokeActionInternal (itemInfo, itemUser);
} else { // If not equipping, just unequip.
EquipUnequip (itemInfo, itemUser);
}
}
This prints out the buttons nicely, so if I my party has 2 characters it looks like this: "Current, Mage, Warrior, Cancel", so that part works. But pressing the buttons is where it all breaks. I have this in InvokeWithAwaitedValue:
C#:
protected override void InvokeWithAwaitedValue (ItemInfo itemInfo, ItemUser itemUser, int awaitedValue) {
Debug.Log (awaitedValue);
if (awaitedValue == -1) {
// Get currently selected character
m_SecondCollectionID = new ItemCollectionID ("Equipped_" + Database.Instance.GetCharacterIndex (Database.Instance.CurrentCharacter), ItemCollectionPurpose.None);
} else {
// Get character from players party with awaitedValue index
m_SecondCollectionID = new ItemCollectionID ("Equipped_" + Database.Instance.PlayerParty [awaitedValue].ID.Value, ItemCollectionPurpose.None);
}
EquipUnequip (itemInfo, itemUser);
}
The only button that works is "Current" that prints out "-1" properly at the Debug.Log. But for some reason all the other buttons print out "2", why is that? What am I doing wrong?