Inheritance: IDisposable
Example #1
0
        /// <summary>
        /// 本地或服务器加载依赖
        /// </summary>
        public IEnumerator UnityManifestWebRequest(bool isLocal, string assetBundleName)
        {
            UnityEngine.Networking.UnityWebRequest manifestReq = null;
            if (!isLocal)
            {
                string assetBundlePath = ServerPath("AssetBundles");
                manifestReq = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(assetBundlePath);
            }
            else
            {
                string assetBundlePath = LocalPath("AssetBundles");
                manifestReq = UnityEngine.Networking.UnityWebRequest.GetAssetBundle("file://" + assetBundlePath);
            }
            yield return(manifestReq.Send());

            AssetBundle         manifestAB = DownloadHandlerAssetBundle.GetContent(manifestReq);
            AssetBundleManifest manifest   = manifestAB.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

            string[] strs = manifest.GetAllDependencies(assetBundleName);
            foreach (string name in strs)
            {
                UnityEngine.Networking.UnityWebRequest dependenceReq = null;
                if (!isLocal)
                {
                    dependenceReq = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(ServerPath(name));
                }
                else
                {
                    dependenceReq = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(LocalPath(name));
                }
                yield return(dependenceReq.Send());

                AssetBundle dependenceAB = DownloadHandlerAssetBundle.GetContent(dependenceReq);
            }
        }
Example #2
0
    IEnumerator load_sub_asset_bundle(string bundle_name)
    {
        // This coroutine loads a single asset bundle at a time
        string uri;
        string path_to_use;

#if UNITY_ANDROID && !UNITY_EDITOR
        // This is the path to require an asset bundle in Assets/StreamingAssets on Android
        path_to_use = Path.Combine("jar:file://" + Application.dataPath + "!assets/", bundle_name);
        uri         = path_to_use;
#else
        // This is the same path but for your computer to recognize
        path_to_use = Application.streamingAssetsPath;
        uri         = path_to_use + "/" + bundle_name;
#endif

        // Ask for the bundle
        UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);

        yield return(request.Send());

        switch (bundle_name)
        {
        case "weapons":
            // Get the bundle data and store it in the AssetBundle variable created at the begining.
            weapons_bundle = DownloadHandlerAssetBundle.GetContent(request);
            break;

        default:
            break;
        }
        // Delay for now is just to make sure it loads properly before its use.
        yield return(new WaitForSeconds(1F));
    }
Example #3
0
    public IEnumerator loadBundle()
    {
        boss = PersistantManager.Instance;



        string uri = "file:///" + Application.dataPath + "/AssetBundles/" + assetBundleName;

        UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0);
        yield return(request.SendWebRequest());

        // yield return request.Send();
        AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
        //ssrp_response_string = bundle.Load<>;
        TextAsset charDataFile2 = bundle.LoadAsset(fileName) as TextAsset;

        ssrp_response_string = charDataFile2.text;
        response_raw         = (SSRP_response_raw)Deserialize(typeof(SSRP_response_raw), ssrp_response_string);
        boss.entityManager.importEntity(response_raw.contextResponses);

        /*
         * GameObject cube = bundle.LoadAsset<GameObject>("Cube");
         *
         * GameObject sprite = bundle.LoadAsset<GameObject>("Sprite");
         * Instantiate(cube);
         * Instantiate(sprite);
         * // */
    }
        public IEnumerator LoadCoroutineIE(string _savePath, DataboxObject _databoxObject, bool _callEvent)
        {
            string _j = "";

            using (UnityEngine.Networking.UnityWebRequest _download = UnityEngine.Networking.UnityWebRequest.Get(_savePath))
            {
                yield return(_download.SendWebRequest());

                while (!_download.isDone)
                {
                                        #if UNITY_2020_1_OR_NEWER
                    if (_download.result == UnityWebRequest.Result.ConnectionError)
                                        #else
                    if (_download.isNetworkError || _download.isHttpError || !string.IsNullOrEmpty(_download.error))
                                        #endif
                    {
                        break;
                    }

                    yield return(null);
                }

                                #if UNITY_2020_1_OR_NEWER
                if (_download.result == UnityWebRequest.Result.ConnectionError)
                                #else
                if (_download.isNetworkError || _download.isHttpError || !string.IsNullOrEmpty(_download.error))
                                #endif
                {
                    Debug.Log(_download.error);
                }
                else
                {
                    _j = _download.downloadHandler.text;
                }
            }



            if (!string.IsNullOrEmpty(_j))
            {
                if (_databoxObject.serializer == DataboxObject.Serializer.FullSerializer)
                {
                    DeserializeWithFullSerializer(_j, _databoxObject, _callEvent);
                }
                else
                {
#if NET_4_6
                    DeserializeWithOdin(_j, _databoxObject, _callEvent);
#endif
                }
            }
            else
            {
                // destroy this object
                //Destroy(this.gameObject);
            }
        }
 public override IObservable <UnityWebRequest> Download(IProgress <float> progress = null)
 {
     return(Observable.Defer(() =>
     {
         var request = Hash.isValid
                                 ? UnityWebRequestAssetBundle.GetAssetBundle(Url, Hash, 0)
                                 : UnityWebRequestAssetBundle.GetAssetBundle(Url);
         return request.SendAsObservable(progress).Do(OnDownloaded);
     }));
 }
Example #6
0
        public static IEnumerator ReadStreamingFile(string path, Action <DownloadHandler> callback)
        {
            if (!path.Contains("://"))
            {
                path = "file://" + path;
            }
            UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path);
            yield return(www.SendWebRequest());

            callback(www.downloadHandler);
        }
Example #7
0
        IObservable <AssetBundle> GetAssetBundleCore(string actualName)
        {
            ThrowIfManifestNotLoaded();
            string url     = RootUrl + actualName;
            var    hash    = Manifest.GetAssetBundleHash(actualName);
            var    request = hash.isValid
                                ? UnityWebRequestAssetBundle.GetAssetBundle(url, hash, 0)
                                : UnityWebRequestAssetBundle.GetAssetBundle(url);

            return(request.SendAsObservable().LoadAssetBundle());
        }
        public IEnumerator LoadSetupCloseBackButtons()
        {
            if (YUR.Yur.YURAssetBundle == null)
            {
                string URI = "file:///" + Application.dataPath + "/AssetBundles/" + YUR.Yur.assetBundleName;
                UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(URI, 0);
                yield return(request.SendWebRequest());

                if (request.error != null)
                {
                    yield break;
                }
                else
                {
                    YUR_Log.Log("Local asset bundle found!");
                    yield return(YUR.Yur.YURAssetBundle = DownloadHandlerAssetBundle.GetContent(request));
                }
            }

            var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Back Button");

            yield return(BackButton = Instantiate(temppp, gameObject.transform));

            // BackButton = (GameObject)Instantiate(Resources.Load("YUR Back Button"), gameObject.transform);
            BackButton.GetComponent <Button>().onClick.AddListener(delegate
            {
                if (BackButtonPressed != null)
                {
                    BackButtonPressed.Invoke();
                }
                YURScreenCoordinator.ScreenCoordinator.BackButtonPressed();
            });


            temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Close Button");
            yield return(CloseButton = Instantiate(temppp, gameObject.transform));

            // CloseButton = (GameObject)Instantiate(Resources.Load("YUR Close Button"), gameObject.transform);

            CloseButton.GetComponent <Button>().onClick.AddListener(delegate
            {
                if (CloseButtonPressed != null)
                {
                    CloseButtonPressed.Invoke();
                }
                YURScreenCoordinator.ScreenCoordinator.CloseButtonPressed();
            });
            if (Finished != null)
            {
                Finished.Invoke();
            }
        }
Example #9
0
    public IEnumerator Download_World()
    {
        yield return(new WaitUntil(() => download));

        string world_name = doARsState.search;

        Debug.Log(world_name);
        // Download the file from the URL. It will not be saved in the Cache
        string BundleURL = "http://www.arnocular.org/handle_doARs/";

        // string BundleURL = "http://127.0.0.1:2567/handle_doARs/";
        UnityEngine.Networking.UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(BundleURL, 0);
        request.SetRequestHeader("world", world_name);
        yield return(request.Send());

        AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);

        Debug.Log(bundle);
        if (world_name == "")
        {
            Instantiate(bundle.mainAsset);
        }
        else
        {
            Handheld.Vibrate();
            UnityEngine.Object[] list_of_worlds = bundle.LoadAllAssets();
            foreach (UnityEngine.Object world in list_of_worlds)
            {
                // GameObject core = GameObject.Find("ModifiedARCore");
                // Transform t = core.transform;
                // t.position += new Vector3(0,0,-1);
                try {
                    UnityEngine.Object clone = Instantiate(world);
                    Debug.Log(clone.name);
                    GameObject f = GameObject.Find(clone.name);
                    f.gameObject.AddComponent <SelfDestruct>();
                    GameObject k = GameObject.Find("PortalWindow");
                    k.GetComponent <Portal>().device = GameObject.Find("First Person Camera").transform;
                }
                catch {
                    Debug.Log("Not available");
                }
            }
            // Instantiate(bundle.LoadAsset(world_name));
        }
        // Unload the AssetBundles compressed contents to conserve memory
        Debug.Log("download asset bundle");
        bundle.Unload(false);
        doARsState.goToState(doARs_state.rest);
        download = false;
        StartCoroutine(Download_World());
    } // memory is freed from the web stream (www.Dispose() gets called implicitly)
Example #10
0
    IEnumerator InstantiateObject()

    {
        string uri = "https://s3-ap-southeast-1.amazonaws.com/vaanarsena/parasu-ar";

        UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(uri);
        yield return(request.SendWebRequest());

        AssetBundle myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(request);
        var         prefab    = myLoadedAssetBundle.LoadAsset("parasu-ar");
        GameObject  parasuRam = Instantiate(prefab, parentGO.transform) as GameObject;
        //ganesh.transform.parent = parentGO.transform;
    }
Example #11
0
    /// <summary>
    /// Initializes a new instance of the `UniWebViewMessage` struct.
    /// </summary>
    /// <param name="rawMessage">Raw message which will be parsed to a UniWebViewMessage.</param>
    public UniWebViewMessage(string rawMessage) : this()
    {
        UniWebViewLogger.Instance.Debug("Try to parse raw message: " + rawMessage);
        this.RawMessage = Net.UnEscapeURL(rawMessage);

        string[] schemeSplit = rawMessage.Split(new string[] { "://" }, System.StringSplitOptions.None);
        if (schemeSplit.Length >= 2)
        {
            this.Scheme = schemeSplit[0];
            UniWebViewLogger.Instance.Debug("Get scheme: " + this.Scheme);

            string pathAndArgsString = "";
            int    index             = 1;
            while (index < schemeSplit.Length)
            {
                pathAndArgsString = string.Concat(pathAndArgsString, schemeSplit[index]);
                index++;
            }
            UniWebViewLogger.Instance.Verbose("Build path and args string: " + pathAndArgsString);

            string[] split = pathAndArgsString.Split("?"[0]);

            this.Path = Net.UnEscapeURL(split[0].TrimEnd('/'));
            this.Args = new Dictionary <string, string>();
            if (split.Length > 1)
            {
                foreach (string pair in split[1].Split("&"[0]))
                {
                    string[] elems = pair.Split("="[0]);
                    if (elems.Length > 1)
                    {
                        var key = Net.UnEscapeURL(elems[0]);
                        if (Args.ContainsKey(key))
                        {
                            var existingValue = Args[key];
                            Args[key] = existingValue + "," + Net.UnEscapeURL(elems[1]);
                        }
                        else
                        {
                            Args[key] = Net.UnEscapeURL(elems[1]);
                        }
                        UniWebViewLogger.Instance.Debug("Get arg, key: " + key + " value: " + Args[key]);
                    }
                }
            }
        }
        else
        {
            UniWebViewLogger.Instance.Critical("Bad url scheme. Can not be parsed to UniWebViewMessage: " + rawMessage);
        }
    }
    IEnumerator Start2()
    {
        //服务器地址
        string uri = @"http://localhost//AssetBundles/scene/sphere.test";

        //本地地址
        //string uri = @"file://D:/Unity3d/APlan_Siki/09_AssetBundleProject/Assets/AssetBundles/scene/sphere.test";
        UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0);
        yield return(request.Send());//开始下载到缓存

        AssetBundle ab     = DownloadHandlerAssetBundle.GetContent(request);
        var         prefab = ab.LoadAsset <GameObject>("Sphere");

        GameObject.Instantiate(prefab);
    }
Example #13
0
        internal static Dictionary <string, BackgroundDownload> LoadDownloads()
        {
            Dictionary <string, BackgroundDownload> downloads = new Dictionary <string, BackgroundDownload>();

            foreach (var item in _dwnloads)
            {
                IntPtr backend = item.Value;
                BackgroundDownloadConfig config = new BackgroundDownloadConfig();
                config.url      = backend.uri;
                config.filePath = item.Key;
                var dl = new BackgroundDownloadEditor(backend, config);
                downloads[config.filePath] = dl;
            }
            return(downloads);
        }
    static int get_error(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            string ret = obj.error;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index error on a nil value"));
        }
    }
    static int set_timeout(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.timeout = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index timeout on a nil value"));
        }
    }
    static int set_certificateHandler(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest    obj  = (UnityEngine.Networking.UnityWebRequest)o;
            UnityEngine.Networking.CertificateHandler arg0 = (UnityEngine.Networking.CertificateHandler)ToLua.CheckObject <UnityEngine.Networking.CertificateHandler>(L, 2);
            obj.certificateHandler = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index certificateHandler on a nil value"));
        }
    }
    static int set_uri(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            System.Uri arg0 = (System.Uri)ToLua.CheckObject <System.Uri>(L, 2);
            obj.uri = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uri on a nil value"));
        }
    }
    static int get_uploadedBytes(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            ulong ret = obj.uploadedBytes;
            LuaDLL.tolua_pushuint64(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uploadedBytes on a nil value"));
        }
    }
    static int get_certificateHandler(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest    obj = (UnityEngine.Networking.UnityWebRequest)o;
            UnityEngine.Networking.CertificateHandler ret = obj.certificateHandler;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index certificateHandler on a nil value"));
        }
    }
    static int get_responseCode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            long ret = obj.responseCode;
            LuaDLL.tolua_pushint64(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index responseCode on a nil value"));
        }
    }
    static int get_timeout(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            int ret = obj.timeout;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index timeout on a nil value"));
        }
    }
    static int get_isDone(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            bool ret = obj.isDone;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isDone on a nil value"));
        }
    }
    static int set_useHttpContinue(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.useHttpContinue = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index useHttpContinue on a nil value"));
        }
    }
    static int get_downloadProgress(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            float ret = obj.downloadProgress;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index downloadProgress on a nil value"));
        }
    }
    static int get_result(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest        obj = (UnityEngine.Networking.UnityWebRequest)o;
            UnityEngine.Networking.UnityWebRequest.Result ret = obj.result;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index result on a nil value"));
        }
    }
    static int get_uri(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            System.Uri ret = obj.uri;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uri on a nil value"));
        }
    }
    IEnumerator DownloadAndCreatePrefab()
    {
        UnityEngine.Networking.UnityWebRequest request
            = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);

        // cope with security issue for local host
//        request.certificateHandler = new CertHandler();

        yield return(request.SendWebRequest());

        AssetBundle myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(request);

        // create and instantiate prefab - red Cube
        GameObject cubePrefab = myLoadedAssetBundle.LoadAsset <GameObject>(prefabName);

        Instantiate(cubePrefab);
    }
Example #28
0
    static int get_webRequest(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequestAsyncOperation obj = (UnityEngine.Networking.UnityWebRequestAsyncOperation)o;
            UnityEngine.Networking.UnityWebRequest ret = obj.webRequest;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index webRequest on a nil value"));
        }
    }
    static int set_method(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.method = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index method on a nil value"));
        }
    }
    static int set_disposeUploadHandlerOnDispose(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.disposeUploadHandlerOnDispose = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index disposeUploadHandlerOnDispose on a nil value"));
        }
    }
        /// <summary>
        /// Creates a SparkMessage from a JSON Spark response.
        /// </summary>
        /// <param name="data">Dictionary of data about the SparkMessage.</param>
        /// <param name="request">The associated UnityWebRequest.</param>
        public SparkMessage(Dictionary<string, object> data, UnityWebRequest request)
        {
            WebRequest = request;
            Message = (string)data["message"];
            Errors = new List<SparkError>();

            object errors;
            if (data.TryGetValue("errors", out errors))
            {
                var listOfErrors = errors as List<object>;
                var errorList = new List<SparkError>();
                foreach (var error in listOfErrors)
                {
                    errorList.Add(new SparkError(error as Dictionary<string, object>));
                }
                Errors = errorList;
            }
            TrackingId = (string)data["trackingId"];
        }
Example #32
0
 public WebRequestEventArgs(UnityWebRequest request)
 {
     WebRequest = request;
 }
 /// <summary>
 /// <para>Returns the downloaded AssetBundle, or null.</para>
 /// </summary>
 /// <param name="www">A finished UnityWebRequest object with DownloadHandlerAssetBundle attached.</param>
 /// <returns>
 /// <para>The same as DownloadHandlerAssetBundle.assetBundle</para>
 /// </returns>
 public static AssetBundle GetContent(UnityWebRequest www)
 {
     return DownloadHandler.GetCheckedDownloader<DownloadHandlerAssetBundle>(www).assetBundle;
 }
Example #34
0
 public void Restful(ERestful method, string action)
 {
     UnityWebRequest request = new UnityWebRequest(url + action, method.ToString());
     queue.Enqueue(request);
 }
 /// <summary>
 /// Creates a SparkMessage object from a UnityWebRequest.
 /// </summary>
 /// <param name="request">The associated UnityWebRequest.</param>
 public SparkMessage(UnityWebRequest request)
 {
     WebRequest = request;
 }
Example #36
0
 public UpdateList(UnityWebRequest request)
 {
     this.Parse(new UTF8Encoding(false).GetString(request.downloadHandler.data));
 }
 /// <summary>
 /// <para>Returns the downloaded AudioClip, or null.</para>
 /// </summary>
 /// <param name="www">A finished UnityWebRequest object with DownloadHandlerAudioClip attached.</param>
 /// <returns>
 /// <para>The same as DownloadHandlerAudioClip.audioClip</para>
 /// </returns>
 public static AudioClip GetContent(UnityWebRequest www)
 {
     return DownloadHandler.GetCheckedDownloader<DownloadHandlerAudioClip>(www).audioClip;
 }
 /// <summary>
 /// <para>Returns a copy of the native-memory buffer interpreted as a UTF8 string.</para>
 /// </summary>
 /// <param name="www">A finished UnityWebRequest object with DownloadHandlerBuffer attached.</param>
 /// <returns>
 /// <para>The same as DownloadHandlerBuffer.text</para>
 /// </returns>
 public static string GetContent(UnityWebRequest www)
 {
     return DownloadHandler.GetCheckedDownloader<DownloadHandlerBuffer>(www).text;
 }
 /// <summary>
 /// <para>Returns the downloaded Texture, or null.</para>
 /// </summary>
 /// <param name="www">A finished UnityWebRequest object with DownloadHandlerTexture attached.</param>
 /// <returns>
 /// <para>The same as DownloadHandlerTexture.texture</para>
 /// </returns>
 public static Texture2D GetContent(UnityWebRequest www)
 {
     return DownloadHandler.GetCheckedDownloader<DownloadHandlerTexture>(www).texture;
 }
Example #40
0
        /// <summary>
        /// Generate a Web Request to Spark.
        /// </summary>
        /// <param name="resource">Resource.</param>
        /// <param name="requestType">Request type.</param>
        /// <param name="data">Data to upload.</param>
        public UnityWebRequest Generate(string resource, string requestType, byte[] data = null)
        {
            // Setup Headers.
            var www = new UnityWebRequest(BaseUrl + "/" + resource);
            www.SetRequestHeader("Authorization", "Bearer " + AuthenticationToken);
            www.SetRequestHeader("Content-type", "application/json; charset=utf-8");
            www.method = requestType;
            www.downloadHandler = new DownloadHandlerBuffer();

            // Is there data to upload?
            if (data != null)
            {
                www.uploadHandler = new UploadHandlerRaw(data);
            }

            return www;
        }