其實不算是unity的 就是c#中我想通過Nvelocity的這個模板引擎 生成一些我想要的變數
我可以傳List<string> xxx 或者 string 或者單一的一個匿名類 里面的一些資料都可以
但是我定義了一個類
public class BTNDEFINEANDFUNC
{
public string btnName;
public string btnFunc;
}
public List<BTNDEFINEANDFUNC> btnFunc = new List<BTNDEFINEANDFUNC>(); 當我把這個list傳過去 模板檔案的時候 就除了問題 大概就是反射找不到類別 這樣怎么處理
var nesss = new { name = mCurData.className, definename = mCurData.defineName , awakefunc = mCurData.awakeFunc, ss = mCurData.btnFunc, authorname = author , datatime = System.DateTime.Now, btnfuncc = mCurData.btnFunc };
context.Remove("datas");
context.Put("datas", nesss);
我也確定這邊我一定是傳過來引數了
另一邊模板檔案代碼
#foreach($btnf in $datas.btnfuncc)
void ${btnf.btnFunc}()
{
}
#end
這個是報錯的提示 有沒有什么方法解決 謝謝各位
InvalidCastException: Cannot cast from source type to destination type.
NVelocity.Runtime.Parser.Node.MapGetExecutor.Discover (System.Type clazz)
uj5u.com熱心網友回復:
額,Nvelocity沒用過的說,提示是說無法從源型別轉換為目標型別。這個我只能想解決思路,比如,先不在unity,先在.net的應用里,看看,程式對不對。
如果對的話,就是看是不是少了什么參考或者配置了。
uj5u.com熱心網友回復:
.Net 也同樣報錯,╮(╯▽╰)╭ 謝謝提供這個思路 很對轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/70370.html
標籤:Unity3D
上一篇:直面秋招!非科班生背水一戰,最終拿下阿里等大廠offer!
下一篇:NGUI某些功能在手機上無法使用
