public void OnConfirm()
    {
        var toggle = ModeGroup.GetActive();

        if (toggle.name == "Mode1")
        {
            command.mode = 0;
        }
        else if (toggle.name == "Mode2")
        {
            command.mode = 1;
        }
        if (timeField.text.Length != 0)
        {
            command.time = int.Parse(timeField.text);
        }
        if (energyField.text.Length != 0)
        {
            command.energy = int.Parse(energyField.text);
        }
        if (coordField.text != "Wrong string" && coordField.text.Length != 0)
        {
            command.command = RobotCommands.TelegaMoving(coordField.text);
            ModeGroup.SetActive(0);
            coordField.text = "";
            this.gameObject.SetActive(false);
        }
    }
    public IEnumerator DirectionalMoving()
    {
        rc.aims.Insert(0, telega.PointA.transform.position);
        rc.aims.Insert(0, telega.PointA.transform.position + telega.A - telega.B);

        for (int i = 0; i < rc.aims.Count; ++i)
        {
            rc.aims[i] = new Vector3(rc.aims[i].x, telega.transform.position.y, rc.aims[i].z);
        }

        for (int j = 1; j < rc.aims.Count - 1; ++j)
        {
            a = rc.aims[j] - rc.aims[j - 1];
            b = rc.aims[j + 1] - rc.aims[j];

            angle = new float[3] {
                30f, -30f, 90f
            };
            float alpha = Mathf.Acos(Vector3.Dot(a.normalized, b.normalized)) * Mathf.Rad2Deg;
            dist = new float[3] {
                Mathf.Abs(Mathf.PI * 20f * alpha / 180f), Mathf.Abs(Mathf.PI * 20f * alpha / 180f), Mathf.Abs(Mathf.PI * 20f * alpha / 180f)
            };

            if (Vector3.Cross(a, b).y >= 0)
            {
                isReversed = new float[3] {
                    -1, -1, 1
                };
            }
            if (Vector3.Cross(a, b).y < 0)
            {
                isReversed = new float[3] {
                    1, 1, -1
                };
            }

            //SceneManager.Net.Sender(RobotCommands.TelegaMoving());
            var aimsRobot = CoordTransformation.UnityToRobotPosOnly(new Vector4(rc.aims[j].x, rc.aims[j].y, rc.aims[j].z, 1));
            SceneManager.Net.Sender(RobotCommands.TelegaMoving(aimsRobot[0].ToString("0.00"), aimsRobot[1].ToString("0.00")));
            yield return(new WaitForSeconds(0.5f));

            GameObject.Find("telega").GetComponent <telegaScript>().isMoved = true;



            float dst = Mathf.Sqrt((rc.aims[j + 1].x - rc.aims[j].x) * (rc.aims[j + 1].x - rc.aims[j].x) +
                                   (rc.aims[j + 1].z - rc.aims[j].z) * (rc.aims[j + 1].z - rc.aims[j].z)) * 1000f;
            dist = new float[3] {
                dst, dst, dst
            };
            isReversed[0] = isReversed[1] = isReversed[2] = 1;
            angle[0]      = angle[1] = angle[2] = 0;
            yield return(new WaitForSeconds(0.5f));

            GameObject.Find("telega").GetComponent <telegaScript>().isMoved = true;
        }
        rc.aims.RemoveAt(0);
        rc.aims.RemoveAt(0);
    }