提交 4246d344 编写于 作者: Z zhengxiaofeng

【Xlua框架】Lua和C#之间相互调用测试

上级 fba1615d
# #
# Sprite sheet data for Unity. # Sprite sheet data for Unity.
# #
# To import these sprites into your Unity project, download "TexturePackerImporter": # To import these sprites into your Unity project, download "TexturePackerImporter":
# http://www.codeandweb.com/texturepacker/unity # http://www.codeandweb.com/texturepacker/unity
# #
# $TexturePacker:SmartUpdate:aac6ee9e89d7bcdb6fa6ad6017429cb6:ec63ee5d604b67674563505d2aa44d61:e26c11978e44b0e8b1d7d7be5d5ab09a$ # $TexturePacker:SmartUpdate:aac6ee9e89d7bcdb6fa6ad6017429cb6:ec63ee5d604b67674563505d2aa44d61:e26c11978e44b0e8b1d7d7be5d5ab09a$
# #
:format=40300 :format=40300
:texture=AchieveUIAtlas.png :texture=AchieveUIAtlas.png
:size=2048x2048 :size=2048x2048
:pivotpoints=enabled :pivotpoints=enabled
:borders=disabled :borders=disabled
Achieve_UI_card_back1;95;1557;133;133; 0.5;0.5; 0;0;0;0 Achieve_UI_card_back1;95;1557;133;133; 0.5;0.5; 0;0;0;0
Achieve_UI_card_back2;95;1422;133;133; 0.5;0.5; 0;0;0;0 Achieve_UI_card_back2;95;1422;133;133; 0.5;0.5; 0;0;0;0
Achievement_img_3a;95;1830;145;217; 0.5;0.5; 0;0;0;0 Achievement_img_3a;95;1830;145;217; 0.5;0.5; 0;0;0;0
Achievement_img_3b;95;1300;120;120; 0.5;0.5; 0;0;0;0 Achievement_img_3b;95;1300;120;120; 0.5;0.5; 0;0;0;0
Achievement_img_7;1214;1320;727;727; 0.5;0.5; 0;0;0;0 Achievement_img_7;1214;1320;727;727; 0.5;0.5; 0;0;0;0
Achievement_ui_button1;260;1249;425;138; 0.5;0.5; 0;0;0;0 Achievement_ui_button1;260;1249;425;138; 0.5;0.5; 0;0;0;0
Achievement_ui_button2;1943;1688;59;59; 0.5;0.5; 0;0;0;0 Achievement_ui_button2;1943;1688;59;59; 0.5;0.5; 0;0;0;0
Achievement_ui_cj;95;528;349;385; 0.5;0.5; 0;0;0;0 Achievement_ui_cj;95;528;349;385; 0.5;0.5; 0;0;0;0
Achievement_ui_cj2;260;1389;522;137; 0.5;0.5; 0;0;0;0 Achievement_ui_cj2;260;1389;522;137; 0.5;0.5; 0;0;0;0
Achievement_ui_cj_button1;95;150;235;180; 0.5;0.5; 0;0;0;0 Achievement_ui_cj_button1;95;150;235;180; 0.5;0.5; 0;0;0;0
Achievement_ui_cj_button2;95;332;235;194; 0.5;0.5; 0;0;0;0 Achievement_ui_cj_button2;95;332;235;194; 0.5;0.5; 0;0;0;0
Achievement_ui_cj_gj1;86;26;172;29; 0.5;0.5; 0;0;0;0 Achievement_ui_cj_gj1;86;26;172;29; 0.5;0.5; 0;0;0;0
Achievement_ui_cj_gj2;687;1358;172;29; 0.5;0.5; 0;0;0;0 Achievement_ui_cj_gj2;687;1358;172;29; 0.5;0.5; 0;0;0;0
Achievement_ui_countries1;2004;1668;35;162; 0.5;0.5; 0;0;0;0 Achievement_ui_countries1;2004;1668;35;162; 0.5;0.5; 0;0;0;0
Achievement_ui_countries2;95;1010;115;288; 0.5;0.5; 0;0;0;0 Achievement_ui_countries2;95;1010;115;288; 0.5;0.5; 0;0;0;0
Achievement_ui_dark_bg;46;16;38;39; 0.5;0.5; 0;0;0;0 Achievement_ui_dark_bg;46;16;38;39; 0.5;0.5; 0;0;0;0
Achievement_ui_lin;242;1407;5;640; 0.5;0.5; 0;0;0;0 Achievement_ui_lin;242;1407;5;640; 0.5;0.5; 0;0;0;0
Achievement_ui_lock;1943;1749;59;81; 0.5;0.5; 0;0;0;0 Achievement_ui_lock;1943;1749;59;81; 0.5;0.5; 0;0;0;0
Achievement_ui_picture;260;1528;605;191; 0.5;0.5; 0;0;0;0 Achievement_ui_picture;260;1528;605;191; 0.5;0.5; 0;0;0;0
Achievement_ui_reward;687;1245;112;111; 0.5;0.5; 0;0;0;0 Achievement_ui_reward;687;1245;112;111; 0.5;0.5; 0;0;0;0
Achievement_ui_scroll2;1;1053;92;994; 0.5;0.5; 0;0;0;0 Achievement_ui_scroll2;1;1053;92;994; 0.5;0.5; 0;0;0;0
Achievement_ui_scroll3;1;57;92;994; 0.5;0.5; 0;0;0;0 Achievement_ui_scroll3;1;57;92;994; 0.5;0.5; 0;0;0;0
Achievement_ui_scroll4-1;1943;1832;81;130; 0.5;0.5; 0;0;0;0 Achievement_ui_scroll4-1;1943;1832;81;130; 0.5;0.5; 0;0;0;0
Achievement_ui_scroll4;260;1721;952;326; 0.5;0.5; 0;0;0;0 Achievement_ui_scroll4;260;1721;952;326; 0.5;0.5; 0;0;0;0
Achievement_ui_share;1;11;43;44; 0.5;0.5; 0;0;0;0 Achievement_ui_share;1;11;43;44; 0.5;0.5; 0;0;0;0
Achievement_ui_shihao1;95;1692;136;136; 0.5;0.5; 0;0;0;0 Achievement_ui_shihao1;95;1692;136;136; 0.5;0.5; 0;0;0;0
Achievement_ui_shihao2;1943;1964;97;83; 0.5;0.5; 0;0;0;0 Achievement_ui_shihao2;1943;1964;97;83; 0.5;0.5; 0;0;0;0
Achievement_ui_shihao3;95;915;107;93; 0.5;0.5; 0;0;0;0 Achievement_ui_shihao3;95;915;107;93; 0.5;0.5; 0;0;0;0
Achievement_ui_tgjl1;260;994;414;253; 0.5;0.5; 0;0;0;0 Achievement_ui_tgjl1;260;994;414;253; 0.5;0.5; 0;0;0;0
Achievement_ui_tgjl2;867;1574;286;145; 0.5;0.5; 0;0;0;0 Achievement_ui_tgjl2;867;1574;286;145; 0.5;0.5; 0;0;0;0
Achievement_ui_ww;867;1198;273;374; 0.5;0.5; 0;0;0;0 Achievement_ui_ww;867;1198;273;374; 0.5;0.5; 0;0;0;0
fileFormatVersion: 2
guid: 2f0d8566f81a39344b9e1abbf40d9701
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Shader "光照/漫反射_逐顶点光照"
{
Properties
{
_Diffuse("Diffuse",color) = (1,1,1,1)
}
SubShader
{
Pass
{
Tags {"LightMode" = "ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _Diffuse
struct a2v
{
float4 vertex : POSITION;
float3 normal : NORMAL;
}
struct v2f
{
float4 pos : SV_POSITION;
fixed3 color : COLOR;
}
v2f vert()
{
v2f o;
o.pos = mul(UNITY_MATRIX_M)
}
fixed4 frag(v2f f)
{
return fixed4(f.color,1.0)
}
ENDCG
}
}
FallBack "Diffuse"
}
\ No newline at end of file
fileFormatVersion: 2
guid: 2fc5537c632c4994aa9d7faeaeca8a68
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 607248d26123ade4f984187e93f5eea8 guid: 4c13d118ac45d8b4287caf0e6036c06b
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: d004b7c99f393844d8b16776e9350326 guid: 29e96dc8203e6c54fbbb8ae007077416
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
...@@ -27,9 +27,25 @@ function CSCallLuaFunc() ...@@ -27,9 +27,25 @@ function CSCallLuaFunc()
print("全局函数") print("全局函数")
end end
function LuaTest:LuaCallCSharp()
local StaticVariant = CS.Test.Test_LuaCallCSharp.CSharpString;
print("1. 调用C#内的静态变量 : "..StaticVariant)
CS.Test.Test_LuaCallCSharp:LuaCallCSharpTest()
print("3. 调用C#端公有方法")
local objectTest = CS.ZFramework.Core.AssetManager.Instance:GetGameObject("Prefab/Cube.prefab")
end
function LuaTest:LocalTest() function LuaTest:LocalTest()
print("公有函数") print("公有函数")
print("-------------------------------开始测试lua调用C#-----------------------------------")
LuaTest:LuaCallCSharp()
end end
return LuaTest return LuaTest
...@@ -207,7 +207,7 @@ namespace ZFramework.Core ...@@ -207,7 +207,7 @@ namespace ZFramework.Core
} }
} }
private void ProcessSubAssets(Object[] assets) public void ProcessSubAssets(Object[] assets)
{ {
_subAssetObjects = new Dictionary<string, Object>(); _subAssetObjects = new Dictionary<string, Object>();
if (assets[0] is SpriteAtlas) if (assets[0] is SpriteAtlas)
......
...@@ -8,6 +8,7 @@ namespace ZFramework.Core ...@@ -8,6 +8,7 @@ namespace ZFramework.Core
{ {
public class AssetRegistry public class AssetRegistry
{ {
public const string AssetRootPath = "Assets/AssetSources/AbResources";
public const string MetaFileName = "AssetBundleMeta.bin"; public const string MetaFileName = "AssetBundleMeta.bin";
private readonly Dictionary<string,string> _assetPathToBundleName = new Dictionary<string, string>(); private readonly Dictionary<string,string> _assetPathToBundleName = new Dictionary<string, string>();
...@@ -101,6 +102,7 @@ namespace ZFramework.Core ...@@ -101,6 +102,7 @@ namespace ZFramework.Core
public AssetData GetAssetAtPath(string path,bool withSubAssets = false) public AssetData GetAssetAtPath(string path,bool withSubAssets = false)
{ {
AssetData assetData = null; AssetData assetData = null;
#if ASSETBUNDLE_ENABLE
AssetBundleData bundleData = FindAssetBundle(path); //获取资源所在的AB数据 AssetBundleData bundleData = FindAssetBundle(path); //获取资源所在的AB数据
if (bundleData!= null) if (bundleData!= null)
{ {
...@@ -112,6 +114,33 @@ namespace ZFramework.Core ...@@ -112,6 +114,33 @@ namespace ZFramework.Core
bundleData.SetAsset(path,assetData); //把asset数据和bundle数据关联起来 bundleData.SetAsset(path,assetData); //把asset数据和bundle数据关联起来
} }
} }
#elif UNITY_EDITOR
if (withSubAssets)
{
UnityEngine.Object[] subAssets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath($"{AssetRootPath}/{path}");
if (subAssets != null && subAssets.Length > 0)
{
assetData = new AssetData(path);
assetData.ProcessSubAssets(subAssets);
}
else
{
Debug.LogError($"Can not load the asset '{path}'");
}
}
else
{
UnityEngine.Object obj = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Object>($"{AssetRootPath}/{path}");
if (obj != null)
{
assetData = new AssetData(path, null, obj);
}
else
{
Debug.LogError($"Can not load the asset '{path}'");
}
}
#endif
return assetData; return assetData;
} }
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;
namespace Test
{
[LuaCallCSharp]
public class Test_LuaCallCSharp
{
public static string CSharpString = "C#端测试string";
public static void LuaCallCSharpTest()
{
Debug.Log("2. 调用C#端静态函数");
}
}
}
fileFormatVersion: 2
guid: fe8a2ad273b76ca4584cf17a492a84de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7fd92acba61afb4448f6a0f7250878c7 guid: b6d93b40157c53648baf28d5d586aa4b
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册