本文整理汇总了C#中UnityEditor.SerializedProperty类的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty类的具体用法?C# SerializedProperty怎么用?C# SerializedProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializedProperty类属于UnityEditor命名空间,在下文中一共展示了SerializedProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGUI
// Draw the property inside the given rect
public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
{
// Now draw the property as a Slider or an IntSlider based on whether it’s a float or integer.
if ( property.type != "MinMaxRange" )
Debug.LogWarning( "Use only with MinMaxRange type" );
else
{
var range = attribute as MinMaxRangeAttribute;
var minValue = property.FindPropertyRelative( "rangeStart" );
var maxValue = property.FindPropertyRelative( "rangeEnd" );
var newMin = minValue.floatValue;
var newMax = maxValue.floatValue;
var xDivision = position.width * 0.33f;
var yDivision = position.height * 0.5f;
EditorGUI.LabelField( new Rect( position.x, position.y, xDivision, yDivision ), label );
EditorGUI.LabelField( new Rect( position.x, position.y + yDivision, position.width, yDivision ), range.minLimit.ToString( "0.##" ) );
EditorGUI.LabelField( new Rect( position.x + position.width - 28f, position.y + yDivision, position.width, yDivision ), range.maxLimit.ToString( "0.##" ) );
EditorGUI.MinMaxSlider( new Rect( position.x + 24f, position.y + yDivision, position.width - 48f, yDivision ), ref newMin, ref newMax, range.minLimit, range.maxLimit );
EditorGUI.LabelField( new Rect( position.x + xDivision, position.y, xDivision, yDivision ), "From: " );
newMin = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision + 30, position.y, xDivision - 30, yDivision ), newMin ), range.minLimit, newMax );
EditorGUI.LabelField( new Rect( position.x + xDivision * 2f, position.y, xDivision, yDivision ), "To: " );
newMax = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision * 2f + 24, position.y, xDivision - 24, yDivision ), newMax ), newMin, range.maxLimit );
minValue.floatValue = newMin;
maxValue.floatValue = newMax;
}
}
示例2: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
rtpc = property.GetValue<AudioRTPC>();
Begin(position, property, label);
string rtpcName = string.Format("{4}{0} | {1} [{2}, {3}]", rtpc.Name, rtpc.Type, rtpc.MinValue, rtpc.MaxValue, rtpc.Scope == AudioRTPC.RTPCScope.Global ? "*" : "");
PropertyField(property, rtpcName.ToGUIContent(), false);
if (property.isExpanded)
{
EditorGUI.indentLevel++;
PropertyField(property.FindPropertyRelative("Scope"), GUIContent.none);
PropertyField(property.FindPropertyRelative("Name"));
PropertyField(property.FindPropertyRelative("Type"));
PropertyField(property.FindPropertyRelative("MinValue"));
PropertyField(property.FindPropertyRelative("MaxValue"));
PropertyField(property.FindPropertyRelative("Curve"));
EditorGUI.indentLevel--;
}
End();
}
示例3: construct
public static void construct(SerializedProperty prop){
prop.FindPropertyRelative("name").stringValue = "Animation Set Name";
SerializedProperty animations = prop.FindPropertyRelative ("animations");
animations.arraySize = 1;
AnimationDrawer.construct (animations.GetArrayElementAtIndex(0));
prop.serializedObject.ApplyModifiedProperties();
}
示例4: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = base.GetPropertyHeight(property, label);
CheckRequiredComponents(property.GetValue<EntityBehaviour>());
return height;
}
示例5: OnGUI
/// <summary>
/// Override this method to make your own GUI for the property
/// </summary>
/// <param name="position">Position</param>
/// <param name="prop">Property</param>
/// <param name="label">Label</param>
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
{
label = EditorGUI.BeginProperty(position, label, prop);
position.height = EditorGUIUtility.singleLineHeight;
Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
FindProperties(prop);
// Draw the preview texture
Rect textureRect = new Rect(contents);
textureRect.x += textureRect.width - PREVIEW_TEXTURE_SIZE;
textureRect.width = PREVIEW_TEXTURE_SIZE;
textureRect.height = PREVIEW_TEXTURE_SIZE;
EditorGUI.BeginChangeCheck();
HydraEditorUtils.DrawUnindented(
() => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true));
// Draw the fields
Rect contentRect = new Rect(contents);
contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f;
HydraEditorUtils.DrawUnindented(
() =>
HydraEditorUtils.EnumPopupField<Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp,
HydraEditorGUIStyles.enumStyle));
// Clear the cache if the texture changes
if (EditorGUI.EndChangeCheck())
m_WrappedTextureProp.objectReferenceValue = null;
EditorGUI.EndProperty();
}
示例6: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
MinMax minMax = attribute as MinMax;
if (property.propertyType != SerializedPropertyType.Vector2) {
EditorGUI.PropertyField(position, property);
Debug.LogWarning("The MinMax property can only be used on Vector2!");
return;
}
Vector2 value = property.vector2Value;
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
float w = position.width * PERCENT_NUM;
Rect leftNum = new Rect(position.x, position.y, w, position.height);
Rect slider = new Rect(position.x + w + SPACING, position.y, position.width - 2 * w - SPACING * 2, position.height);
Rect rightNum = new Rect(position.x + position.width - w, position.y, w, position.height);
float newMin = EditorGUI.FloatField(leftNum, value.x);
float newMax = EditorGUI.FloatField(rightNum, value.y);
value.x = Mathf.Clamp(newMin, minMax.min, value.y);
value.y = Mathf.Clamp(newMax, value.x, minMax.max);
EditorGUI.MinMaxSlider(slider, ref value.x, ref value.y, minMax.min, minMax.max);
property.vector2Value = value;
EditorGUI.EndProperty();
}
示例7: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
WritableAttribute attr = attribute as WritableAttribute;
GUI.enabled = attr.Result(DrawerUtil.GetTarget(property));
DrawerUtil.OnGUI(position, property, label);
GUI.enabled = true;
}
示例8: OnGUI
/// <summary>
/// Show the RequiredField inspector. Changes depending on the field being
/// empty or not.
/// </summary>
public override void OnGUI(Rect a_position, SerializedProperty a_property, GUIContent a_label)
{
// Split the widget position rectangle horizontally.
Rect bottom = new Rect();
Rect top = new Rect();
SplitRect(a_position, ref top, ref bottom);
// Save the default GUI color for later.
Color defaultColor = GUI.color;
// If the object pointed by the property is null, then show the error
// message, and set the GUI color to red to display the PropertyField in
// red.
if(a_property.objectReferenceValue == null) {
EditorGUI.HelpBox(top, "The field below is required and can't be empty.", MessageType.Error);
GUI.color = Color.red;
}
// Draw the default property field, this drawer does not alter the GUI.
if(a_property.objectReferenceValue == null) {
EditorGUI.PropertyField(bottom, a_property, a_label);
}
else {
EditorGUI.PropertyField(a_position, a_property, a_label);
}
// Restore the original colors.
GUI.color = defaultColor;
}
示例9: GetPropertyHeightSafe
internal float GetPropertyHeightSafe(SerializedProperty property, GUIContent label)
{
ScriptAttributeUtility.s_DrawerStack.Push(this);
float propertyHeight = this.GetPropertyHeight(property, label);
ScriptAttributeUtility.s_DrawerStack.Pop();
return propertyHeight;
}
示例10: Show
public static void Show(SerializedProperty list,
EditorListOption options = EditorListOption.Default)
{
if (!list.isArray) {
EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
return;
}
bool showListLabel = (options & EditorListOption.ListLabel) != 0;
bool showListSize = (options & EditorListOption.ListSize) != 0;
if (showListLabel) {
EditorGUILayout.PropertyField(list);
EditorGUI.indentLevel += 1;
}
if (!showListLabel || list.isExpanded) {
SerializedProperty size = list.FindPropertyRelative("Array.size");
if (showListSize) {
EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
}
if (size.hasMultipleDifferentValues) {
EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
} else {
ShowElements(list, options);
}
}
if (showListLabel) {
EditorGUI.indentLevel -= 1;
}
}
示例11: OnEnable
void OnEnable()
{
p_aoMode = serializedObject.FindProperty("Mode");
p_noiseTexture = serializedObject.FindProperty("NoiseTexture");
//p_maskTexture = serializedObject.FindProperty("MaskTexture");
#if UNITY_4_X
p_useHighPrecisionDepthMap = serializedObject.FindProperty("UseHighPrecisionDepthMap");
#endif
p_samples = serializedObject.FindProperty("Samples");
p_downsampling = serializedObject.FindProperty("Downsampling");
p_radius = serializedObject.FindProperty("Radius");
p_intensity = serializedObject.FindProperty("Intensity");
p_distance = serializedObject.FindProperty("Distance");
p_bias = serializedObject.FindProperty("Bias");
p_tag = serializedObject.FindProperty("Tag");
p_lumContribution = serializedObject.FindProperty("LumContribution");
p_occlusionColor = serializedObject.FindProperty("OcclusionColor");
p_cutoffDistance = serializedObject.FindProperty("CutoffDistance");
p_cutoffFalloff = serializedObject.FindProperty("CutoffFalloff");
p_blur = serializedObject.FindProperty("Blur");
p_blurDownsampling = serializedObject.FindProperty("BlurDownsampling");
p_blurPasses = serializedObject.FindProperty("BlurPasses");
p_blurBilateralThreshold = serializedObject.FindProperty("BlurBilateralThreshold");
p_debugAO = serializedObject.FindProperty("DebugAO");
}
示例12: OnEnable
void OnEnable () {
serObj = new SerializedObject (target);
screenBlendMode = serObj.FindProperty("screenBlendMode");
hdr = serObj.FindProperty("hdr");
sepBlurSpread = serObj.FindProperty("sepBlurSpread");
useSrcAlphaAsMask = serObj.FindProperty("useSrcAlphaAsMask");
bloomIntensity = serObj.FindProperty("bloomIntensity");
bloomthreshold = serObj.FindProperty("bloomThreshold");
bloomBlurIterations = serObj.FindProperty("bloomBlurIterations");
lensflares = serObj.FindProperty("lensflares");
lensflareMode = serObj.FindProperty("lensflareMode");
hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations");
hollyStretchWidth = serObj.FindProperty("hollyStretchWidth");
lensflareIntensity = serObj.FindProperty("lensflareIntensity");
lensflarethreshold = serObj.FindProperty("lensflareThreshold");
flareColorA = serObj.FindProperty("flareColorA");
flareColorB = serObj.FindProperty("flareColorB");
flareColorC = serObj.FindProperty("flareColorC");
flareColorD = serObj.FindProperty("flareColorD");
lensFlareVignetteMask = serObj.FindProperty("lensFlareVignetteMask");
tweakMode = serObj.FindProperty("tweakMode");
}
示例13: OnEnable
public void OnEnable()
{
this.m_UseColliderMask = this.serializedObject.FindProperty("m_UseColliderMask");
this.m_ColliderMask = this.serializedObject.FindProperty("m_ColliderMask");
this.m_ShowColliderMask.value = (this.target as Effector2D).useColliderMask;
this.m_ShowColliderMask.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
}
示例14: OnEnable
void OnEnable(){
point = (BezierPoint)target;
handleTypeProp = serializedObject.FindProperty("handleStyle");
handle1Prop = serializedObject.FindProperty("_handle1");
handle2Prop = serializedObject.FindProperty("_handle2");
}
示例15: OnEnable
void OnEnable()
{
serObj = new SerializedObject (target);
visualizeFocus = serObj.FindProperty ("visualizeFocus");
focalLength = serObj.FindProperty ("focalLength");
focalSize = serObj.FindProperty ("focalSize");
aperture = serObj.FindProperty ("aperture");
focalTransform = serObj.FindProperty ("focalTransform");
maxBlurSize = serObj.FindProperty ("maxBlurSize");
highResolution = serObj.FindProperty ("highResolution");
blurType = serObj.FindProperty ("blurType");
blurSampleCount = serObj.FindProperty ("blurSampleCount");
nearBlur = serObj.FindProperty ("nearBlur");
foregroundOverlap = serObj.FindProperty ("foregroundOverlap");
dx11BokehThreshold = serObj.FindProperty ("dx11BokehThreshold");
dx11SpawnHeuristic = serObj.FindProperty ("dx11SpawnHeuristic");
dx11BokehTexture = serObj.FindProperty ("dx11BokehTexture");
dx11BokehScale = serObj.FindProperty ("dx11BokehScale");
dx11BokehIntensity = serObj.FindProperty ("dx11BokehIntensity");
}