Skip to content

Commit

Permalink
support 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed Jan 25, 2019
1 parent bf8b309 commit d5b4709
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,26 @@ namespace QFramework
public class TestSpriteAtlas : MonoBehaviour
{
[SerializeField] private Image mImage;

// Use this for initialization
private IEnumerator Start()
{
var loader = ResLoader.Allocate();

ResMgr.Init();

#if UNITY_2017_1_OR_NEWER
var spriteAtlas = loader.LoadSync<SpriteAtlas>("spriteatlas");
var square = spriteAtlas.GetSprite("Square");
Log.I(spriteAtlas.spriteCount);

mImage.sprite = square;

#endif

yield return new WaitForSeconds(5.0f);

loader.Recycle2Cache();
loader = null;
}
}
}
}
13 changes: 10 additions & 3 deletions Assets/QFramework/Framework/0.Core/8.CrossPlatformAPI/UnityAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public IDisposable HttpGet(string url, Dictionary<string, string> headers, Actio
return ObservableWWW.Get(url, headers).Subscribe(onResponse);
}

public IDisposable HttpPost(string url, Dictionary<string, string> headers, Dictionary<string, string> form, Action<string> onResponse)
public IDisposable HttpPost(string url, Dictionary<string, string> headers, Dictionary<string, string> form,
Action<string> onResponse)
{
var wwwForm = new WWWForm();

Expand All @@ -42,7 +43,7 @@ public IDisposable HttpPatch(string url, Dictionary<string, string> headers,
contentDict.ForEach((key, value) => { jsonForm[key] = value; });

var content = new ByteArrayContent(Encoding.UTF8.GetBytes(jsonForm.ToString()), "application/json");

httpClient.Patch(new Uri(url), content, (responseContent) => { onResponse(responseContent.Data); });

return Disposable.Create(() => httpClient.Abort());
Expand All @@ -57,9 +58,15 @@ public IDisposable HttpDelete(string url, Dictionary<string, string> headers, Ac
headers.ForEach((k, v) => { request.SetRequestHeader(k, v); });
}

#if UNITY_2017_1_OR_NEWER
return request.SendWebRequest()
.AsAsyncOperationObservable()
.Subscribe(operation => { onResponse.Invoke(); });;
.Subscribe(operation => { onResponse.Invoke(); });
#else
return request.Send()
.AsAsyncOperationObservable()
.Subscribe(operation => { onResponse.Invoke(); });
#endif
}
}
}
Expand Down

0 comments on commit d5b4709

Please sign in to comment.