Beispiel #1
0
    public override IEnumerator CoLoad(GameState gameState)
    {
        this.gameState       = gameState;
        canvas.renderMode    = RenderMode.ScreenSpaceCamera;
        canvas.planeDistance = 2f;
        canvas.worldCamera   = gameState.World.CameraController.Camera;

        // ステージデータ読み込み
        var ret  = new CoroutineReturnValue <string>();
        var path = string.Format("StageData/stage_{0}.json", gameState.StageIndex);

        yield return(DebugServerUtil.CoLoad(ret, path));

        if (ret.Exception != null)
        {
            Debug.LogException(ret.Exception);
            yield break;
        }
        var newStageData = UnityEngine.JsonUtility.FromJson <StageData>(ret.Value);

        if (newStageData != null)
        {
            stageData = newStageData;
        }
        else
        {
            Debug.LogError("json deserialization error.");
        }
    }
Beispiel #2
0
 void OnWebRequestDeleteAllFile(out string outputHtml, string inputText)
 {
     DebugServerUtil.DeleteAllOverride();
     // 再度ロード
     StartCoroutine(CoLoad());
     outputHtml = null;
 }
Beispiel #3
0
    void OnWebRequestUploadFile(out string outputHtml, string inputText)
    {
        outputHtml = null;
        if (string.IsNullOrEmpty(inputText))
        {
            outputHtml = "入力テキストがない.";
            return;
        }
        var arg = UnityEngine.JsonUtility.FromJson <UploadFileArg>(inputText);

        if (string.IsNullOrEmpty(arg.path))
        {
            outputHtml = "アップロードしたファイルのパスが空.";
            return;
        }
        if (arg.contentBase64 == null)
        {
            outputHtml = "ファイルの中身が空.";
            return;
        }
        var bytes = System.Convert.FromBase64String(arg.contentBase64);

        DebugServerUtil.SaveOverride(arg.path, bytes);
        // 再度ロード
        StartCoroutine(CoLoad());
    }
 void OnWebRequestDeleteAllFile(
     out string outputHtml,
     NameValueCollection queryString,
     Stream bodyData)
 {
     outputHtml = null;
     DebugServerUtil.DeleteAllOverride();
     OnOverrideFileChanged(null);         // ファイルを消した後通知
 }
Beispiel #5
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();
        });
    }
Beispiel #6
0
    void OnWebRequestDeleteFile(out string outputHtml, NameValueCollection queryString, Stream bodyData)
    {
        outputHtml = null;
        var path = queryString["path"];

        if (string.IsNullOrEmpty(path))
        {
            outputHtml = "アップロードしたファイルのパスが空.";
            return;
        }
        DebugServerUtil.DeleteOverride(path);
        loadRequested = true;
    }
    IEnumerator CoLoad(string path)
    {
        Unload();
        var ret = new CoroutineReturnValue <AssetBundle>();

        yield return(DebugServerUtil.CoLoad(ret, path));

        if (ret.Value == null)
        {
            if (ret.Exception != null)
            {
                Debug.LogException(ret.Exception);
            }
            else
            {
                Debug.LogError("CoLoad: Can't get value.");
            }
            loadCoroutine = null;
            yield break;
        }
        assetBundle = ret.Value;

#if false
        var names = assetBundle.GetAllAssetNames();
        foreach (var name in names)
        {
            Debug.Log("\tAsset: " + name);
        }
#endif
        var op = assetBundle.LoadAllAssetsAsync <GameObject>();
        yield return(op);

        if (op.allAssets == null)
        {
            Debug.LogError("No Prefab Contained.");
            loadCoroutine = null;
            yield break;
        }
        prefabs = new GameObject[op.allAssets.Length];
        for (int i = 0; i < op.allAssets.Length; i++)
        {
            prefabs[i] = op.allAssets[i] as GameObject;
//            Debug.Log("\tprefab: " + prefabs[i].name);
        }

        prefabIndex = 0;

        CreateInstance();
        loadCoroutine = null;
    }
    IEnumerator CoSendTextFile(string path)
    {
        if (slack == null)
        {
            yield break;
        }
        var ret = new CoroutineReturnValue <string>();

        yield return(DebugServerUtil.CoLoad(ret, path));

        if (ret.Exception == null)
        {
            yield return(slack.CoPostSnippet(ret.Value, null, null, path));
        }
    }
Beispiel #9
0
    IEnumerator CoLoad()
    {
        audioSource.Stop();
        var retJson = new CoroutineReturnValue <string>();

        yield return(DebugServerUtil.CoLoad(retJson, "Jsons/rotation_speed.json"));

        if (retJson.Exception != null)
        {
            Debug.LogException(retJson.Exception);
        }
        var retImage = new CoroutineReturnValue <Texture2D>();

        yield return(DebugServerUtil.CoLoad(retImage, "Images/image.png"));

        if (retImage.Exception != null)
        {
            Debug.LogException(retImage.Exception);
        }
        var retSound = new CoroutineReturnValue <AudioClip>();

        yield return(DebugServerUtil.CoLoad(retSound, "Sounds/sound.wav"));

        if (retSound.Exception != null)
        {
            Debug.LogException(retSound.Exception);
        }

        if (retJson.Value != null)
        {
            rotationSpeed = JsonUtility.FromJson <RotationSpeedData>(retJson.Value).rotationSpeed;
        }

        if (retImage.Value != null)
        {
            image.texture = retImage.Value;
        }

        if (retSound.Value != null)
        {
            audioSource.clip = retSound.Value;
        }
        coroutine = null;
    }
Beispiel #10
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;
         }
     }
 }
Beispiel #11
0
    void OnWebRequestDeleteFile(out string outputHtml, string inputText)
    {
        outputHtml = null;
        if (string.IsNullOrEmpty(inputText))
        {
            outputHtml = "入力テキストがない.";
            return;
        }
        var arg = UnityEngine.JsonUtility.FromJson <UploadFileArg>(inputText);

        if (string.IsNullOrEmpty(arg.path))
        {
            outputHtml = "消したファイルのパスが空.";
            return;
        }
        DebugServerUtil.DeleteOverride(arg.path);
        // 再度ロード
        StartCoroutine(CoLoad());
    }
Beispiel #12
0
    IEnumerator CoLoad()
    {
        audioSource.Stop();
        var retJson = new CoroutineReturnValue <string>();

        yield return(DebugServerUtil.CoLoad(retJson, "rotation_speed.json"));

        var retImage = new CoroutineReturnValue <Texture2D>();

        yield return(DebugServerUtil.CoLoad(retImage, "image.png"));

        var retSound = new CoroutineReturnValue <AudioClip>();

        yield return(DebugServerUtil.CoLoad(retSound, "sound.wav"));

        rotationSpeed    = JsonUtility.FromJson <RotationSpeedData>(retJson.Value).rotationSpeed;
        image.texture    = retImage.Value;
        audioSource.clip = retSound.Value;
    }
    void OnWebRequestUploadFile(
        out string outputHtml,
        NameValueCollection queryString,
        Stream bodyData)
    {
        outputHtml = null;
        if (bodyData == null)
        {
            outputHtml = "中身が空.";
            return;
        }
        var path = queryString["path"];

        if (string.IsNullOrEmpty(path))
        {
            outputHtml = "アップロードしたファイルのパスが空.";
            return;
        }
        DebugServerUtil.SaveOverride(path, bodyData);
        OnOverrideFileChanged(path);
    }
    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;
    }
Beispiel #15
0
 void OnWebRequestDeleteAllFile(out string outputHtml, NameValueCollection queryString, Stream bodyData)
 {
     DebugServerUtil.DeleteAllOverride();
     outputHtml    = null;
     loadRequested = true;
 }
Beispiel #16
0
 void Start()
 {
     debugServer = new DebugServer(8080, "/upload/", OnDebugFileServiceChanged);
     debugServer.RegisterRequestCallback("/", OnAccessRoot);
     ipAddress = DebugServerUtil.GetLanIpAddress();
 }