• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEditor.SerializedProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEditor.SerializedProperty的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty类的具体用法?C# SerializedProperty怎么用?C# SerializedProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SerializedProperty类属于UnityEditor命名空间,在下文中一共展示了SerializedProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty _property, GUIContent _label)
        {
            if (_property.isArray)
                return EditorGUI.GetPropertyHeight(_property);

            return EditorGUI.GetPropertyHeight(_property) + kButtonHeight + kOffset;
        }
开发者ID:ASchvartzman,项目名称:518Project-ASK,代码行数:7,代码来源:InspectorButtonDrawer.cs


示例12: CurveGui

	void CurveGui ( string name ,   SerializedProperty animationCurve ,   Color color  ){
		// @NOTE: EditorGUILayout.CurveField is buggy and flickers, using PropertyField for now
        //animationCurve.animationCurveValue = EditorGUILayout.CurveField (GUIContent (name), animationCurve.animationCurveValue, color, Rect (0.0f,0.0f,1.0f,1.0f));
		EditorGUILayout.PropertyField (animationCurve, new GUIContent (name));
		if (GUI.changed) 
			applyCurveChanges = true;
	}
开发者ID:lukehb,项目名称:rainy_night,代码行数:7,代码来源:ColorCorrectionCurvesEditor.cs


示例13: OnGUI

		public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) {
			string valueStr;
			switch (_property.propertyType) {
				case SerializedPropertyType.Integer:
					valueStr = _property.intValue.ToString();
					break;
				case SerializedPropertyType.Boolean:
					valueStr = _property.boolValue.ToString();
					break;
				case SerializedPropertyType.Float:
					valueStr = _property.floatValue.ToString("0.00000");
					break;
				case SerializedPropertyType.String:
					valueStr = _property.stringValue;
					break;
				case SerializedPropertyType.Enum:
					valueStr = _property.enumDisplayNames[_property.enumValueIndex];
					break;
				case SerializedPropertyType.Vector2:
					valueStr = _property.vector2Value.ToString();
					break;
				case SerializedPropertyType.Vector3:
					valueStr = _property.vector3Value.ToString();
					break;
				default:
					valueStr = "(not supported)";
					break;
			}

			EditorGUI.LabelField(_position, _label.text + ":", valueStr);
		}
开发者ID:cupsster,项目名称:DTCoreModule,代码行数:31,代码来源:ReadOnlyDrawer.cs


示例14: Initialize

    void Initialize(SerializedProperty property)
    {
        if (listedScenes != null && listedScenes.Length > 0)
            return;

        var scenes = EditorBuildSettings.scenes;
        var selectableScenes = new System.Collections.Generic.List<EditorBuildSettingsScene>();

        SceneSelectionAttribute attr = (SceneSelectionAttribute)attribute;

        for (int i = 0; i < scenes.Length; i++)
        {
            if (scenes[i].enabled || attr.allowDisabledScenes)
                selectableScenes.Add(scenes[i]);
        }
        listedScenes = new GUIContent[selectableScenes.Count];

        for (int i = 0; i < listedScenes.Length; i++)
        {
            var path = selectableScenes[i].path;
            int lastSeparator = path.LastIndexOf("/") + 1;
            var sceneName = path.Substring(lastSeparator, path.LastIndexOf(".") - lastSeparator);
            listedScenes[i] = new GUIContent(sceneName, selectableScenes[i].enabled ? "Enabled" : "Disabled");
            if (listedScenes[i].text.Equals(property.stringValue))
                selectedIndex = i;
        }
    }
开发者ID:LuciusSixPercent,项目名称:Finsternis,代码行数:27,代码来源:ScenesPopupDrawer.cs


示例15: OnGUI

		public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {


			SerializedProperty selection = prop.FindPropertyRelative("selection");
			SerializedProperty gameObject = prop.FindPropertyRelative("gameObject");

			CacheOwnerGameObject(prop.serializedObject);


			// draw the enum popup Field
			int oldEnumIndex = selection.enumValueIndex;

			EditorGUI.PropertyField(
				GetRectforRow(pos,0),
				selection,new GUIContent("Target"),true);

			if (oldEnumIndex !=selection.enumValueIndex)
			{
				if (selection.enumValueIndex==1)
				{
					gameObject.objectReferenceValue = ownerGameObject;
				}
			}

			if (selection.enumValueIndex==1)
			{
				EditorGUI.indentLevel++;

				EditorGUI.PropertyField(
					GetRectforRow(pos,1),
					gameObject,new GUIContent("Game Object"),true);
			}
	
		}
开发者ID:OmegaDEVAU,项目名称:Simulator,代码行数:34,代码来源:OwnerPropertyDrawer.cs


示例16: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                if (EditorGUI.PropertyField(position, property))
                {
                    EditorGUILayout.PropertyField(property.FindPropertyRelative("type"));

                    switch (property.FindPropertyRelative("type").enumValueIndex)
                    {
                        case 0: // None
                            break;
                        case 1: // Sphere
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 2: // Box
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("size"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 3: // Capsule
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("direction"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("height"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                    }
                }
            }
            EditorGUI.EndProperty();
        }
开发者ID:pencilking2002,项目名称:Tails-of-Fury-movement-prototype,代码行数:34,代码来源:ColliderSettingsDrawer.cs


示例17: OnGUI

        public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 
        {
            float value = 0f;
            if (property.propertyType == SerializedPropertyType.Float)
            {
                value = property.floatValue;
                isNumericValue = true;
            }
            else
            if (property.propertyType == SerializedPropertyType.Integer)
            {
                value = (float)property.intValue;
                isNumericValue = true;
            }
            else
            {
                isNumericValue = false;
            }

            if (isNumericValue)
            {
                ProgressBarAttribute barAttribute = (ProgressBarAttribute)attribute;
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.ProgressBar(position, (value / barAttribute.max), label.text);
                EditorGUI.EndProperty();
            }
            else
            {
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.PropertyField(position, property);
                EditorGUI.EndProperty();
            }
        }
开发者ID:NightHammer1000,项目名称:Lux,代码行数:33,代码来源:ProgressBarDrawer.cs


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VersionControl.Asset类代码示例发布时间:2022-05-26
下一篇:
C# UnityEditor.SerializedObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap