Exemplo n.º 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.");
        }
    }
    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;
    }
Exemplo n.º 3
0
    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));
        }
    }
Exemplo n.º 4
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;
    }
Exemplo n.º 5
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;
    }