Skip to content

Commit

Permalink
Merge pull request #176 from Geequlim/puerts-gloader-patch
Browse files Browse the repository at this point in the history
支持使用JS脚本实现GLoader
  • Loading branch information
xiaoguzhu authored Dec 31, 2021
2 parents 60bb11b + 475ff40 commit f5d6bd5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Assets/Scripts/UI/GLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class GLoader : GObject, IAnimationGear, IColorGear
GObject _errorSign;
GComponent _content2;

#if FAIRYGUI_PUERTS
public Action __loadExternal;
public Action<NTexture> __freeExternal;
#endif

public GLoader()
{
_url = string.Empty;
Expand Down Expand Up @@ -447,6 +452,12 @@ protected void LoadFromPackage(string itemURL)

virtual protected void LoadExternal()
{
#if FAIRYGUI_PUERTS
if (__loadExternal != null) {
__loadExternal();
return;
}
#endif
Texture2D tex = (Texture2D)Resources.Load(_url, typeof(Texture2D));
if (tex != null)
onExternalLoadSuccess(new NTexture(tex));
Expand All @@ -456,9 +467,15 @@ virtual protected void LoadExternal()

virtual protected void FreeExternal(NTexture texture)
{
#if FAIRYGUI_PUERTS
if (__freeExternal != null) {
__freeExternal(texture);
return;
}
#endif
}

protected void onExternalLoadSuccess(NTexture texture)
public void onExternalLoadSuccess(NTexture texture)
{
_content.texture = texture;
sourceWidth = texture.width;
Expand All @@ -469,7 +486,7 @@ protected void onExternalLoadSuccess(NTexture texture)
UpdateLayout();
}

protected void onExternalLoadFailed()
public void onExternalLoadFailed()
{
SetErrorState();
}
Expand Down

0 comments on commit f5d6bd5

Please sign in to comment.