예제 #1
0
        public override object parser(LoaderXDataType parserType)
        {
            switch (parserType)
            {
            case LoaderXDataType.BYTES:
                _data = www.bytes;
                break;

            case LoaderXDataType.MANIFEST:
                if (assetBundle == null)
                {
                    assetBundle = www.assetBundle;
                }
                if (assetBundle != null)
                {
                    _data = assetBundle.LoadAsset("AssetBundleManifest");
                }
                else
                {
                    _data = null;
                    Debug.Log("No this Manisfest");
                }
                break;

            case LoaderXDataType.TEXTURE:
                texture2D = www.texture;
                if (www.assetBundle != null)
                {
                    www.assetBundle.Unload(false);
                }
                _data = texture2D;
                break;

            case LoaderXDataType.SOUND:
                _data = www.audioClip;
                break;

            case LoaderXDataType.ASSETBUNDLE:
                if (assetBundle == null)
                {
                    assetBundle = www.assetBundle;
                }
                _data = assetBundle;
                break;

            case LoaderXDataType.SPRITE:
                if (assetBundle == null)
                {
                    assetBundle = www.assetBundle;
                }
                if (assetBundle != null)
                {
                    _data = assetBundle.LoadAllAssets <Sprite>();    //assetBundle.LoadAll(typeof (Sprite));
                }
                break;

            case LoaderXDataType.AMF:
                ByteArray bytes = new ByteArray(www.bytes);
                if (bytes.BytesAvailable > 0)
                {
                    try
                    {
                        bytes.Inflate();
                    }
                    catch (Exception)
                    {
                        bytes.Position = 0;
                    }
                    _data = bytes.ReadObject();
                }
                else
                {
                    _data = null;
                }
                break;
            }

            return(_data);
        }