Skip to content

Commit b96a2bb

Browse files
committed
Fix the error when creating the defaultlua file when the plugin is located in the Assets directory
1 parent 9dec6c2 commit b96a2bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Editor/PreferencesGUI.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,19 @@ private static void CreateDefaultScript()
8181
}
8282
}
8383

84-
var srcfile = "Packages/com.litefeel.luainteractive/Editor/defaultlua.lua";
84+
var srcfile = GetDefultLuaFile();
8585
File.Copy(srcfile, path, true);
8686
}
87+
88+
/// <summary>
89+
/// 获得调用函数的类名和方法。
90+
/// </summary>
91+
/// <returns></returns>
92+
public static string GetDefultLuaFile()
93+
{
94+
var st = new System.Diagnostics.StackTrace(1, true).GetFrame(0);
95+
var dir = System.IO.Path.GetDirectoryName(st.GetFileName());
96+
return Path.Combine(dir, "defaultlua.lua");
97+
}
8798
}
8899
}

0 commit comments

Comments
 (0)