Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Teach you to view and use Untiy internal libraries and methods

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Use Unity editor-related namespaces in VS and Mono, and then F12 can jump to specific editor namespace definitions, look up relevant fields, methods, and so on, and then use reflection technology to use internal private methods.

The general form is as follows:

1. # if UNITY_EDITOR

2. Using UnityEditor

3. Using UnityEditor.Sprites

4. Using System.Reflection

5. # endif

6. Using UnityEngine

7. Using System

8. Using System.Collections

9. Using UnityEngine.UI

10.

11. Using Object = UnityEngine.Object

twelve。

13. Public class NewBehaviourScript: MonoBehaviour

14. {

15. Void Start ()

16. {

17. # if UNITY_EDITOR

18. MethodInfo dynMethod = typeof (PackageInfo) .GetMethod ("GetPackageList", BindingFlags.NonPublic | BindingFlags.Static)

19. Object obj = dynMethod.Invoke (typeof (PackageInfo), null)

20.

21. PackageInfo [] packageInfos = obj as PackageInfo []

twenty-two。 Foreach (PackageInfo packageInfo in packageInfos)

23. {

24. Debug.Log ("- -")

25. Debug.Log (packageInfo.iconURL)

twenty-six。 Debug.Log (packageInfo.jsonInfo)

twenty-seven。 Debug.Log (packageInfo.packagePath)

twenty-eight。 }

twenty-nine。 # endif

thirty。 }

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report