CS调用js脚本变量

来源:互联网 发布:会员制营销软件 编辑:程序博客网 时间:2024/04/30 01:37

using System.Reflection;// 反射      (需要加入头文件)


Offset = GetComponent("MainBoardTopJS");
FieldInfo OffsetXFieldInfo = Offset.GetType().GetField("OffsetX");
OffsetX = (float)OffsetXFieldInfo.GetValue(Offset);
----------或----------------------------------------------------
using System.Reflection;// 反射      (需要加入头文件)

Component X;
FieldInfo OffsetXFieldInfo;
X = GetComponent("ToAngleAxis");
OffsetXFieldInfo = X.GetType().GetField("rotationX");
rotationX = (float)OffsetXFieldInfo.GetValue(X);
----------------------------------------------------------------------

using System.Reflection;// 反射

Component Offset = GetComponent("MainBoardTopJS");
FieldInfo OffsetXFieldInfo = Offset.GetType().GetField("OffsetX");
OffsetX = (float)OffsetXFieldInfo.GetValue(Offset);