Skip to content

Commit f5d6bd5

Browse files
authored
Merge pull request #176 from Geequlim/puerts-gloader-patch
支持使用JS脚本实现GLoader
2 parents 60bb11b + 475ff40 commit f5d6bd5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Assets/Scripts/UI/GLoader.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public class GLoader : GObject, IAnimationGear, IColorGear
2929
GObject _errorSign;
3030
GComponent _content2;
3131

32+
#if FAIRYGUI_PUERTS
33+
public Action __loadExternal;
34+
public Action<NTexture> __freeExternal;
35+
#endif
36+
3237
public GLoader()
3338
{
3439
_url = string.Empty;
@@ -447,6 +452,12 @@ protected void LoadFromPackage(string itemURL)
447452

448453
virtual protected void LoadExternal()
449454
{
455+
#if FAIRYGUI_PUERTS
456+
if (__loadExternal != null) {
457+
__loadExternal();
458+
return;
459+
}
460+
#endif
450461
Texture2D tex = (Texture2D)Resources.Load(_url, typeof(Texture2D));
451462
if (tex != null)
452463
onExternalLoadSuccess(new NTexture(tex));
@@ -456,9 +467,15 @@ virtual protected void LoadExternal()
456467

457468
virtual protected void FreeExternal(NTexture texture)
458469
{
470+
#if FAIRYGUI_PUERTS
471+
if (__freeExternal != null) {
472+
__freeExternal(texture);
473+
return;
474+
}
475+
#endif
459476
}
460477

461-
protected void onExternalLoadSuccess(NTexture texture)
478+
public void onExternalLoadSuccess(NTexture texture)
462479
{
463480
_content.texture = texture;
464481
sourceWidth = texture.width;
@@ -469,7 +486,7 @@ protected void onExternalLoadSuccess(NTexture texture)
469486
UpdateLayout();
470487
}
471488

472-
protected void onExternalLoadFailed()
489+
public void onExternalLoadFailed()
473490
{
474491
SetErrorState();
475492
}

0 commit comments

Comments
 (0)