[CustomPropertyDrawer(typeof(DisplayScriptableObjectPropertiesAttribute))]publicclassDisplayScriptableObjectPropertiesDrawer:PropertyDrawer{boolshowProperty=false;floatDrawerHeight=0;stringbutton="-";// Draw the property inside the given rectpublicoverridevoidOnGUI(Rectposition,SerializedPropertyproperty,GUIContentlabel)...
属性范围显示,跟Unity的Range一样,只是这个是对属性的,需要配合ShowInInspector显示出来 [ShowInInspector,PropertyRange(0,1)]publicfloatProgress{get;set;} 6.Wrap 值在指定范围内循环 [Wrap(0,10)]publicintScore; 数字在0-9之间循环 7.AssetList 资源列表,标记属性后点击右上角按钮可以快速选择和切换同类型资...
Only components that are common to all objects will be visible in the inspector. If any selected object has components that are not present on other objects, the inspector will show a message to say that some components are hidden. The context menu for a property (opened by right-clicking ...
[InspectorName("32 bits")] UInt32 = 2, } 1. 2. 3. 4. 5. 6. 7. 8. 9. 自定义标签 Header源代码 using System; namespace UnityEngine { /// /// <para>Use this PropertyAttribute to add a header above some fields in the Inspector.</para> /// [AttributeUsage(AttributeTargets.F...
起: 有一个System.Serializable的class,平时作为public成员,可以直接在Inspector上显示和编辑。 我有成员变量比如float类型时,需要当某个属性被打开时,才在编辑器上显示,则将其设置成[HideInInspector],再在Editor代码中使用if(xxx){PropertyField(...)}的形式就可以
如果将SerializedObject.FindProperty从OnEnable中改到OnInspectorGUI中,即: using UnityEngine; using System.Collections; using UnityEditor; using System.Collections.Generic; using UnityEngine.Assertions.Must; [CustomEditor(typeof(xxxControl))] public class xxxControlEditor : Editor ...
从上面的数据可以看出如下几点: 1.OnGUI 和 GetPropertyHeight 里的 property 参数是同一个参数。该参数里存放的是 Persion 里的属性信息。 2.OnGUI 和 GetPropertyHeight 里的 Label 参数也是同一个参数,该参数里存放的是 Persion 类的类名。 3.position参数指的是需要在Inspector面板中绘制的区域信息,可以从下...
如果将SerializedObject.FindProperty从OnEnable中改到OnInspectorGUI中,即: using UnityEngine; using System.Collections; using UnityEditor; using System.Collections.Generic; using UnityEngine.Assertions.Must; [CustomEditor(typeof(xxxControl))] public class xxxControlEditor : Editor ...
material = serializedObject.FindProperty("m_Material"); names = new string[6] { "Center", "ATK", "HP", "ASS", "REV", "CON" }; } bool showMaxProp = false, showPercent = true; public override void OnInspectorGUI() { serializedObject.Update (); ...
●ColorUsageAttribute 用于指定颜色字段的属性,以便在 Inspector 窗口中显示颜色拾取器,允许用户选择颜色。 ●ColorUsageAttribute 的参数有两个: ○Show Alpha: 这是一个布尔值,用于指定是否显示颜色拾取器中的 Alpha 透明度通道。如果设置为 true,则颜色拾取器将包括 Alpha 透明度通道,允许用户选择带有透明度的颜色。