Example #1
0
        protected override void OnFetchingResponse()
        {
            // Create respone based on completion data
            if (string.IsNullOrEmpty(WWWObject.error))
            {
                IDictionary _responseDict = JSONUtility.FromJSON(WWWObject.text) as IDictionary;

                if (OnSuccess != null)
                {
                    OnSuccess(_responseDict);
                }
            }
            else
            {
                IDictionary _responseDict = new Dictionary <string, string>()
                {
                    { "error", WWWObject.error }
                };

                if (OnFailure != null)
                {
                    OnFailure(_responseDict);
                }
            }
        }
Example #2
0
        public static Texture2D Deserialise(string _strImg)
        {
            IDictionary _decodedDict = JSONUtility.FromJSON(_strImg) as Dictionary <string, object>;

            if (_decodedDict != null)
            {
                // Extracting properties from padded fields
                int    _width      = (int)_decodedDict["width"];
                int    _height     = (int)_decodedDict["height"];
                string _texDataB64 = _decodedDict["texture"] as string;

                return(CreateTexture(_texDataB64, _width, _height));
            }

            return(null);
        }