コード例 #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 void ManualUpdate()
 {
     if (Application.internetReachability == UnityEngine.NetworkReachability.NotReachable)
     {
         ipButton.Text = "NO NETWORK";
     }
     else if ((Time.frameCount % 64) == 0)
     {
         var ip = DebugServerUtil.GetLanIpAddress();
         if (ip == null)
         {
             ipButton.Text = "NO WiFi";
         }
         else
         {
             ipButton.Text = ip;
         }
     }
 }
コード例 #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;
    }
コード例 #4
0
ファイル: Main.cs プロジェクト: Dvolition/UnitySamples
 void Start()
 {
     debugServer = new DebugServer(8080, "/upload/", OnDebugFileServiceChanged);
     debugServer.RegisterRequestCallback("/", OnAccessRoot);
     ipAddress = DebugServerUtil.GetLanIpAddress();
 }