DEV Community

Cover image for In-Game Wiki in Unity in 15 min
Mike Krop
Mike Krop

Posted on • Edited on • Originally published at mitrapunk.com

3 1 1 1 1

In-Game Wiki in Unity in 15 min

This solution is ideal if you need a simple way to create a wiki in your game.

Solution is based on TextMesh Pro component.

The game itself is in active development, you can subscribe for updates about what does it mean to be manager

public class WikiUI : MonoBehaviour, IPointerClickHandler
{
    public TextMeshProUGUI text;

    public void OnenWikiAbout(string page)
    {
        text.text = "<line-height=125%>";

        if (page == "negotiations")
        {
            text.text += "Negotiations<br>Negotiations start when there are several opinions on the next steps. During negotiations, you and your colleagues communicate about which course to take.";
        }
        else if (page == "homepage")
        {
            text.text += "Wiki Index:<br><link=negotiations><u>Read about negotiations</u></link>";
        }
        else
        {
            text.text = "404<br>";
        }

        text.text += "<br><link=homepage><u>Go Home</u></link>";
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        // camera is null only if you use Screen Space Overlay, otherwise add camera reference
        int linkIndex = TMP_TextUtilities.FindIntersectingLink(text, eventData.position, null);

        if (linkIndex != -1)
        {
            TMP_LinkInfo linkInfo = text.textInfo.linkInfo[linkIndex];
            OnenWikiAbout(linkInfo.GetLinkID());
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay