Exemplo n.º 1
0
    void Start()
    {
        //Find Input text fields, associated labels and buttons for utilizing local data in the Radar.unity scene and assign them to fields.
        //Names in Radar.unity scene exactly match corresponding Manager.cs field names
        ReadButton1    = GameObject.Find("ReadButton1");
        CSVText        = GameObject.Find("CSVText");
        FileInputText1 = GameObject.Find("FileInputText1");
        ReadButton2    = GameObject.Find("ReadButton2");
        CSVText2       = GameObject.Find("CSVText2");
        FileInputText2 = GameObject.Find("FileInputText2");

        //Find input text fields, associated labels and buttons for utilizing data read from socket in the Radar.unity scene and assign them to fields.
        //Names in Radar.unity scene exactly match corresponding Manager.cs field names
        ReadButtonIP          = GameObject.Find("ReadButtonIP");
        IPText                = GameObject.Find("IPText");
        IPInputText           = GameObject.Find("IPInputText");
        ReadButtonPort        = GameObject.Find("ReadButtonPort");
        PortText              = GameObject.Find("PortText");
        PortInputText         = GameObject.Find("PortInputText");
        ConnectToSocketButton = GameObject.Find("ConnectToSocketButton");

        CSVWritePathInputText = GameObject.Find("CSVWritePathInputText");
        CSVWritePath          = CSVWritePathInputText.GetComponent <InputField>();

        //Find Red Asterisk objects in Radar.unity scene
        RedAsteriskBeam   = GameObject.Find("RedAsteriskBeam");
        RedAsteriskTarget = GameObject.Find("RedAsteriskTarget");
        RedAsteriskIP     = GameObject.Find("RedAsteriskIP");
        RedAsteriskPort   = GameObject.Find("RedAsteriskPort");
        RedAsteriskWriter = GameObject.Find("RedAsteriskWriter");

        //Initially Set all Red Asterisk objects to inactive
        RedAsteriskBeam.SetActive(false);
        RedAsteriskTarget.SetActive(false);
        RedAsteriskIP.SetActive(false);
        RedAsteriskPort.SetActive(false);
        RedAsteriskWriter.SetActive(false);

        //Initially set all input text fields and associated labels/buttons for reading data from a socket in the Radar.unity
        //scene to "off"
        ReadButtonIP.SetActive(false);
        IPText.SetActive(false);
        IPInputText.SetActive(false);
        ReadButtonPort.SetActive(false);
        PortText.SetActive(false);
        PortInputText.SetActive(false);
        ConnectToSocketButton.SetActive(false);

        IPAddress  = IPInputText.GetComponent <InputField>();
        portNumber = PortInputText.GetComponent <InputField>();

        UIPanel.gameObject.SetActive(false); //make sure our pause menu is disabled when Radar.unity scene starts
        objectInfo.gameObject.SetActive(false);

        isPaused      = false; //make sure isPaused is always false when our Radar.unity scene opens
        time          = 0;
        timeText.text = time.ToString();

        //adjust speed here
        speed    = 1;
        interval = speed;
        aboutButton.onClick.AddListener(TaskOnClick);
        detectionData = new CSVWriter();
        subscriber    = new Subscriber();
        subscriber.ConnectToTcpServer();
        tDataQueue = new Queue();
        bDataQueue = new Queue();
        readValues = false;
    }