当前位置: 首页>>代码示例>>C#>>正文


C# UnityEditor.SerializedProperty类代码示例

本文整理汇总了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;
        }
    }
开发者ID:tory37,项目名称:TorysUnityToolbox,代码行数:31,代码来源:MinMaxRangeDrawer.cs

示例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();
        }
开发者ID:Magicolo,项目名称:No-Love-No-Gain,代码行数:25,代码来源:AudioRTPCDrawer.cs

示例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();
	}
开发者ID:JBillingsley,项目名称:eecs-390-rts,代码行数:7,代码来源:AnimationsetDrawer.cs

示例4: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = base.GetPropertyHeight(property, label);
            CheckRequiredComponents(property.GetValue<EntityBehaviour>());

            return height;
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:7,代码来源:EntityBehaviourDrawer.cs

示例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();
		}
开发者ID:JustJessTV,项目名称:GitMergeTest,代码行数:40,代码来源:Texture2DDrawer.cs

示例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();
    }
开发者ID:imclab,项目名称:SpaceLeap,代码行数:34,代码来源:MinMaxPropertyDrawer.cs

示例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;

    }
开发者ID:toros11,项目名称:AbilitySystem,代码行数:7,代码来源:WritableAttributeDrawer.cs

示例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;
    }
开发者ID:Judepompom,项目名称:Unity-RequiredField,代码行数:33,代码来源:RequiredFieldPropertyDrawer.cs

示例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;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:PropertyDrawer.cs

示例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;
        }
    }
开发者ID:SethSR,项目名称:Mech-Game,代码行数:28,代码来源:EditorList.cs

示例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");
	}
开发者ID:illvisation,项目名称:cellVIEW_lite,代码行数:27,代码来源:SSAOProEditor.cs

示例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");
        }
开发者ID:CORTECHX,项目名称:Dopple,代码行数:28,代码来源:BloomAndFlaresEditor.cs

示例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));
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:Effector2DEditor.cs

示例14: OnEnable

	void OnEnable(){
		point = (BezierPoint)target;
		
		handleTypeProp = serializedObject.FindProperty("handleStyle");
		handle1Prop = serializedObject.FindProperty("_handle1");
		handle2Prop = serializedObject.FindProperty("_handle2");
	}	
开发者ID:ChemaLeon,项目名称:RitualCops,代码行数:7,代码来源:BezierPointEditor.cs

示例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");
        }
开发者ID:Nortrix0,项目名称:Beyond-Equilibrium,代码行数:25,代码来源:DepthOfFieldEditor.cs


注:本文中的UnityEditor.SerializedProperty类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。