Created
May 7, 2023 15:32
-
-
Save snowman647/1cbcc7acc48ff88a9021f0bee1819b76 to your computer and use it in GitHub Desktop.
In-Game Wiki for Unity game using TextMesh Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code from my game about software development https://devmanager.carrd.co | |
// | |
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()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code from my game about software development