yanghuan / csharpluaforunity Goto Github PK
View Code? Open in Web Editor NEWCSharp.lua的Unity适配,可将Unity工程中的C#代码编译至Lua
License: MIT License
CSharp.lua的Unity适配,可将Unity工程中的C#代码编译至Lua
License: MIT License
我的文件内容如下:
`using System.Collections.Generic;
public class MyElement
{
public int value1;
public int value2;
public bool value3;
public string value4;
public string value5;
public MyElement()
{
}
}
public class MyClass
{
public MyClass()
{
Init();
}
public void Init()
{
Dictionary<int, List<MyElement>> dic = new Dictionary<int, List<MyElement>>{
{1,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{2,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{3,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{4,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{5,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{6,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{7,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{8,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{9,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{10,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{11,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{12,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{13,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{14,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
},
{15,
new List<MyElement>()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}
}
};
}
}
`
报错信息如下:
SourceLocation(/Users/infosunny/Documents/TestCsharpLua/Assets/Compiled/MyClass.cs@142:17)"new List()
{
new MyElement()
{
value1 = 1,
value2 = 2,
value3 = true,
value4 = "A Dictionary<TKey,TValue> can support multiple readers concurrently",
value5 = "as long as the collection is not modified"
}
}": Your code is startling,17 temporary variables is not enough, please refactor your code.
希望升级ToluaFramework,以支持Android Arm64版本的编译
在C#中
IEnumerator ttt1()
{
yield return null;
yield return ttt2();
}
可以正常执行,但是转成lua后ttt2()不会执行。
必须写成
IEnumerator ttt1()
{
yield return null;
yield return StartCoroutine(ttt2());
}
的形式才可以
local function isUserdataType(obj, cls)
if cls.__gc ~= nil then
return isInstanceOfType(typeof(cls), obj)
end
return true
end
C#:
(byte[]) test
lua:
System.cast(ArrayByte, test)
报错信息:
Type:334: field or property interface does not exist
stack traceback:
NotSupportedException: UIHintPosition's field[posRect] type[UnityEngine.Vector2] not support serialized
CSharpLua.UserMonoBehaviourConverter.Convert (UnityEngine.MonoBehaviour monoBehaviour, LuaInterface.LuaTable luaClass, System.Reflection.FieldInfo field, CSharpLua.UserMonoBehaviourConverter+SerializeFieldsInfo info) (at Assets/CFPlugin/Runtime/UserMonoBehaviourConverter.cs:471)
T.c不存在
C#:
public class AAA
{
}
public class ZxyTest
{
public void Main()
{
AAA aaa;
Action action = (T t) =>
{
aaa = new AAA();
};
}
}
生成的lua编译不通过:
local System = System
System.namespace("", function (namespace)
namespace.class("AAA_1", function (namespace)
return function (T)
return {}
end
end)
end)
System.namespace("", function (namespace)
namespace.class("ZxyTest", function (namespace)
local Main
local AAA_1T = AAA_1(T)
Main = function (this, T)
local aaa
local action = function (t)
aaa = AAA_1T()
end
end
return {
Main = Main
}
end)
end)
list lst = new list();
lst.Count会被翻译成#lst
但是此时lst是bridge中new出来的,是userdata类型,不能使用#操作符
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.