Example #1
0
    void Start()
    {
        _debugUi = DebugUiManager.Create(
            _camera,
            _textShader,
            _texturedShader,
            _font,
            referenceScreenWidth: 1024,
            referenceScreenHeight: 576,
            screenPlaneDistance: 100f,
            triangleCapacity: 8192);
        _sampleWindow = new SampleWindow(_debugUi);
        _debugUi.Add(_sampleWindow, 0, 0, DebugUi.AlignX.Right, DebugUi.AlignY.Bottom);

        _menu = new DebugUiMenu(100, 40);
        var subA = new DebugUiSubMenu("SubA", 100, 40, DebugUi.Direction.Down);

        subA.AddItem("A1", () => Debug.Log("A1"));
        subA.AddItem("A2", () => Debug.Log("A2"));
        var subB = new DebugUiSubMenu("SubA", 100, 40, DebugUi.Direction.Down);

        subB.AddItem("B1", () => Debug.Log("B1"));
        subB.AddItem("B2", () => Debug.Log("B2"));
        subA.AddSubMenu(subB, DebugUi.Direction.Right);
        _menu.AddSubMenu(subA, DebugUi.Direction.Down);
        _menu.AddItem("1", () => Debug.Log("1"));
        _menu.AddItem("2", () => Debug.Log("2"));
        _debugUi.Add(_menu, 0, 0);
    }
Example #2
0
        private static DebugUiMenu CreateMenu(KeyInputHandler handler)
        {
            var menu = new DebugUiMenu(100, 80, direction: DebugUi.Direction.Down);

            foreach (var g in handler.Definition)
            {
                var sub = new DebugUiSubMenu(g.Name, 100, 80);
                foreach (var a in g.Assigns)
                {
                    sub.AddItem(a.Name + "\n[" + a.Key.ToString() + "]", () => { if (g.IsActive)
                                                                                 {
                                                                                     a.OnKeyDown.Invoke();
                                                                                 }
                                });
                }
                menu.AddSubMenu(sub, DebugUi.Direction.Right);
            }
            return(menu);
        }
Example #3
0
    public DebugService(
        World world,
        int serverPort,
        Camera camera,
        Shader textShader,
        Shader texturedShader,
        Font font,
        Sprite tapMark,
        string debugServerIndexHtml)
    {
        var decodedToken = DebugSlack.DecryptXor(slackKey, slackEncodedToken);

        if (decodedToken != null)
        {
            slack = new DebugSlack(decodedToken, "テキトーなチャンネル名");
        }
        // ログできるだけ速く欲しいので、こいつのコンストラクトだけ先にやる
        Log         = new DebugUiLogWindow(12f, 380f, 700f, borderEnabled: true, captureUnityLog: true);
        Log.enabled = false;

        this.world = world;
        this.debugServerIndexHtml = debugServerIndexHtml;
        server = new DebugServer(serverPort, "/assets/", OnFileChanged);

        uiManager = DebugUiManager.Create(
            camera,
            textShader,
            texturedShader,
            font,
            432,
            768,
            1f,
            8192);
        uiManager.safeAreaVisualizationEnabled = true;
        var frameTimeGauge = new FrameTimeGauge(100f, 15f, null);

        uiManager.Add(frameTimeGauge, 0f, 0f, DebugUi.AlignX.Right, DebugUi.AlignY.Bottom);
        menu = new DebugUiMenu(100f, 40f, DebugUi.Direction.Down, "DebugMenu");
        uiManager.Add(menu);
        menu.AddItem("LogWindow", () =>
        {
            Log.enabled = !Log.enabled;
        });
        uiManager.Add(Log, 0, 40f, DebugUi.AlignX.Center, DebugUi.AlignY.Top);

        var dataSubMenu = new DebugUiSubMenu("Data", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(dataSubMenu, DebugUi.Direction.Right);
        dataSubMenu.AddItem("SendJsons", () =>
        {
            world.StartCoroutine(CoSendJsons());
        });
        dataSubMenu.AddItem("Reload\nGlobalParams", () =>
        {
            world.ReloadGlobalParams();
        });

        var debugSubMenu = new DebugUiSubMenu("Debug", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(debugSubMenu, DebugUi.Direction.Right);

        debugSubMenu.AddItem("HideDebug", () =>
        {
            ToggleUiEnabled();
        });

        debugSubMenu.AddItem("AutoTap", () =>
        {
            tapper.enabled = !tapper.enabled;
        });

        var resoSubMenu = new DebugUiSubMenu("Resolution", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(resoSubMenu, DebugUi.Direction.Right);
        var text = string.Format("{0}x{1}", Screen.width, Screen.height);

        resoButton = resoSubMenu.AddItem(text, () =>
        {
            var w = Screen.width * 70 / 100;
            var h = Screen.height * 70 / 100;
            if (w < (16 * 9))
            {
                w = 720;
                h = 1280;
            }
            Screen.SetResolution(w, h, false, 60);
            resoButton.text = w.ToString() + "x" + h.ToString();
        });
        resoSubMenu.AddItem("Aspect\n4:3", () =>
        {
            ScreenSettings.Save(1536, 2048, 0, 0, 0, 0);
        });
        resoSubMenu.AddItem("Aspect\n16:9", () =>
        {
            ScreenSettings.Save(1080, 1920, 0, 0, 0, 0);
        });
        resoSubMenu.AddItem("Aspect\niPhoneX", () =>
        {
            ScreenSettings.Save(1242, 2688, 0, 0, 132, 102);
        });
        resoSubMenu.AddItem("Aspect\nDefault", () =>
        {
            ScreenSettings.SaveDefault();
        });

        menu.AddItem(DebugServerUtil.GetLanIpAddress(), () =>
        {
            var url = string.Format("http://{0}:{1}/", DebugServerUtil.GetLanIpAddress(), serverPort);
            Application.OpenURL(url);
        });
//		uiManager.enabled = false; // 初期状態は無効

        server.RegisterRequestCallback("/", OnWebRequestRoot);
        server.RegisterRequestCallback("/api/upload-file", OnWebRequestUploadFile);
        server.RegisterRequestCallback("/api/delete-file", OnWebRequestDeleteFile);
        server.RegisterRequestCallback("/api/delete-all-file", OnWebRequestDeleteAllFile);
        server.RegisterRequestCallback("/api/toggle-debug", OnWebRequestToggleDebug);

        var go = new GameObject("DebugTapper");

        tapper = go.AddComponent <DefaultDebugTapper>();
        tapper.ManualStart(8, tapMark);
        tapper.enabled = false;
    }