1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using ObjectScripts;
- using CSVReader;
- namespace UIScripts
- {
- public class EventSlider : MonoBehaviour
- {
-
- ///<summary>
- /// EventHandler to get Events from
- ///</summary>
- [SerializeField] AbstractEventHandler EventHandler;
- ///<summary>
- /// Canvas for each moving Timestamp
- ///</summary>
- [SerializeField] GameObject TimestampCanvas;
- ///<summary>
- /// Timeline slider
- ///</summary>
- [SerializeField] UnityEngine.UI.Slider Slider;
- ///<summary>
- /// Manager to control
- ///</summary>
- [SerializeField] AbstractManager Manager;
- ///<summary>
- /// Sprites for each Eventtype
- ///</summary>
- [SerializeField] Sprite[] EventImages;
- ///<summary>
- /// Dictionary to keep track of each timestamp canvas
- ///</summary>
- Dictionary<double, GameObject> Timestamps;
- ///<summary>
- /// number of known events
- ///</summary>
- private int KnownCount = 0;
- ///<summary>
- /// Left timeline postion
- ///</summary>
- private Vector3 MinPositon;
- void Start()
- {
- Timestamps = new Dictionary<double, GameObject>();
- MinPositon = TimestampCanvas.transform.position;
- }
- // Update is called once per frame
- void Update()
- {
- //for each unknown event
- for (int i = KnownCount; i < EventHandler.EventList.Count; i++)
- {
- EventObject eventObject = EventHandler.EventList[i].Event;
- double timestamp = eventObject.TimestampStart;
- GameObject obj;
- if (Timestamps.TryGetValue(timestamp, out obj))
- {
- EventStamp eventStamp = obj.GetComponent<EventStamp>();
- eventStamp.addContent(EventHandler.EventList[i], EventImages[(int)eventObject.Type]);
- }
- else
- {
- obj = Instantiate(TimestampCanvas, TimestampCanvas.transform.localPosition, Quaternion.Euler(0, 0, 0), transform);
- obj.transform.localRotation = Quaternion.Euler(0, 0, 0);
- obj.SetActive(true);
- EventStamp eventStamp = obj.GetComponent<EventStamp>();
- eventStamp.Slider = Slider;
- eventStamp.Manager = Manager;
- eventStamp.Timestamp = eventObject.TimestampStart;
- eventStamp.addContent(EventHandler.EventList[i], EventImages[(int)eventObject.Type]);
- Timestamps.Add(timestamp, obj);
- obj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -obj.GetComponent<RectTransform>().sizeDelta.y);
- }
- KnownCount += 1;
- }
- }
- }
- }
|