Unity game framework build 2019 (27) deprecated code warning solution

In the first two articles, we have organized all the examples from beginning to end.

The current status is as follows:

  1. Things to do:
    • (Complete) Backup: export the file and give it a reasonable name.
  2. Remaining problem:
    • (Complete) The eighth example repeats the code of the previous example with repeated functions.
    • (Done) There is a problem with the naming of the class where the method is located.
    • The order is displayed in the menu bar.
    • Deprecated code warning
  3. Conventions and rules:
    • Each example creates a folder under the QFramework directory, the format of the folder is: number. Function of the example
    • Each example writes a script that contains reusable static methods and MenuItem methods.
    • Every time you write an example to export, the date and time are appended to the exported file name. This function has been built into the export function.
    • Make a backup every time there is an API change, the name of the backup is in QFramework_vX.YZ format.
    • Every time you organize, make sure to delete and change the function when it is effective.
  4. Example classification:
    1. Knowledge learning & collection
      • API collection
      • C # Grammar Practice
    2. Functions of the library itself
      • Rule implementation
      • Use process provision and optimization
      • Increased efficiency (coding experience, logical reuse)
      • Project utility collection

Let's take a look at the remaining problems above. The example repeats this, and there is a menu bar showing the order problem, and there is a warning of the deprecated code.

It seems that the warning of the deprecated code will immediately come to mind, as long as the code is rewritten with the correct function.

Let's take a look at the editor's deprecated code warnings:
006tNc79gy1fzfr7gy35wj30mq0dmwgz.jpg
there are currently 5 warnings, mainly focused on Example 7 and the main. We solve them one by one.

First look at the code of Example 7:

using System.IO;

#if UNITY_EDITOR
using UnityEditor;
#endif

using UnityEngine;

namespace QFramework
{
	public class CustomShortCut : MonoBehaviour
	{
#if UNITY_EDITOR
		[MenuItem("QFramework/7.自定义快捷键 %e")]
		private static void MenuClicked()
		{
			var generatePackageName = PreviousFunctions.GenerateUnityPackageName();
			
			PreviousFunctions.ExportPackage("Assets/QFramework",generatePackageName + ".unitypackage");
			
			PreviousFunctions.OpenInFolder(Path.Combine(Application.dataPath, "../"));
		}
#endif
	}
}

It's easy to change. The modified code is as follows:

using System.IO;

#if UNITY_EDITOR
using UnityEditor;
#endif

using UnityEngine;

namespace QFramework
{
	public class CustomShortCut : MonoBehaviour
	{
#if UNITY_EDITOR
		[MenuItem("QFramework/7.自定义快捷键 %e")]
		private static void MenuClicked()
		{
			var generatePackageName = Exporter.GenerateUnityPackageName();
			
			EditorUtil.ExportPackage("Assets/QFramework",generatePackageName + ".unitypackage");
			
			EditorUtil.OpenInFolder(Path.Combine(Application.dataPath, "../"));
		}
#endif
	}
}

After the compilation, the results are as follows:
006tNc79gy1fzfr7jpozqj30mg0d240v.jpg
there are two left, let's look at the code of the eighth example.

...
public class PreviousFunctions
{
	...
	[MenuItem("QFramework/8.总结之前的方法/3.生成文件名到剪切板")]
	private static void MenuClicked3()
	{
		CommonUtil.CopyText(GenerateUnityPackageName());		
	}
		
	[MenuItem("QFramework/8.总结之前的方法/4.导出 UnityPackage")]
	private static void MenuClicked4()
	{
		EditorUtil.ExportPackage("Assets/QFramework",GenerateUnityPackageName() + ".unitypackage");
	}
	...
}
...

The main problem is GenerateUnityPackageName, which was forgotten when finishing the first example, just change to the following code.

...
public class PreviousFunctions
{
	...
	[MenuItem("QFramework/8.总结之前的方法/3.生成文件名到剪切板")]
	private static void MenuClicked3()
	{
		CommonUtil.CopyText(Exporter.GenerateUnityPackageName());		
	}
		
	[MenuItem("QFramework/8.总结之前的方法/4.导出 UnityPackage")]
	private static void MenuClicked4()
	{
		EditorUtil.ExportPackage("Assets/QFramework",Exporter.GenerateUnityPackageName() + ".unitypackage");
	}
	...
}
...

This way the compilation warning is gone.

The problem of the warning has been solved, and all the deprecated methods can be deleted, because the deprecated method will only report a warning as soon as it is called, but be careful when deleting the deprecated method, because the deprecated method It may be called in a certain macro. At this time, it is best to use the IDE's global search string. Generally, IDE will have it.

That's all for today, bye ~.

Please indicate the address of the reprint: Sandal notes: liangxiegame.com

more content

  • QFramework address: https://github.com/liangxiegame/QFramework

  • QQ communication group: 623597263

  • Unity Advanced Small Class :

    • Main training content:
      • Framework construction training (first year)
      • Follow the case study Shader (first year)
      • Incubation of sideline business (second and third years)
    • Please refer to the "Small Class Product Manual" for specific details such as rights and teaching methods : https://liangxiegame.com/master/intro
  • Pay attention to the public number: liangxiegame Get the latest update notification and more free content.

66 original articles published · Liked 153 · Visitors 50,000+

Guess you like

Origin blog.csdn.net/u010125551/article/details/105457338