예제 #1
0
    public DirectViewerSampleUi(
        DebugUiManager manager,
        int serverPort,
        System.Action onClickPlay,
        System.Action onClickStop,
        System.Action onClickNext)
    {
        initialWidth  = Screen.width;
        initialHeight = Screen.height;

        manager.ManualStart();
        // ログできるだけ速く欲しいので、こいつのコンストラクトだけ先にやる
        logWindow         = new LogWindow(12f, 400f, 736f, borderEnabled: true, captureUnityLog: true);
        logWindow.Enabled = false;

        var frameTimeGauge = new FrameTimeGauge(100f, 15f, null);

        manager.Add(frameTimeGauge, 0f, 0f, AlignX.Right, AlignY.Bottom);
        menu = new Menu(100f, 40f, Direction.Down, "DebugMenu");
        manager.Add(menu);
        menu.AddItem("LogWindow", () =>
        {
            logWindow.Enabled = !logWindow.Enabled;
        });
        manager.Add(logWindow, 0f, 0f, AlignX.Center, AlignY.Center);

        var ip = DebugServerUtil.GetLanIpAddress();

        if (ip == null)
        {
            ip = "NO NETWORK";
        }
        ipButton = menu.AddItem(ip, () =>
        {
#if UNITY_EDITOR || UNITY_STANDALONE
            var url = string.Format("http://{0}:{1}/", DebugServerUtil.GetLanIpAddress(), serverPort);
            Application.OpenURL(url);
#endif
        });
        menu.AddItem("Play", onClickPlay);
        menu.AddItem("Stop", onClickStop);
        menu.AddItem("Next", onClickNext);
        var text = string.Format("{0}x{1}", Screen.width, Screen.height);
        resoButton = menu.AddItem(text, () =>
        {
            // sqrt(0.5)倍していく。描画面積は半分になる
            var w = Screen.width * 707 / 1000;
            var h = Screen.height * 707 / 1000;
            if (w < (16 * 9))
            {
                w = initialWidth;
                h = initialHeight;
            }
            Screen.SetResolution(w, h, false, 60);
            resoButton.Text = w.ToString() + "x" + h.ToString();
        });
    }
예제 #2
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;
    }
예제 #3
0
    public SampleWindow(DebugUiManager manager) : base(manager, "SampleWindow")
    {
        frameTimeWatcher = new FrameTimeWatcher();

        var button = new Button("ボタン", 100f)
        {
            OnClick = () =>
            {
                log.Add("ボタンが押された!");
            }
        };

        AddAuto(button);

        var toggleGroup = new ToggleGroup();
        var toggles     = new Toggle[2];

        toggles[0] = new Toggle("トグルA", 100f, 50f, toggleGroup)
        {
            OnChangeToOn = () =>
            {
                log.Add("Aが有効になった");
            }
        };
        AddAuto(toggles[0]);
        toggles[1] = new Toggle("トグルB", 100f, 50f, toggleGroup)
        {
            OnChangeToOn = () =>
            {
                log.Add("Bが有効になった");
            }
        };
        AddAuto(toggles[1]);

        var text = new Text("テキスト", fontSize: 20f, width: 80f, height: 25f);

        AddAuto(text);

        BreakLine();

        log = new LogWindow(
            fontSize: 20f,
            width: 600f,
            height: 220f,
            borderEnabled: true,
            captureUnityLog: true); // Unityのログも出しちゃうよ
        AddAuto(log);

        graph = new Graph(5, 200f, 220f);
        graph.AddSeries(new Color32(255, 64, 64, 255));
        AddAuto(graph);

        BreakLine();

        var frameTimeGauge = new FrameTimeGauge(200f, 30f, frameTimeWatcher);

        AddAuto(frameTimeGauge);

        var slider = new Slider("スライダー", -100f, 100f, 400f);

        slider.OnDragEnd = () =>
        {
            log.Add("スライダーが" + slider.Value + "に変更された");
        };
        AddAuto(slider);

        BreakLine();

        var table = new Table(
            16f,
            new List <float>()
        {
            80f, 80f, 120f
        },
            3,
            20f);

        table.Cells[0, 0] = "列A";
        table.Cells[0, 1] = "列B";
        table.Cells[0, 2] = "列C";
        table.Cells[1, 0] = "データ10";
        table.Cells[1, 1] = "データ11";
        table.Cells[1, 2] = "データ12";
        table.Cells[2, 0] = "データ20";
        table.Cells[2, 1] = "データ21";
        table.Cells[2, 2] = "データ23";
        AddAuto(table);

        FitSize();
    }