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


C# SerializedProperty.FindPropertyRelative方法代码示例

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


在下文中一共展示了SerializedProperty.FindPropertyRelative方法的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: 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

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

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        SerializedProperty direction = property.FindPropertyRelative ("direction");
        SerializedProperty accuracy = property.FindPropertyRelative ("accuracy");
        EditorGUI.BeginProperty (position, label, property);
        Rect contentPosition = EditorGUI.PrefixLabel (position, label);
        int indent = EditorGUI.indentLevel;
        EditorGUI.indentLevel = 0;

        float fullWidth = contentPosition.width;

        contentPosition.width = fullWidth * 0.2f;
        float x = contentPosition.x;

        contentPosition.x = x;
        EditorGUIUtility.labelWidth = 20f;
        EditorGUI.PropertyField (contentPosition, direction, new GUIContent ("Dir"));

        x += contentPosition.width;
        contentPosition.width = fullWidth * .4f;
        contentPosition.x = x;
        EditorGUIUtility.labelWidth = 50f;
        EditorGUI.PropertyField (contentPosition, accuracy);

        EditorGUI.indentLevel = indent;
        EditorGUI.EndProperty ();
    }
开发者ID:spencerHarrill,项目名称:UnityThirdPersonTut,代码行数:27,代码来源:AttackInputDrawer.cs

示例5: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float offset = 0f;
            if (!string.IsNullOrEmpty(label.text))
            {
                EditorGUI.LabelField(position, label);
                offset = 18f;
            }

            EditorGUI.BeginProperty(position, GUIContent.none, property);

            position.y += offset;
            EditorGUI.indentLevel++;

            var slopeRect = new Rect(position.x, position.y, position.width, 16f);
            var scaleRect = new Rect(position.x, position.y + 18f, position.width, 16f);
            var dropRect = new Rect(position.x, position.y + 36f, position.width, 16f);

            EditorGUI.PropertyField(slopeRect, property.FindPropertyRelative("maxSlopeAngle"), new GUIContent("Max Slope Angle", "The maximum angle at which a unit can walk."));
            EditorGUI.PropertyField(scaleRect, property.FindPropertyRelative("maxClimbHeight"), new GUIContent("Max Climb Height", "The maximum height that the unit can scale, i.e. walk onto even if it is a vertical move. Stairs for instance."));
            EditorGUI.PropertyField(dropRect, property.FindPropertyRelative("maxDropHeight"), new GUIContent("Max Drop Height", "The maximum height from which a unit can drop down to the ground below."));

            EditorGUI.indentLevel--;
            EditorGUI.EndProperty();
        }
开发者ID:forwolk,项目名称:UnityApex,代码行数:25,代码来源:HeightNavigationCapabilitiesPropertyDrawer.cs

示例6: DrawRangeField

 private void DrawRangeField(Rect position, float labelWidth, float textFieldWidth, SerializedProperty prop, bool floatingPoint)
 {
     position.width = labelWidth;
     EditorGUI.LabelField(position, new GUIContent("Min", "Minimum value"));
     position.x += labelWidth;
     position.width = textFieldWidth;
     if (floatingPoint)
     {
         DrawFloatTextField(position, prop.FindPropertyRelative("Minimum"));
     }
     else
     {
         DrawIntTextField(position, prop.FindPropertyRelative("Minimum"));
     }
     position.x += textFieldWidth;
     position.width = labelWidth;
     EditorGUI.LabelField(position, new GUIContent("Max", "Maximum value"));
     position.x += labelWidth;
     position.width = textFieldWidth;
     if (floatingPoint)
     {
         DrawFloatTextField(position, prop.FindPropertyRelative("Maximum"));
     }
     else
     {
         DrawIntTextField(position, prop.FindPropertyRelative("Maximum"));
     }
 }
开发者ID:OAMKPelienOhjelmointi2016,项目名称:DescentRemake,代码行数:28,代码来源:SingleLineAttribute.cs

示例7: GetPropertyHeight

    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        var propText = property.FindPropertyRelative("text");
        var propTurnHead = property.FindPropertyRelative("turnHead");

        return EditorGUI.GetPropertyHeight(propText) + EditorGUI.GetPropertyHeight(propTurnHead);
    }
开发者ID:Turnary-Games,项目名称:Battery-Golem,代码行数:7,代码来源:_Dialog_Message.cs

示例8: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty (position, label, property);

        // Draw label
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        // Get properties
        var clipProp = property.FindPropertyRelative("clip");
        var volumeProp = property.FindPropertyRelative("volume");
        var vLabelContent = new GUIContent("Volume");

        // Calc rects
        var clipRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

        var volumeRect = new Rect(position.x, position.y + clipRect.height, position.width, EditorGUIUtility.singleLineHeight);
        var vLabelRect = new Rect(volumeRect.x, volumeRect.y, 50, volumeRect.height);
        var vSliderRect = new Rect(volumeRect.x + vLabelRect.width, volumeRect.y, volumeRect.width - vLabelRect.width, volumeRect.height);

        // Create labels
        var clipLabel = new GUIContent("clip");
        var volumeLabel = new GUIContent("volume");

        // Draw fields
        EditorGUI.BeginProperty(clipRect, clipLabel, clipProp);
            EditorGUI.PropertyField(clipRect, clipProp, GUIContent.none);
        EditorGUI.EndProperty();
        EditorGUI.BeginProperty(volumeRect, volumeLabel, volumeProp);
            EditorGUI.LabelField(vLabelRect, vLabelContent);
            EditorGUI.PropertyField(vSliderRect, volumeProp, GUIContent.none);
        EditorGUI.EndProperty();

        EditorGUI.EndProperty();
    }
开发者ID:jilleJr,项目名称:Akira-Moto,代码行数:34,代码来源:_SoundEffectsHelper_Sound.cs

示例9: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            const int indentWidth = 16;
            var lineHeight = EditorGUIUtility.singleLineHeight;
            var lineSpace = EditorGUIUtility.standardVerticalSpacing;

            // these controls have single line height
            position.height = lineHeight;

            // interpolation type
            var type = property.FindPropertyRelative("_interpolationType");
            EditorGUI.PropertyField(position, type, label);

            if (CheckShouldExpand(property))
            {
                // indent the line
                position.width -= indentWidth;
                position.x += indentWidth;
                EditorGUIUtility.labelWidth -= indentWidth;

                // go to the next line
                position.y += lineHeight + lineSpace;

                // interpolation speed
                var speed = property.FindPropertyRelative("_interpolationSpeed");
                EditorGUI.PropertyField(position, speed, _textSpeed);
            }

            EditorGUI.EndProperty();
        }
开发者ID:magadan,项目名称:Klak,代码行数:32,代码来源:InterpolatorConfigDrawer.cs

示例10: OnGUI

	public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {
		SerializedProperty context = prop.FindPropertyRelative ("context");
		SerializedProperty index = prop.FindPropertyRelative ("index");

		float p = TileRenderDrawer.previewSize((TileContext)context.enumValueIndex);
		float h = Mathf.Max (p + EditorUtil.padding, 2 * EditorUtil.row + 3);
		float w = pos.width;

		GUI.Box(new Rect (pos.x + 25, pos.y, w - 25, h), GUIContent.none);

		//
		EditorGUIUtility.labelWidth = 100;

		EditorGUI.BeginChangeCheck();

		EditorGUI.PropertyField (new Rect (pos.x, pos.y + h/2 - EditorUtil.row + 2, w - p - EditorUtil.padding, EditorUtil.height), context, new GUIContent("Context"));
		EditorGUI.PropertyField (new Rect (pos.x, pos.y + h/2 + 2, w - p - EditorUtil.padding, EditorUtil.height), index, new GUIContent("Index"));

		if (EditorGUI.EndChangeCheck ()) {
			prop.FindPropertyRelative("view").objectReferenceValue = TileRenderDrawer.constructPreview(prop);
		}

		Rect r = new Rect (pos.x + pos.width - p - 4, pos.y + 4 + (h - p - EditorUtil.padding)/2, p, p);
		Texture2D tex = (Texture2D)prop.FindPropertyRelative("view").objectReferenceValue;
		GUI.Box(r, tex == null? new GUIContent("Error"):new GUIContent(tex));
		
		EditorGUIUtility.labelWidth = 0;

		prop.serializedObject.ApplyModifiedProperties ();
	}
开发者ID:JBillingsley,项目名称:eecs-390-rts,代码行数:30,代码来源:TileRenderDrawer.cs

示例11: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);

        position.height = EditorGUIUtility.singleLineHeight;

        // First line: mode selector.
        var propMode = property.FindPropertyRelative("_mode");
        EditorGUI.IntPopup(position, propMode, modeLabels, modeValues, label);
        position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

        // Indent the line.
        position.width -= 16;
        position.x += 16;
        EditorGUIUtility.labelWidth -= 16;

        // Reference box.
        var mode = (InjectorLink.Mode)propMode.intValue;
        if (propMode.hasMultipleDifferentValues || mode == InjectorLink.Mode.ByReference)
        {
            EditorGUI.PropertyField(position, property.FindPropertyRelative("_reference"));
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
        }

        // Name box.
        if (propMode.hasMultipleDifferentValues || mode == InjectorLink.Mode.ByName)
            EditorGUI.PropertyField(position, property.FindPropertyRelative("_name"));

        // Update the link when it gets updated.
        if (GUI.changed) property.FindPropertyRelative("_forceUpdate").boolValue = true;

        EditorGUI.EndProperty();
    }
开发者ID:dgkae,项目名称:Teatro,代码行数:33,代码来源:GenericLinkDrawer.cs

示例12: OnGUI

	public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 
	{
		label.text = "";
		
		// Using BeginProperty / EndProperty on the parent property means that
		// prefab override logic works on the entire property.
		EditorGUI.BeginProperty (position, label, property);
		
		// Draw label
		position = EditorGUI.PrefixLabel (position, GUIUtility.GetControlID (FocusType.Passive), label);
		
		// Don't make child fields be indented
		var indent = EditorGUI.indentLevel;
		EditorGUI.indentLevel = 0;
		
		// Calculate rects
		Rect pointsRect = new Rect (position.x, position.y, position.width * 0.6f, position.height);
		Rect streakRect = new Rect (pointsRect.x + pointsRect.width, position.y, position.width * 0.3f, position.height);
		
		// Draw fields - passs GUIContent.none to each so they are drawn without labels
		EditorGUIUtility.labelWidth = pointsRect.width * 0.5f;
		EditorGUI.PropertyField (pointsRect, property.FindPropertyRelative ("item"), GUIContent.none);
		EditorGUIUtility.labelWidth = streakRect.width * 0.3f;
		EditorGUI.PropertyField (streakRect, property.FindPropertyRelative ("percent"), new GUIContent("%"));
		
		// Set indent back to what it was
		EditorGUI.indentLevel = indent;
		
		EditorGUI.EndProperty ();
	}
开发者ID:OvertimeStudios,项目名称:CreepyBuster,代码行数:30,代码来源:ItemPercentDrawer.cs

示例13: OnGUI

        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            // Calculate rects:

            float halfWidth = position.width / 2;
            float questStateWidth = Mathf.Min(halfWidth, 160f) - 32f;
            float questNameWidth = position.width - questStateWidth - 16f;
            Rect questNameRect = new Rect(position.x + 16f, position.y, questNameWidth, position.height);
            Rect questStateRect = new Rect(position.x + questNameWidth + 16, position.y, questStateWidth, position.height);

            // Draw fields - pass GUIContent.none to each so they are drawn without labels
            var questName = property.FindPropertyRelative("questName");
            if (EditorTools.selectedDatabase == null) {
                EditorGUI.PropertyField(questNameRect, questName, GUIContent.none);
            } else {
                int questNameIndex;
                string[] questNames = GetQuestNames(questName.stringValue, out questNameIndex);
                int newQuestNameIndex = EditorGUI.Popup(questNameRect, questNameIndex, questNames);
                if (newQuestNameIndex != questNameIndex) {
                    questName.stringValue = GetQuestName(questNames, newQuestNameIndex);
                }
            }

            var questState = property.FindPropertyRelative("questState");
            EditorGUI.PropertyField(questStateRect, questState, GUIContent.none);

            EditorGUI.EndProperty();
        }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:33,代码来源:QuestConditionPropertyDrawer.cs

示例14: OnGUI

	// Draw the property inside the given rect
	public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
	{
		// Using BeginProperty / EndProperty on the parent property means that
		// prefab override logic works on the entire property.
		EditorGUI.BeginProperty (position, label, property);

		//Get selected property
		int selectedValue = property.FindPropertyRelative("current").intValue;

		// Draw label
		label.text = "Property";
		position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

		//Get array of properties
		SerializedProperty sProp = property.FindPropertyRelative("properties");
		string[] properties = new string[sProp.arraySize];
		int[] values = new int[properties.Length];
		for (int i = 0; i < sProp.arraySize; i++)
		{
			properties[i] = sProp.GetArrayElementAtIndex(i).stringValue;
			values[i] = i;
		}

		//Draw enum
		selectedValue = EditorGUI.IntPopup(position, selectedValue, properties, values);

		//Save selected property
		property.FindPropertyRelative("current").intValue = selectedValue;


		EditorGUI.EndProperty();
	}
开发者ID:t1mmmmY,项目名称:ResourceManager,代码行数:33,代码来源:ComponentPropertiesDrawer.cs

示例15: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Presenter:", GUILayout.Width(65));
        EditorGUILayout.PropertyField(property.FindPropertyRelative("presenterName"), GUIContent.none);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Company:", GUILayout.Width(65));
        EditorGUILayout.PropertyField(property.FindPropertyRelative("company"), GUIContent.none);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Length (m):", GUILayout.Width(65));
        EditorGUILayout.IntSlider(property.FindPropertyRelative("presentationLength"), 0, 45, GUIContent.none);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Title:", GUILayout.Width(65));
        EditorGUILayout.PropertyField(property.FindPropertyRelative("presentationTitle"), GUIContent.none);
        EditorGUILayout.EndHorizontal();

        EditorGUI.EndProperty();
    }
开发者ID:DUUG,项目名称:Meetup-3,代码行数:26,代码来源:DUUGPresenterDrawer.cs


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