Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using UnityEngine;
- using UnityEngine.Networking;
- public class PasteBinTextLoader : MonoBehaviour
- {
- [SerializeField]
- private string pasteBinRawLink = "YOUR_PASTEBIN_RAW_LINK_HERE";
- [SerializeField]
- private GameObject[] targetGameObjects;
- private void Start()
- {
- StartCoroutine(LoadTextFromPasteBin());
- }
- private IEnumerator LoadTextFromPasteBin()
- {
- UnityWebRequest www = UnityWebRequest.Get(pasteBinRawLink);
- yield return www.SendWebRequest();
- if (www.result == UnityWebRequest.Result.Success)
- {
- string pasteBinText = www.downloadHandler.text;
- foreach (GameObject obj in targetGameObjects)
- {
- TextMesh textMesh = obj.GetComponent<TextMesh>();
- if (textMesh != null)
- {
- textMesh.text = pasteBinText;
- }
- else
- {
- Debug.LogWarning("TextMesh component not found on GameObject: " + obj.name);
- }
- }
- }
- else
- {
- Debug.LogError("Failed to fetch PasteBin content: " + www.error);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement