Exemple #1
0
    //运动控制界面
    void MotionControl()
    {
        GUI.contentColor                = Color.white;
        GUI.skin.label.fontSize         = 13;
        GUI.skin.label.normal.textColor = Color.white;

        GUI.Label(new Rect(30, 80, 130, 20), "从该节点开始运行:");
        st_Manager.tableNum = GUI.TextField(new Rect(145, 80, 40, 20), st_Manager.tableNum);
        GUI.Label(new Rect(190, 80, 130, 20), "ROW:");
        st_Manager.rowNum = GUI.TextField(new Rect(230, 80, 40, 20), st_Manager.rowNum);
        if (GUI.Button(new Rect(280, 80, 70, 20), "运行"))
        {
            //首先判断节点号
            int nodeNum = 0;
            try
            {
                nodeNum = int.Parse(st_Manager.tableNum);
            }
            catch
            {
                Debug.LogError("ID号不是数字!");
                return;
            }
            if (nodeNum < 1)
            {
                Debug.LogError("ID号从1开始!");
                return;
            }
            //处理ID号
            int rowNum = 0;
            try
            {
                rowNum = int.Parse(st_Manager.rowNum);
            }
            catch
            {
                Debug.LogError("ROW处应填Excel对应的行号,从2开始!");
                return;
            }
            if (rowNum < 2)
            {
                Debug.LogError("ROW号从2开始!");
                return;
            }
            if (MotionPara.MotionActive)
            {
                st_Manager.StopButton();
            }
            st_Manager.SetLocation(nodeNum, st_Manager.rowNum);
            MotionPara.PauseControl = false;
            StartCoroutine(st_Manager.MainEntrance(nodeNum - 1, rowNum - 2));
        }
        GUI.contentColor = Color.green;
        //时间信息
        st_Manager.isTimeLoad = GUI.Toggle(new Rect(380, 80, 300, 20), st_Manager.isTimeLoad, timeDisplayStr);
        if (st_Manager.isTimeLoad)
        {
            timeDisplayStr = "已加载时间信息";
        }
        else
        {
            timeDisplayStr = "未加载时间信息";
        }
        //位置信息
        st_Manager.createPosition = GUI.Toggle(new Rect(380, 100, 300, 20), st_Manager.createPosition, autoLocationStr);
        if (st_Manager.createPosition)
        {
            autoLocationStr = "播放时生成位置信息";
        }
        else
        {
            autoLocationStr = "播放时不生成位置信息";
        }
        GUI.contentColor = Color.white;

        //表格编辑器控制
        GUI.contentColor = Color.cyan;
        if (GUI.Button(new Rect(380, 130, 130, 30), "打开表格编辑器"))
        {
            MotionEditor.show            = true;
            st_Editor.ExcelWriteWindow.x = 0;
            st_Editor.ExcelWriteWindow.y = 0;
        }
        currentEditorExcel = GUI.TextField(new Rect(380, 170, 55, 30), currentEditorExcel);
        if (GUI.Button(new Rect(450, 170, 60, 30), "切换表格"))
        {
            string filePath = Application.dataPath + "/Resources/" + MotionPara.taskName + st_Manager.subTablePath + currentEditorExcel;
            if (File.Exists(filePath + ".xls"))
            {
                currentIDIndex = st_Manager.idList.IndexOf(currentEditorExcel);;
                st_Editor.setExcel(filePath);
            }
            else
            {
                Debug.LogError("该文件不存在---路径:" + filePath);
                return;
            }
        }
        if (GUI.Button(new Rect(380, 210, 60, 30), "上一个"))
        {
            int formerID = 0;
            if (currentIDIndex == -1)
            {
                return;
            }
            else if (currentIDIndex == 0)
            {
                formerID           = st_Manager.idList.Count - 1;
                currentEditorExcel = st_Manager.idList[formerID];
            }
            else
            {
                formerID           = currentIDIndex - 1;
                currentEditorExcel = st_Manager.idList[formerID];
            }
            string filePath = Application.dataPath + "/Resources/" + MotionPara.taskName + st_Manager.subTablePath + currentEditorExcel;
            if (File.Exists(filePath + ".xls"))
            {
                currentIDIndex = st_Manager.idList.IndexOf(currentEditorExcel);;
                st_Editor.setExcel(filePath);
            }
            else
            {
                Debug.LogError("该文件不存在---路径:" + filePath);
                return;
            }
        }
        if (GUI.Button(new Rect(450, 210, 60, 30), "下一个"))
        {
            int formerID = 0;
            if (currentIDIndex == -1)
            {
                return;
            }
            else if (currentIDIndex == st_Manager.idList.Count - 1)
            {
                formerID           = 0;
                currentEditorExcel = st_Manager.idList[formerID];
            }
            else
            {
                formerID           = currentIDIndex + 1;
                currentEditorExcel = st_Manager.idList[formerID];
            }
            string filePath = Application.dataPath + "/Resources/" + MotionPara.taskName + st_Manager.subTablePath + currentEditorExcel;
            if (File.Exists(filePath + ".xls"))
            {
                currentIDIndex = st_Manager.idList.IndexOf(currentEditorExcel);;
                st_Editor.setExcel(filePath);
            }
            else
            {
                Debug.LogError("该文件不存在---路径:" + filePath);
                return;
            }
        }


        GUI.contentColor = Color.white;


        GUI.Label(new Rect(30, 110, 130, 20), "运动控制:");
        if (GUI.Button(new Rect(40, 140, 40, 40), "开始"))
        {
            st_Manager.PlayButton();
        }
        if (GUI.Button(new Rect(90, 140, 40, 40), "暂停"))
        {
            st_Manager.PauseButton();
        }
        if (GUI.Button(new Rect(140, 140, 40, 40), "减速"))
        {
            st_Manager.SpeedControl(false);
        }
        if (GUI.Button(new Rect(190, 140, 40, 40), "加速"))
        {
            st_Manager.SpeedControl(true);
        }
        if (GUI.Button(new Rect(240, 140, 40, 40), "停止"))
        {
            st_Manager.StopButton();
        }
        if (GUI.Button(new Rect(290, 140, 60, 40), "单步运行"))
        {
            st_Manager.SinglePlayButton();
        }
        st_Manager.hSliderValue = GUI.HorizontalSlider(sliderRect, st_Manager.hSliderValue, 0.0f, st_Manager.TotalValue);
        if (sliderRect.Contains(Event.current.mousePosition))
        {
            if (Input.GetMouseButtonDown(0) && !st_Manager.dragLock && !st_Manager.dragActive)
            {
                st_Manager.dragActive = true;
                st_Manager.preProcess = st_Manager.hSliderValue;
            }
        }

        if (GUI.Button(new Rect(40, 210, 90, 30), "超快速播放"))
        {
            st_Manager.ChangeRate(100f);
        }
        GUI.Box(new Rect(140, 205, 120, 40), "");
        GUI.Label(new Rect(145, 208, 120, 30), "当前速度值:");
        GUI.contentColor = Color.green;
        GUI.Label(new Rect(225, 208, 120, 30), MotionPara.SpeedRate.ToString());
        GUI.contentColor = Color.white;
        GUI.Label(new Rect(145, 223, 120, 30), "播放状态:");
        GUI.contentColor = Color.green;
        if (MotionPara.MotionActive)
        {
            if (MotionPara.PauseControl)
            {
                GUI.Label(new Rect(215, 223, 120, 30), "暂停中");
            }
            else
            {
                GUI.Label(new Rect(215, 223, 120, 30), "播放中");
            }
        }
        else
        {
            GUI.Label(new Rect(215, 223, 120, 30), "停止中");
        }

        GUI.contentColor = Color.white;
        if (GUI.Button(new Rect(270, 210, 80, 30), "速度恢复1"))
        {
            st_Manager.ChangeRate(1f);
        }

        GUI.Box(new Rect(40, 250, 140, 30), "");
        GUI.Label(new Rect(45, 253, 130, 20), "当前运动方式:");
        GUI.contentColor = Color.green;
        GUI.Label(new Rect(130, 253, 100, 20), motionTypeStr);
        GUI.contentColor = Color.white;
        if (GUI.Button(new Rect(40, 290, 40, 30), "拆"))
        {
            //if (FuncPara.curentMode != Movement.Chai)
            //{
            //	motionTypeStr = "拆动画";

            //}
        }
        if (GUI.Button(new Rect(90, 290, 40, 30), "装"))
        {
            //if (FuncPara.curentMode != Movement.Zhuang)
            //{
            //	motionTypeStr = "装动画";

            //}
        }
        if (GUI.Button(new Rect(140, 290, 40, 30), "原理"))
        {
            //if (FuncPara.curentMode != Movement.Yuan)
            //{
            //	motionTypeStr = "原理动画";

            //}
        }

        GUI.Box(new Rect(200, 250, 140, 30), "");
        GUI.Label(new Rect(205, 253, 130, 20), "当前运动状态:");
        GUI.contentColor = Color.green;
        GUI.Label(new Rect(290, 253, 100, 20), motionStateStr);
        GUI.contentColor = Color.white;
        //教
        if (GUI.Button(new Rect(200, 290, 40, 30), "教"))
        {
            if (FuncPara.currentMotion != MotionState.Teaching)
            {
                motionStateStr         = "教";
                FuncPara.currentMotion = MotionState.Teaching;
            }
        }
        //练
        if (GUI.Button(new Rect(250, 290, 40, 30), "练"))
        {
            if (FuncPara.currentMotion != MotionState.Exercising)
            {
                motionStateStr         = "练";
                FuncPara.currentMotion = MotionState.Exercising;
            }
        }
        //考
        if (GUI.Button(new Rect(300, 290, 40, 30), "考"))
        {
            //if (FuncPara.currentMotion != MotionState.Examining)
            //{
            //	motionStateStr = "考";

            //}
        }
        GUI.contentColor = Color.white;
    }