コード例 #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.");
        }
    }
コード例 #2
0
    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;
    }
コード例 #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));
        }
    }
コード例 #4
0
ファイル: Main.cs プロジェクト: zhaozilong1988/UnitySamples
    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;
    }
コード例 #5
0
ファイル: Main.cs プロジェクト: sugiyamasaya419/UnitySamples
    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;
    }