﻿using UnityEngine;
using System.Collections;

public class NewsFeed : MonoBehaviour {
    
    [AddComponentMenu("AxeyWorks/News Feed")]

    string myText;
    public UnityEngine.UI.Text newsFeed;
    public string myNewsURL;
    public string noNewsText;

    void Start()
    {
        StartCoroutine(GetNews());
    }
    
    private IEnumerator GetNews()
    {
        WWW feed = new WWW(myNewsURL);
        yield return feed;
        myText = feed.text;
        newsFeed.text = myText;
        
        if (newsFeed.text == "")
        {
            newsFeed.text = noNewsText;
        }
    }

}