此功能是因为我们代码使用的是dll,添加到Script Execution Order的代码为dll代码,设置后svn提交Player Settings文件夹下的文件。结果更新后没有这些更新到设置。后面查看了dll的meta文件。发现meta文件里有相关的设置。如下图:
dll的meta内容
猜测可能需要编辑dll,加入一些标识,所以就只能用工具手动加入这些类,调整调用顺序。
工具代码如下:
[ExecuteInEditMode]
[MenuItem("UnityTools/Script Execution Order")]
private static void SetScriptOrder()
{
Assembly asm = Assembly.Load(@"UnityEditor");
Type type = asm.GetType("UnityEditor.ScriptExecutionOrderInspector");
object obj = asm.CreateInstance("UnityEditor.ScriptExecutionOrderInspector");
MethodInfo oMethod = type.GetMethod("SetExecutionOrder", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
GameObject go = new GameObject();
SunFlareSystem.FlareSystem fs = go.AddComponent<SunFlareSystem.FlareSystem>();
MonoScript ms = MonoScript.FromMonoBehaviour(fs);
oMethod.Invoke(obj, new object[] { ms, 1200 });
GameObject.DestroyImmediate(go);
MethodInfo apply = type.GetMethod("Apply", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
apply.Invoke(obj, null);
EditorUtility.DisplayDialog("Script Execution Order", "添加成功", "确定");
}
网友评论