Пример #1
0
    private GameObject CreateEvent(Timeline.C_TimelineData historyEvent)
    {
        //if there is no history event and there should be no filler: return.
        if (displayFillerEvents == false && historyEvent.historyEvent == null)
        {
            return(null);
        }

        GameObject go = (GameObject)Instantiate(UITemplate);

        go.transform.SetParent(gameObject.transform, false);
        Timeline_UIItem uiItem = go.GetComponent <Timeline_UIItem>();

        if (uiItem == null)
        {
            Debug.LogWarning("The Prefab for timeline UI-items should have a 'Timeline_UIItem' script. This script was not found. Skipping display.");
            return(null);
        }
        else
        {
            uiItem.SetHistoryEvent(historyEvent);
            listElements.Add(go);
            return(go);
        }
    }
Пример #2
0
    //Set an history event and its year form an TimelineData class (contains more information about the event, e.g. year)
    public void SetHistoryEvent(Timeline.C_TimelineData timelineData)
    {
        _timelineData = timelineData;

        if (_timelineData != null && _timelineData.historyEvent != null)
        {
            if (eventImage != null)
            {
                eventImage.sprite = _timelineData.historyEvent.image;
            }
            if (eventTitle != null)
            {
                eventTitle.text = TranslationManager.translateIfAvail(_timelineData.historyEvent.title);
            }
            if (eventYear != null)
            {
                if (Timeline.instance != null)
                {
                    eventYear.text = (_timelineData.year + Timeline.instance.startYear + Timeline.instance.history.startYearOffset - 1).ToString();
                }
                else
                {
                    //if acessing timeline instance fails, show the year from the element only
                    eventYear.text = _timelineData.year.ToString();
                }
            }
            if (descriptionText != null)
            {
                descriptionText.text = TranslationManager.translateIfAvail(_timelineData.historyEvent.description);
            }
            if (addText != null)
            {
                //translation can't be applied here, because text-replacement is already finished.
                addText.text = _timelineData.addText;
            }
            if (combinedDescriptionText != null)
            {
                combinedDescriptionText.text = TranslationManager.translateIfAvail(_timelineData.historyEvent.description) + " " + _timelineData.addText;
            }
        }
    }