[unity] to solve the problem of error reporting in the custom rule tile menu script of 2D extras

2D extras is a very useful plug-in for tilemap officially made by unity. You can download it from GitHub

Like me, you may encounter an error in the custom rule tile menu script in the downloaded 2D extras package

According to the error prompt, the non-existent function is called. After searching, the corresponding function is indeed missing

Solution 1:

Just open the script and replace it with the following code

 1 namespace UnityEditor
 2 {
 3     static class CustomRuleTileMenu
 4     {
 5         [MenuItem("Assets/Create/Custom Rule Tile Script", false, 89)]
 6         static void CreateCustomRuleTile()
 7         {
 8             CreateScriptAsset("Assets/Tilemap/Rule Tiles/Scripts/ScriptTemplates/NewCustomRuleTile.cs.txt", "NewCustomRuleTile.cs");
 9         }
10 
11         static void CreateScriptAsset(string templatePath, string destName)
12         {
13             typeof(ProjectWindowUtil)
14                 .GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
15                 .Invoke(null, new object[] { templatePath, destName });
16         }
17     }
18 }

Solution 2:

Or, use the 2D techdemos version, which is officially provided for you to learn. In addition to the complete 2D extras, there are also some examples. According to my personal test, there is no problem with this version. It is just that there are too many sample materials and palettes, which will be a bit of an eyesore when you don’t need them

In fact, the code in solution 1 is the code of the custom rule tile menu script file in the 2D techdemo version

If you are interested, comparing the content of the custom rule tile menu scripts of 2D extras and 2D techdemos, it is not difficult to see that they realize the same function, but there are some differences in the implementation methods. What I do is equivalent to replacing parts

Similar Posts: