Пример #1
0
        void OnGUI()
        {
            if (MyGUI.Button(isEditing ? "编辑中" : "未编辑"))
            {
                isEditing = !isEditing;
            }

            // 当前编辑的场景 add by TangJian 2018/11/21 11:51
            {
                List <SceneController> sceneControllers = MapEditorManager.GetCurrSceneControllerList();
                string[] sceneOptions = new string[sceneControllers.Count];
                for (int i = 0; i < sceneControllers.Count; i++)
                {
                    sceneOptions[i] = sceneControllers[i].name;
                }
                currSelectedSceneIndex = MyGUI.PopupWithTitle("当前编辑场景", currSelectedSceneIndex, sceneOptions);

                if (sceneControllers.CanFindIndex(currSelectedSceneIndex))
                {
                    currSceneController = sceneControllers[currSelectedSceneIndex];
                }
            }

            if (MyGUI.Button("计算角度"))
            {
                // Camera camera = Camera.main;

                // Vector3 beginScreenVec3 = new Vector3(0, 0);
                // Vector3 endScreenVec3 = new Vector3(100, 100);

                // Vector3 endWorldVec3 = camera.ScreenToWorldPoint(endScreenVec3);
                Debug.Log(Mathf.Atan(2) / Mathf.PI * 180);
                Debug.Log(Mathf.Atan(Mathf.Sqrt(3)) / Mathf.PI * 180);

                // Debug.Log(Mathf.Atan(2) / Mathf.PI * 180);


                // Debug.Log();
            }

            gravity = MyGUI.FloatFieldWithTitle("gravity", gravity);

            if (MyGUI.Button("Test"))
            {
                var dict = Tools.GetFileListInFolder("Assets");

                List <string> retList = new List <string>();

                object suo = new object();

                retList.Clear();
                int begin = Tools.GetTimestamp();
                dict.AsParallel().ForAll(pair =>
                {
                    for (int i = 0; i < 100000; i++)
                    {
                    }
                });

                Debug.Log("duration1 = " + (Tools.GetTimestamp() - begin).ToString());

                retList.Clear();
                begin = Tools.GetTimestamp();
                Parallel.ForEach(dict, pair =>
                {
                    for (int i = 0; i < 100000; i++)
                    {
                    }
                });

                Debug.Log("duration2 = " + (Tools.GetTimestamp() - begin).ToString());

                retList.Clear();
                begin = Tools.GetTimestamp();
                foreach (var pair in dict)
                {
                    for (int i = 0; i < 100000; i++)
                    {
                    }
                }

                Debug.Log("duration3 = " + (Tools.GetTimestamp() - begin).ToString());
            }

            valueMonitorPool.Update();
        }