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


C# SerializedProperty.GetValue方法代码示例

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


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

示例1: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            _audioOption = property.GetValue<AudioOption>();
            _dynamicValue = _audioOption.Value;
            _hasCurve = _audioOption.HasCurve();
            _typeProperty = property.FindPropertyRelative("_type");
            _delayProperty = property.FindPropertyRelative("_delay");

            UpdateProperties();

            InitializeValue(_typeProperty.GetValue<AudioOption.Types>());

            float height = 16f;

            if (property.isExpanded)
            {
                height += 38f + EditorGUI.GetPropertyHeight(_valueProperty, label, true);

                if (_timeProperty != null)
                    height += EditorGUI.GetPropertyHeight(_timeProperty) + 2f;
                if (_easeProperty != null)
                    height += EditorGUI.GetPropertyHeight(_easeProperty) + 2f;
            }

            return height;
        }
开发者ID:Magicolo,项目名称:No-Love-No-Gain,代码行数:28,代码来源:AudioOptionDrawer.cs

示例2: ToggleButton

		public void ToggleButton(SerializedProperty boolProperty, GUIContent trueLabel, GUIContent falseLabel) {
			Rect indentedPosition = EditorGUI.IndentedRect(currentPosition);
			boolProperty.SetValue(EditorGUI.Toggle(indentedPosition, boolProperty.GetValue<bool>(), new GUIStyle("button")));
			
			if (boolProperty.GetValue<bool>()) {
				Rect labelPosition = new Rect(indentedPosition.x + indentedPosition.width / 2 - trueLabel.text.GetWidth(EditorStyles.standardFont) / 2 - 16, indentedPosition.y, indentedPosition.width, indentedPosition.height);
				EditorGUI.LabelField(labelPosition, trueLabel);
			}
			else {
				Rect labelPosition = new Rect(indentedPosition.x + indentedPosition.width / 2 - falseLabel.text.GetWidth(EditorStyles.standardFont) / 2 - 16, indentedPosition.y, indentedPosition.width, indentedPosition.height);
				EditorGUI.LabelField(labelPosition, falseLabel);
			}
			
			currentPosition.y += currentPosition.height + 2;
		}
开发者ID:Kartoshka,项目名称:Crabby-Pulse-2,代码行数:15,代码来源:CustomPropertyDrawerBase.cs

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

示例4: OnGroupSelected

        void OnGroupSelected(FlagsOption option, SerializedProperty property)
        {
            var groups = property.GetValue<ByteFlag>();

            switch (option.Type)
            {
                case FlagsOption.OptionTypes.Everything:
                    foreach (var data in groupData)
                        groups |= data.Group;
                    break;
                case FlagsOption.OptionTypes.Nothing:
                    groups = ByteFlag.Nothing;
                    break;
                case FlagsOption.OptionTypes.Custom:
                    var group = ((GroupData)option.Value).Group;

                    if (option.IsSelected)
                        groups &= ~group;
                    else
                        groups |= group;
                    break;
            }

            for (int i = 1; i <= 8; i++)
            {
                var flagName = "f" + i;
                property.FindPropertyRelative(flagName).intValue = groups.GetValueFromMember<int>(flagName);
            }

            property.serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(property.serializedObject.targetObject);
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:32,代码来源:EntityGroupsDrawer.cs

示例5: ShowPolar3D

        void ShowPolar3D(SerializedProperty property)
        {
            var xProperty = property.FindPropertyRelative("x");
            var yProperty = property.FindPropertyRelative("y");
            var zProperty = property.FindPropertyRelative("z");
            var vector = property.GetValue<Vector3>().ToPolar().Round(0.0001f);
            currentPosition.width = currentPosition.width / 3f - 1f;

            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginProperty(currentPosition, xProperty.ToGUIContent(), xProperty);

            vector.x = EditorGUI.FloatField(currentPosition, "R", vector.x);
            currentPosition.x += currentPosition.width + 2f;

            EditorGUI.EndProperty();

            EditorGUI.BeginProperty(currentPosition, yProperty.ToGUIContent(), yProperty);

            vector.y = EditorGUI.FloatField(currentPosition, "ϴ", vector.y);
            currentPosition.x += currentPosition.width + 2f;

            EditorGUI.EndProperty();

            EditorGUI.BeginProperty(currentPosition, zProperty.ToGUIContent(), zProperty);

            vector.z = EditorGUI.FloatField(currentPosition, "Z", vector.z);

            EditorGUI.EndProperty();

            if (EditorGUI.EndChangeCheck())
                property.SetValue(vector.ToCartesian());
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:32,代码来源:PolarDrawer.cs

示例6: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;

            Begin(position, property, label);

            float min = ((SliderAttribute)attribute).min;
            float max = ((SliderAttribute)attribute).max;

            EditorGUI.BeginChangeCheck();

            currentPosition.height = 16;
            object value = property.GetValue();

            if (value is int) {
                property.SetValue(EditorGUI.IntSlider(currentPosition, label, (int)value, (int)min, (int)max));
            }
            else if (value is float) {
                property.SetValue(EditorGUI.Slider(currentPosition, label, (float)value, min, max));
            }
            else if (value is double) {
                property.SetValue(EditorGUI.Slider(currentPosition, label, (float)(double)value, min, max));
            }
            else {
                EditorGUI.HelpBox(currentPosition, "The type of the field must be numerical.", MessageType.Error);
            }

            if (EditorGUI.EndChangeCheck()) {
                property.Clamp(min, max);
            }

            End();
        }
开发者ID:Dracir,项目名称:Final-bablititi,代码行数:33,代码来源:SliderDrawer.cs

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

示例8: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;

            Begin(position, property, label);

            string arrayName = ((PopupAttribute)attribute).arrayName;
            string onChangeCallback = ((PopupAttribute)attribute).onChangeCallback;
            SerializedProperty array = property.serializedObject.FindProperty(arrayName);
            int selectedIndex = 0;

            List<string> displayedOptions = new List<string>();
            if (array != null && property.GetValue() != null) {
                for (int i = 0; i < array.arraySize; i++) {
                    object value = array.GetArrayElementAtIndex(i).GetValue();

                    if (property.GetValue().Equals(value)) {
                        selectedIndex = i;
                    }

                    if (value != null) {
                        if (value as Object != null) {
                            displayedOptions.Add(string.Format("{0} [{1}]", value.GetType().Name, i));
                        }
                        else {
                            displayedOptions.Add(string.Format("{0}", value));
                        }
                    }
                    else {
                        displayedOptions.Add(" ");
                    }
                }
            }

            EditorGUI.BeginChangeCheck();
            selectedIndex = Mathf.Clamp(EditorGUI.Popup(_currentPosition, label, selectedIndex, displayedOptions.ToGUIContents()), 0, array.arraySize - 1);

            if (array != null && array.arraySize != 0 && array.arraySize > selectedIndex) {
                property.SetValue(array.GetArrayElementAtIndex(selectedIndex).GetValue());
            }

            if (EditorGUI.EndChangeCheck()) {
                if (!string.IsNullOrEmpty(onChangeCallback)) ((MonoBehaviour)property.serializedObject.targetObject).Invoke(onChangeCallback, 0);
            }

            End();
        }
开发者ID:Magicolo,项目名称:No-Love-No-Gain,代码行数:47,代码来源:PopupDrawer.cs

示例9: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            reference = property.GetValue<IPropertyReference>();

            return property.isExpanded ? (lineHeight + 2f) * 3f : lineHeight + 2f;
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:8,代码来源:PropertyReferenceDrawer.cs

示例10: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            messageEnum = property.GetValue<MessageEnum>();

            return lineHeight;
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:8,代码来源:MessageEnumDrawer.cs

示例11: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;

            Begin(position, property, label);

            property.SetValue(EditorGUI.LayerField(currentPosition, label, property.GetValue<int>()));

            End();
        }
开发者ID:Dracir,项目名称:Final-bablititi,代码行数:10,代码来源:LayerDrawer.cs

示例12: CleanUpLayers

 void CleanUpLayers(SerializedProperty layersProperty)
 {
     if (!Application.isPlaying && machine != null) {
         for (int i = layersProperty.arraySize - 1; i >= 0; i--) {
             if (layersProperty.GetValue<UnityEngine.Object>(i) == null) {
                 DeleteFromArray(layersProperty, i);
             }
         }
     }
 }
开发者ID:Dracir,项目名称:Final-bablititi,代码行数:10,代码来源:StateMachineEditor.cs

示例13: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Begin(position, property, label);

            currentPosition = EditorGUI.PrefixLabel(currentPosition, label);
            currentPosition.x -= 1f;

            BeginIndent(0);
            BeginLabelWidth(27f);

            if (isEditingMin && !EditorGUIUtility.editingTextField)
            {
                property.SetValue("max", Mathf.Max(property.GetValue<float>("max"), property.GetValue<float>("min")));
                isEditingMin = false;
            }
            else if (isEditingMax && !EditorGUIUtility.editingTextField)
            {
                property.SetValue("min", Mathf.Min(property.GetValue<float>("min"), property.GetValue<float>("max")));
                isEditingMax = false;
            }

            EditorGUI.BeginChangeCheck();

            currentPosition.width = currentPosition.width / 2f;
            EditorGUI.PropertyField(currentPosition, property.FindPropertyRelative("min"));

            if (EditorGUI.EndChangeCheck())
            {
                if (EditorGUIUtility.editingTextField)
                    isEditingMin = true;
                else
                    property.SetValue("max", Mathf.Max(property.GetValue<float>("max"), property.GetValue<float>("min")));
            }

            EditorGUI.BeginChangeCheck();

            currentPosition.x += currentPosition.width + 1f;
            EditorGUI.PropertyField(currentPosition, property.FindPropertyRelative("max"));

            if (EditorGUI.EndChangeCheck())
            {
                if (EditorGUIUtility.editingTextField)
                    isEditingMax = true;
                else
                    property.SetValue("min", Mathf.Min(property.GetValue<float>("min"), property.GetValue<float>("max")));
            }

            EndLabelWidth();
            EndIndent();

            End();
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:52,代码来源:MinMaxDrawer.cs

示例14: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            pExpression = property.GetValue<PExpression>();
            textProperty = property.FindPropertyRelative("Text");
            int lineCount = textProperty.stringValue.Count(c => c == '\n' || c == '\r') + 1;
            height = Mathf.Max(lineCount * (lineHeight - 3f) + 4f, lineHeight);

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

示例15: GetPropertyHeight

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            enumValue = property.GetValue<IEnum>();
            enumValues = enumValue.GetValues();
            enumNames = enumValue.GetNames().Convert(name => name.Replace('_', '/'));
            isFlag = enumValue is IEnumFlag;

            return 16f;
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:11,代码来源:PEnumDrawer.cs


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