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


C# SerializedProperty类代码示例

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


SerializedProperty类属于命名空间,在下文中一共展示了SerializedProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Header

        public static bool Header(string title, SerializedProperty group)
        {
            var rect = GUILayoutUtility.GetRect(16f, 22f, FxStyles.header);
            GUI.Box(rect, title, FxStyles.header);

            var display = group == null || group.isExpanded;

            var foldoutRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f);
            var e = Event.current;

            if (e.type == EventType.Repaint)
                FxStyles.headerFoldout.Draw(foldoutRect, false, false, display, false);

            if (e.type == EventType.MouseDown)
            {
                if (rect.Contains(e.mousePosition))
                {
                    display = !display;

                    if (group != null)
                        group.isExpanded = !group.isExpanded;

                    e.Use();
                }
            }

            return display;
        }
开发者ID:Cam582,项目名称:Top-Hats,代码行数:28,代码来源:EditorGUIHelper.cs

示例2: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var attribute = (GetSetAttribute)base.attribute;

            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(position, property, label);

            if (EditorGUI.EndChangeCheck())
            {
                attribute.dirty = true;
            }
            else if (attribute.dirty)
            {
                var parent = ReflectionUtils.GetParentObject(property.propertyPath, property.serializedObject.targetObject);

                var type = parent.GetType();
                var info = type.GetProperty(attribute.name);

                if (info == null)
                    Debug.LogError("Invalid property name \"" + attribute.name + "\"");
                else
                    info.SetValue(parent, fieldInfo.GetValue(parent), null);

                attribute.dirty = false;
            }
        }
开发者ID:Cam582,项目名称:Top-Hats,代码行数:26,代码来源:GetSetDrawer.cs

示例3: OnGUI

 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
   if (NavigationDrawer.s_Styles == null)
     NavigationDrawer.s_Styles = new NavigationDrawer.Styles();
   Rect position = pos;
   position.height = EditorGUIUtility.singleLineHeight;
   SerializedProperty propertyRelative1 = prop.FindPropertyRelative("m_Mode");
   Navigation.Mode navigationMode = NavigationDrawer.GetNavigationMode(propertyRelative1);
   EditorGUI.PropertyField(position, propertyRelative1, NavigationDrawer.s_Styles.navigationContent);
   ++EditorGUI.indentLevel;
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   if (navigationMode == Navigation.Mode.Explicit)
   {
     SerializedProperty propertyRelative2 = prop.FindPropertyRelative("m_SelectOnUp");
     SerializedProperty propertyRelative3 = prop.FindPropertyRelative("m_SelectOnDown");
     SerializedProperty propertyRelative4 = prop.FindPropertyRelative("m_SelectOnLeft");
     SerializedProperty propertyRelative5 = prop.FindPropertyRelative("m_SelectOnRight");
     EditorGUI.PropertyField(position, propertyRelative2);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative3);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative4);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative5);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   }
   --EditorGUI.indentLevel;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:28,代码来源:NavigationDrawer.cs

示例4: OnGUI

        public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
        {
            Rect position = rect;
            position.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty property = prop.FindPropertyRelative("m_NormalTrigger");
            SerializedProperty property2 = prop.FindPropertyRelative("m_HighlightedTrigger");
            SerializedProperty property3 = prop.FindPropertyRelative("m_PressedTrigger");
            SerializedProperty property4 = prop.FindPropertyRelative("m_ActiveTrigger");
            SerializedProperty property5 = prop.FindPropertyRelative("m_ActiveHighlightedTrigger");
            SerializedProperty property6 = prop.FindPropertyRelative("m_ActivePressedTrigger");
            SerializedProperty property7 = prop.FindPropertyRelative("m_DisabledTrigger");

            EditorGUI.PropertyField(position, property);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property2);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property3);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property4);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property5);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property6);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property7);
        }
开发者ID:DevDanSTL,项目名称:ggj2016,代码行数:26,代码来源:AnimationTriggersExtendedDrawer.cs

示例5: OnGUI

		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
			
			EditorGUI.PropertyField(position, property, label, includeChildren: true);

			var attribute = PropertyExtensions.GetAttribute<BeginGroupAttribute>(this);
			var otherProp = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, attribute.otherFieldName);

			var isNull = false;
			if (property.propertyType == SerializedPropertyType.ObjectReference) {

				isNull = (property.objectReferenceValue == null);

			}

			if (isNull == true && otherProp != null) {

				if (otherProp.propertyType == SerializedPropertyType.ObjectReference) {

					isNull = (otherProp.objectReferenceValue == null);

				}

			}

			++EditorGUI.indentLevel;
			EditorGUI.BeginDisabledGroup(isNull);

			CustomGUI.Splitter();

		}
开发者ID:Cyberbanan,项目名称:Unity3d.UI.Windows,代码行数:30,代码来源:BeginGroupAttribute.cs

示例6: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Init(property);
            m_FontFieldfHeight = EditorGUI.GetPropertyHeight(m_Font);
            m_FontStyleHeight   = EditorGUI.GetPropertyHeight(m_FontStyle);
            m_FontSizeHeight  = EditorGUI.GetPropertyHeight(m_FontSize);
            m_LineSpacingHeight  = EditorGUI.GetPropertyHeight(m_LineSpacing);
            m_EncodingHeight   = EditorGUI.GetPropertyHeight(m_SupportEncoding);
            m_ResizeTextForBestFitHeight = EditorGUI.GetPropertyHeight(m_ResizeTextForBestFit);
            m_ResizeTextMinSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMinSize);
            m_ResizeTextMaxSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMaxSize);
            m_HorizontalOverflowHeight = EditorGUI.GetPropertyHeight(m_HorizontalOverflow);
            m_VerticalOverflowHeight = EditorGUI.GetPropertyHeight(m_VerticalOverflow);

            var height = m_FontFieldfHeight
                + m_FontStyleHeight
                + m_FontSizeHeight
                + m_LineSpacingHeight
                + m_EncodingHeight
                + m_ResizeTextForBestFitHeight
                + m_HorizontalOverflowHeight
                + m_VerticalOverflowHeight
                + EditorGUIUtility.singleLineHeight * 3
                + EditorGUIUtility.standardVerticalSpacing * 10;

            if (m_ResizeTextForBestFit.boolValue)
            {
                height += m_ResizeTextMinSizeHeight
                    + m_ResizeTextMaxSizeHeight
                    + EditorGUIUtility.standardVerticalSpacing * 2;
            }
            return height;
        }
开发者ID:602147629,项目名称:Unity-ugui,代码行数:33,代码来源:FontDataDrawer.cs

示例7: EditorMode

            void EditorMode()
            {
                EditorGUILayout.LabelField("Built in fields", EditorStyles.boldLabel);
                EditorGUILayout.Separator();
                foreach (string name in System.Enum.GetNames(typeof(NetworkFields.SynchronizedField))) {
                    if (name.StartsWith("Userdef")) {
                        continue;
                    }
                    string propName;
                    SerializedProperty prop;
                    string baseName = System.Char.ToLowerInvariant(name[0]) + name.Substring(1);

                    propName = baseName + "Enabled";
                    prop = so.FindProperty(propName);

                    if (prop != null) {
                        prop.boolValue = EditorGUILayout.Toggle(prop.displayName.Replace("Enabled", ""), prop.boolValue);
                    }

                }

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("User defined fields", EditorStyles.boldLabel);
                EditorGUILayout.Separator();
                foreach (string name in System.Enum.GetNames(typeof(NetworkFields.SynchronizedField))) {

                    if (!name.StartsWith("Userdef")) {
                        continue;
                    }
                    string propName;
                    SerializedProperty prop;
                    string baseName = System.Char.ToLowerInvariant(name[0]) + name.Substring(1);

                    propName = baseName + "Enabled";
                    prop = so.FindProperty(propName);

                    if (prop != null) {
                        prop.boolValue = EditorGUILayout.Toggle(prop.displayName.Replace("Enabled", ""), prop.boolValue);
                    }

                    propName = baseName + "Type";
                    prop = so.FindProperty(propName);
                    string label = baseName;
                    //EditorGUILayout.LabelField(prop.displayName);

                    prop = so.FindProperty(propName);
                    if (prop != null) {
                        prop.enumValueIndex = EditorGUILayout.Popup("Type", prop.enumValueIndex, System.Enum.GetNames(typeof(NetworkFields.UserDefValue)));
                    }

                    string friendlyName = baseName + "Name";
                    prop = so.FindProperty(friendlyName);
                    if (prop != null) {
                        prop.stringValue = EditorGUILayout.TextField("Name", prop.stringValue);
                    }
                    EditorGUILayout.Separator();
                }
            }
开发者ID:tiger0-0,项目名称:gamemachine,代码行数:59,代码来源:GameEntityEditor.cs

示例8: LayoutElementField

 private void LayoutElementField(SerializedProperty property, float defaultValue)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: reference to a compiler-generated method
   this.LayoutElementField(property, new Func<RectTransform, float>(new LayoutElementEditor.\u003CLayoutElementField\u003Ec__AnonStorey2()
   {
     defaultValue = defaultValue
   }.\u003C\u003Em__7));
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:9,代码来源:LayoutElementEditor.cs

示例9: OnEnable

 protected override void OnEnable()
 {
   base.OnEnable();
   this.m_SpriteContent = new GUIContent("Source Image");
   this.m_SpriteTypeContent = new GUIContent("Image Type");
   this.m_ClockwiseContent = new GUIContent("Clockwise");
   this.m_Sprite = this.serializedObject.FindProperty("m_Sprite");
   this.m_Type = this.serializedObject.FindProperty("m_Type");
   this.m_FillCenter = this.serializedObject.FindProperty("m_FillCenter");
   this.m_FillMethod = this.serializedObject.FindProperty("m_FillMethod");
   this.m_FillOrigin = this.serializedObject.FindProperty("m_FillOrigin");
   this.m_FillClockwise = this.serializedObject.FindProperty("m_FillClockwise");
   this.m_FillAmount = this.serializedObject.FindProperty("m_FillAmount");
   this.m_PreserveAspect = this.serializedObject.FindProperty("m_PreserveAspect");
   this.m_ShowType = new AnimBool(this.m_Sprite.objectReferenceValue != (UnityEngine.Object) null);
   this.m_ShowType.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex;
   this.m_ShowSlicedOrTiled = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced);
   this.m_ShowSliced = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced);
   this.m_ShowFilled = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Filled);
   this.m_ShowSlicedOrTiled.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowSliced.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowFilled.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.SetShowNativeSize(true);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:25,代码来源:ImageEditor.cs

示例10: OnEnable

        protected override void OnEnable()
        {
            base.OnEnable();
            m_TextComponent = serializedObject.FindProperty("m_TextComponent");
            m_Text = serializedObject.FindProperty("m_Text");
            m_ContentType = serializedObject.FindProperty("m_ContentType");
            m_LineType = serializedObject.FindProperty("m_LineType");
            m_InputType = serializedObject.FindProperty("m_InputType");
            m_CharacterValidation = serializedObject.FindProperty("m_CharacterValidation");
            m_KeyboardType = serializedObject.FindProperty("m_KeyboardType");
            m_CharacterLimit = serializedObject.FindProperty("m_CharacterLimit");
            m_CaretBlinkRate = serializedObject.FindProperty("m_CaretBlinkRate");
            m_CaretWidth = serializedObject.FindProperty("m_CaretWidth");
            m_CaretColor = serializedObject.FindProperty("m_CaretColor");
            m_CustomCaretColor = serializedObject.FindProperty("m_CustomCaretColor");
            m_SelectionColor = serializedObject.FindProperty("m_SelectionColor");
            m_HideMobileInput = serializedObject.FindProperty("m_HideMobileInput");
            m_Placeholder = serializedObject.FindProperty("m_Placeholder");
            m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
            m_OnEndEdit = serializedObject.FindProperty("m_OnEndEdit");
            m_ReadOnly = serializedObject.FindProperty("m_ReadOnly");

            m_CustomColor = new AnimBool(m_CustomCaretColor.boolValue);
            m_CustomColor.valueChanged.AddListener(Repaint);
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:25,代码来源:InputFieldEditor.cs

示例11: OnEnable

        protected override void OnEnable()
        {
            base.OnEnable();

            m_SpriteContent = new GUIContent("Source Image");
            m_SpriteTypeContent     = new GUIContent("Image Type");
            m_ClockwiseContent      = new GUIContent("Clockwise");

            m_Sprite                = serializedObject.FindProperty("m_Sprite");
            m_Type                  = serializedObject.FindProperty("m_Type");
            m_FillCenter            = serializedObject.FindProperty("m_FillCenter");
            m_FillMethod            = serializedObject.FindProperty("m_FillMethod");
            m_FillOrigin            = serializedObject.FindProperty("m_FillOrigin");
            m_FillClockwise         = serializedObject.FindProperty("m_FillClockwise");
            m_FillAmount            = serializedObject.FindProperty("m_FillAmount");
            m_PreserveAspect        = serializedObject.FindProperty("m_PreserveAspect");

            m_ShowType = new AnimBool(m_Sprite.objectReferenceValue != null);
            m_ShowType.valueChanged.AddListener(Repaint);

            var typeEnum = (Image.Type)m_Type.enumValueIndex;

            m_ShowSlicedOrTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced);
            m_ShowSliced = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced);
            m_ShowFilled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled);
            m_ShowSlicedOrTiled.valueChanged.AddListener(Repaint);
            m_ShowSliced.valueChanged.AddListener(Repaint);
            m_ShowFilled.valueChanged.AddListener(Repaint);

            SetShowNativeSize(true);
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:31,代码来源:ImageEditor.cs

示例12: OnEnable

 protected virtual void OnEnable()
 {
   this.m_Script = this.serializedObject.FindProperty("m_Script");
   this.m_InteractableProperty = this.serializedObject.FindProperty("m_Interactable");
   this.m_TargetGraphicProperty = this.serializedObject.FindProperty("m_TargetGraphic");
   this.m_TransitionProperty = this.serializedObject.FindProperty("m_Transition");
   this.m_ColorBlockProperty = this.serializedObject.FindProperty("m_Colors");
   this.m_SpriteStateProperty = this.serializedObject.FindProperty("m_SpriteState");
   this.m_AnimTriggerProperty = this.serializedObject.FindProperty("m_AnimationTriggers");
   this.m_NavigationProperty = this.serializedObject.FindProperty("m_Navigation");
   this.m_PropertyPathToExcludeForChildClasses = new string[8]
   {
     this.m_Script.propertyPath,
     this.m_NavigationProperty.propertyPath,
     this.m_TransitionProperty.propertyPath,
     this.m_ColorBlockProperty.propertyPath,
     this.m_SpriteStateProperty.propertyPath,
     this.m_AnimTriggerProperty.propertyPath,
     this.m_InteractableProperty.propertyPath,
     this.m_TargetGraphicProperty.propertyPath
   };
   Selectable.Transition transition = SelectableEditor.GetTransition(this.m_TransitionProperty);
   this.m_ShowColorTint.value = transition == Selectable.Transition.ColorTint;
   this.m_ShowSpriteTrasition.value = transition == Selectable.Transition.SpriteSwap;
   this.m_ShowAnimTransition.value = transition == Selectable.Transition.Animation;
   this.m_ShowColorTint.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowSpriteTrasition.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   SelectableEditor.s_Editors.Add(this);
   this.RegisterStaticOnSceneGUI();
   SelectableEditor.s_ShowNavigation = EditorPrefs.GetBool(SelectableEditor.s_ShowNavigationKey);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:31,代码来源:SelectableEditor.cs

示例13: OnEnable

		protected override void OnEnable() {

			base.OnEnable();

			this.transition = this.serializedObject.FindProperty("m_Transition");
			this.transitionExtended = serializedObject.FindProperty("transitionExtended");
			
			extScaleBlockProperty = serializedObject.FindProperty("m_Scale");
			extAlphaBlockProperty = serializedObject.FindProperty("m_Alpha");
			extColorBlockProperty = serializedObject.FindProperty("m_Colors");
			extSpriteStateProperty = serializedObject.FindProperty("m_SpriteState");
			extAnimTriggerProperty = serializedObject.FindProperty("m_AnimationTriggers");
			extTargetGraphicProperty = serializedObject.FindProperty("m_TargetGraphic");

			var trans = GetTransition(this.transitionExtended);
			extShowScale.value = (trans & ButtonExtended.Transition.Scale) != 0;
			extShowAlpha.value = (trans & ButtonExtended.Transition.CanvasGroupAlpha) != 0;
			extShowColorTint.value = (trans & ButtonExtended.Transition.ColorTint) != 0;
			extShowSpriteTrasition.value = (trans & ButtonExtended.Transition.SpriteSwap) != 0;
			extShowAnimTransition.value = (trans & ButtonExtended.Transition.Animation) != 0;
			
			extShowScale.valueChanged.AddListener(Repaint);
			extShowAlpha.valueChanged.AddListener(Repaint);
			extShowColorTint.valueChanged.AddListener(Repaint);
			extShowSpriteTrasition.valueChanged.AddListener(Repaint);

		}
开发者ID:puckery,项目名称:Unity3d.UI.Windows,代码行数:27,代码来源:ButtonExtendedEditor.cs

示例14: OnEnable

 public override void OnEnable()
 {
     m_Colored = FindSetting((Settings x) => x.colored);
     m_Intensity = FindSetting((Settings x) => x.intensity);
     m_Size = FindSetting((Settings x) => x.size);
     m_LuminanceContribution = FindSetting((Settings x) => x.luminanceContribution);
 }
开发者ID:Cam582,项目名称:Top-Hats,代码行数:7,代码来源:GrainModelEditor.cs

示例15: OnEnable

 public override void OnEnable()
 {
     m_FocusDistance = FindSetting((Settings x) => x.focusDistance);
     m_Aperture = FindSetting((Settings x) => x.aperture);
     m_FocalLength = FindSetting((Settings x) => x.focalLength);
     m_UseCameraFov = FindSetting((Settings x) => x.useCameraFov);
     m_KernelSize = FindSetting((Settings x) => x.kernelSize);
 }
开发者ID:Cam582,项目名称:Top-Hats,代码行数:8,代码来源:DepthOfFieldModelEditor.cs


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