Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit baacdb6

Browse files
author
pengqihe
committed
完善资源加载逻辑
1 parent 255d276 commit baacdb6

File tree

78 files changed

+222
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+222
-45
lines changed

‎Assets/FLuaUI.unitypackage‎

23.5 MB
Binary file not shown.

‎Assets/FLuaUI.unitypackage.meta‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/FLuaUI/LuaUI/UIExtends/LuaImage.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static int SetImageExtend(IntPtr L)
3636
// 通过路径加载
3737
var path = LuaDLL.lua_tostring(L, -1);
3838
tb = ToLua.ToVarObject(L, -2) as LuaTable;
39-
LoaderManager.LoadImage(tb, path);
39+
LoaderManager.LoadImage(tb, path);
4040
break;
4141
case 3:
4242
// 通过图集加载

‎Assets/FLuaUI/MainGame.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using Babeltime.Log;
66
using FLuaUI.core;
7+
using FLuaUI.core.loader;
78
using FLuaUI.LuaUI.UIExtends;
89

910
namespace FLuaUI
@@ -34,6 +35,7 @@ public static MainGame Ins
3435
// private GameObject uiBackstage;
3536
private void Awake()
3637
{
38+
InitBundleAPI();
3739
var t = Time.realtimeSinceStartup;
3840
BTLog.Error("start:{0}", t);
3941
if (ins == null)
@@ -58,6 +60,15 @@ private void Awake()
5860
#endif
5961
}
6062

63+
private void InitBundleAPI()
64+
{
65+
#if UNITY_EDITOR && USE_BUNDLE
66+
LoaderManager.AssetsAPI = new EditorAssetsAPI();
67+
#else
68+
LoaderManager.AssetsAPI = new AssetsAssetApi();
69+
#endif
70+
71+
}
6172
protected virtual void OpenLibs()
6273
{
6374
luaState.OpenLibs(LuaDLL.luaopen_pb);

‎Assets/FLuaUI/core/LoaderManager.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace FLuaUI.core
66
{
77
public class LoaderManager
88
{
9+
public static IAssetsAPI AssetsAPI;
910
private static List<BaseLoader> loaderContexts = new List<BaseLoader>();
1011
public static void LoadPrefab(LuaTable lt)
1112
{

‎Assets/FLuaUI/core/loader/AtlasImgLoader.cs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ public AtlasImgLoader(LuaTable lt, string atlas, string name):base(lt)
1818

1919
public override void Load()
2020
{
21-
#if UNITY_EDITOR
22-
var texs = AssetDatabase.LoadAllAssetsAtPath(atlas);
23-
#else
24-
var texs = Resources.LoadAll<Sprite>(atlas);
25-
#endif
26-
21+
var texs = LoaderManager.AssetsAPI.LoadAtlas(atlas);
2722
if (texs == null)
2823
{
2924
BTLog.Error("can not find atlas:{0}", atlas);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using UnityEngine;
2+
3+
namespace FLuaUI.core.loader
4+
{
5+
public class AssetsAssetApi:IAssetsAPI
6+
{
7+
public Sprite LoadSprite(string path)
8+
{
9+
throw new System.NotImplementedException();
10+
}
11+
12+
public GameObject LoadPrefab(string path)
13+
{
14+
throw new System.NotImplementedException();
15+
}
16+
17+
public Object[] LoadAtlas(string atlas)
18+
{
19+
throw new System.NotImplementedException();
20+
}
21+
}
22+
}

‎Assets/FLuaUI/core/loader/BundleAssetsApi.cs.meta‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace FLuaUI.core.loader
5+
{
6+
public class EditorAssetsAPI:IAssetsAPI
7+
{
8+
public Sprite LoadSprite(string path)
9+
{
10+
return AssetDatabase.LoadAssetAtPath<Sprite>(path);
11+
}
12+
13+
public GameObject LoadPrefab(string path)
14+
{
15+
return AssetDatabase.LoadAssetAtPath<GameObject>(path);
16+
}
17+
18+
public Object[] LoadAtlas(string atlas)
19+
{
20+
return AssetDatabase.LoadAllAssetsAtPath(atlas);
21+
}
22+
}
23+
}

‎Assets/FLuaUI/core/loader/EditorAssetsAPI.cs.meta‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /