Strikethrough for completed objective text

It’s the smallest thing in the world, but I wanted to switch up the text for objectives when they’re completed.

All you need to do is add

                if(status.IsObjectiveComplete(objective))
                {
                    objectiveText.text = $"<s>{objective}</s>";
                }

to the end of the foreach loop of Setup(QuestStatus status) in QuestTooltipUI.cs

You can look up tons of other tags at Rich Text, TextMesh Pro Documentation

1 Like

This is an excellent touch! Well done!

2 Likes

Hi Brian,

Was wondering if you could help me with some advice please? I am looking to find a way to push the completed quests at the bottom of the list and put a line through them? Is that something that is possible with the current setup? I have completed all the courses and implemented the Json saving feature as well. I appreciate the help.

Thank you very much.

We managed to make it work by creating a SetTitleText on quest item UI and than set it up in ReDraw() . But would be cool if there would be a way to push the quest that are completed at the bottom of the list in UI.

You’ll need to go through the list of Quests and make 2 lists.
One list for ongoing quests
Another for completed quests.
Then you go through each of the ongoing and create the QuestItemUI, and then go through the completed and create their QuestItemUI. On the completed quests, then you can add the <s> Strikeout.

1 Like

Thank you Brian!
Will give it a shot thank you for the recommendation.

For anyone else trying to achieve something like this I was able to do it like this (in QuestListUI.cs):

private void ReDraw()
    {
        List<QuestStatus> completeQuests = new List<QuestStatus>();
        List<QuestStatus> incompleteQuests = new List<QuestStatus>();

        // Separate quests based on their completion status
        foreach (QuestStatus status in questList.GetStatuses())
        {
            if (status.IsComplete())
            {
                completeQuests.Add(status);
            }
            else
            {
                incompleteQuests.Add(status);
            }
        }

        // Destroy all current UI items
        foreach (Transform item in transform)
        {
            Destroy(item.gameObject);
        }

        // Instantiate UI items for incomplete quests first
        foreach (QuestStatus status in incompleteQuests)
        {
            InstantiateQuestItem(status);
        }

        // Instantiate UI items for complete quests with strikethrough
        foreach (QuestStatus status in completeQuests)
        {
            InstantiateQuestItem(status);
        }
    }

    private void InstantiateQuestItem(QuestStatus status)
    {
        QuestItemUI uiInstance = Instantiate<QuestItemUI>(questPrefab, transform);

        // Check if the quest is complete, and if so, apply strikethrough effect to title
        if (status.IsComplete())
        {
            uiInstance.SetTitleText($"<s>{status.GetQuest().GetTitle()}</s>"); // Wrap the title in <s> tags
        }
        else
        {
            uiInstance.SetTitleText(status.GetQuest().GetTitle()); // Set title without strikethrough
        }

        uiInstance.Setup(status);
    }

I don’t want to play on words but thank you for underlining this :slight_smile:

1 Like

Privacy & Terms