Hi!
I need a similar response system as in the attachment below (+5000 money, +1 weapon). Is there any built-in functionality?
Thanks.
Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
- Attachments
-
- vz62vijh0s761.jpg (134.78 KiB) Viewed 564 times
Re: Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
Hi,
There's built-in functionality for everything except the reward images. This includes Ruby's portrait, name, and text at the top, the choices at the bottom, and the ability to add the reward to the player using each choice's Script field. However, the Dialogue System is designed to let you extend its functionality. Here are my recommendations:
1. Add two new fields to the dialogue entry template (see Templates): reward amount and reward icon.
2. In your reward dialogue entries, set the reward amount (e.g., "1x") and reward icon as an image name (e.g., "kevlar_vest").
3. Make a subclass of StandardUIResponseButton that also supports two extra UI elements: reward amount and reward image. Override the SetFormattedText method to look up the dialogue entry's reward amount and reward icon, and set the UI elements accordingly.
There's built-in functionality for everything except the reward images. This includes Ruby's portrait, name, and text at the top, the choices at the bottom, and the ability to add the reward to the player using each choice's Script field. However, the Dialogue System is designed to let you extend its functionality. Here are my recommendations:
1. Add two new fields to the dialogue entry template (see Templates): reward amount and reward icon.
2. In your reward dialogue entries, set the reward amount (e.g., "1x") and reward icon as an image name (e.g., "kevlar_vest").
3. Make a subclass of StandardUIResponseButton that also supports two extra UI elements: reward amount and reward image. Override the SetFormattedText method to look up the dialogue entry's reward amount and reward icon, and set the UI elements accordingly.
Re: Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
Thanks for advices. I'll try to do that)
Re: Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
Glad to help! If you have questions about it, let me know.
Re: Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
What if I need to output several reward items on response item? For example, 15 XP AND 100 amount of ammo? (See attachment)
Is it possible to create a new array or list field? Something like this: [{RewardName: "Money", RewardAmount: 100}, [{RewardName: "XP", RewardAmount: 15}]
Is it possible to create a new array or list field? Something like this: [{RewardName: "Money", RewardAmount: 100}, [{RewardName: "XP", RewardAmount: 15}]
- Attachments
-
- Screenshot_2024-02-23-13-38-46-28_60a1804e398c12353b31b7cc7cc72187.jpg (170.44 KiB) Viewed 508 times
Re: Dialogue Response Item with dynamic labels (XP, Reward, New weapon)
Hi,
You can do that, but you'd need to parse it yourself.
If you can separate the info with semicolons or some other unique character, you can use string.Split(';') to split the info on that character. Otherwise you could write it in JSON format such as:
and then use JsonUtility:
You can do that, but you'd need to parse it yourself.
If you can separate the info with semicolons or some other unique character, you can use string.Split(';') to split the info on that character. Otherwise you could write it in JSON format such as:
Code: Select all
{Rewards:[ {Name:"Money", Amount:100}, {Name:"XP", Amount:15} ]}
Code: Select all
[System.Serializable]
public class Reward
{
public string Name;
public int Amount;
}
[System.Serializable]
public class Rewards
{
public List<Reward> Rewards;
}
void OnConversationLine(Subtitle subtitle)
{
var s = Field.LookupValue(subtitle.fields, "Rewards");
if (string.IsNullOrEmpty(s)) return;
Rewards rewards = JsonUtility.FromJson<Rewards>(s);
// Show rewards here.
}