http://blog.csdn.net/u012085988/article/details/21620697

 

PreferenceIte顾名思义,它是在PreferenceWindow中添加Item。

如图:

(Editor)在Unity上自定义菜单 PreferenceItem

此图可以看出,PreferenceWindow中多了一个wmm选项。

 

下面看代码示例:

 

[csharp] view plaincopy
  1. using UnityEngine;  
  2. using System.Collections;  
  3. using UnityEditor;  
  4.   
  5. public class menutest : EditorWindow {  
  6.     [PreferenceItem("wmm")]  
  7.     static void wmmtest()  
  8.     {  
  9.         Debug.Log("this is preferenceItem");  
  10.     }  
  11. }  


很简单,只需要PreferenceItem关键字+item名字,然后后面跟一个static函数。当我们在PreferenceWindow中点击wmm项时,就会回调wmmtest函数。

 

但值得注意的是:由于此函数是用于绘制UI的,所以它不只调用一次。就像OnGUI一样,会被调用多次。

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2021-06-26
  • 2021-06-16
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2021-09-07
  • 2021-05-29
  • 2021-10-28
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案