本文整理汇总了C#中SerializedProperty.FindPropertyRelative方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty.FindPropertyRelative方法的具体用法?C# SerializedProperty.FindPropertyRelative怎么用?C# SerializedProperty.FindPropertyRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializedProperty
的用法示例。
在下文中一共展示了SerializedProperty.FindPropertyRelative方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: OnGUI
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect position = rect;
position.height = EditorGUIUtility.singleLineHeight;
SerializedProperty propertyRelative1 = prop.FindPropertyRelative("m_HighlightedSprite");
SerializedProperty propertyRelative2 = prop.FindPropertyRelative("m_PressedSprite");
SerializedProperty propertyRelative3 = prop.FindPropertyRelative("m_DisabledSprite");
EditorGUI.PropertyField(position, propertyRelative1);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, propertyRelative2);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, propertyRelative3);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
示例3: OnGUI
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect drawRect = rect;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty highlightedSprite = prop.FindPropertyRelative("m_HighlightedSprite");
SerializedProperty pressedSprite = prop.FindPropertyRelative("m_PressedSprite");
SerializedProperty disabledSprite = prop.FindPropertyRelative("m_DisabledSprite");
EditorGUI.PropertyField(drawRect, highlightedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
示例4: Copy
protected static void Copy(SerializedProperty prop)
{
m_Copy = new ColorBlockExtended();
m_Copy.normalColor = prop.FindPropertyRelative("m_NormalColor").colorValue;
m_Copy.highlightedColor = prop.FindPropertyRelative("m_HighlightedColor").colorValue;
m_Copy.pressedColor = prop.FindPropertyRelative("m_PressedColor").colorValue;
m_Copy.activeColor = prop.FindPropertyRelative("m_ActiveColor").colorValue;
m_Copy.activeHighlightedColor = prop.FindPropertyRelative("m_ActiveHighlightedColor").colorValue;
m_Copy.activePressedColor = prop.FindPropertyRelative("m_ActivePressedColor").colorValue;
m_Copy.disabledColor = prop.FindPropertyRelative("m_DisabledColor").colorValue;
m_Copy.colorMultiplier = prop.FindPropertyRelative("m_ColorMultiplier").floatValue;
m_Copy.fadeDuration = prop.FindPropertyRelative("m_FadeDuration").floatValue;
m_HasCopy = true;
}
示例5: OnGUI
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect position = rect;
position.height = EditorGUIUtility.singleLineHeight;
SerializedProperty property = prop.FindPropertyRelative("m_NormalColor");
SerializedProperty property2 = prop.FindPropertyRelative("m_HighlightedColor");
SerializedProperty property3 = prop.FindPropertyRelative("m_PressedColor");
SerializedProperty property4 = prop.FindPropertyRelative("m_ActiveColor");
SerializedProperty property5 = prop.FindPropertyRelative("m_ActiveHighlightedColor");
SerializedProperty property6 = prop.FindPropertyRelative("m_ActivePressedColor");
SerializedProperty property7 = prop.FindPropertyRelative("m_DisabledColor");
SerializedProperty property8 = prop.FindPropertyRelative("m_ColorMultiplier");
SerializedProperty property9 = prop.FindPropertyRelative("m_FadeDuration");
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);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, property8);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, property9);
Rect controlRect = EditorGUILayout.GetControlRect();
controlRect.xMin = (controlRect.xMin + EditorGUIUtility.labelWidth);
// Copy button
if (GUI.Button(new Rect(controlRect.x, controlRect.y, ((controlRect.width / 2f) - 2f), controlRect.height), "Copy", EditorStyles.miniButton))
{
// Save the current values
ColorBlockExtendedDrawer.Copy(prop);
}
// Disable the paste button if we dont have a copied property
if (!m_HasCopy)
GUI.enabled = false;
if (GUI.Button(new Rect((controlRect.x + ((controlRect.width / 2f) + 4f)), controlRect.y, ((controlRect.width / 2f) - 2f), controlRect.height), "Paste", EditorStyles.miniButton))
{
// Apply the copied values
ColorBlockExtendedDrawer.Paste(ref prop);
}
GUI.enabled = true;
}
示例6: 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);
}
示例7: Init
private void Init(SerializedProperty property)
{
if (this.m_ReorderableList != null)
return;
SerializedProperty propertyRelative = property.FindPropertyRelative("m_Options");
this.m_ReorderableList = new ReorderableList(property.serializedObject, propertyRelative);
this.m_ReorderableList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawOptionData);
this.m_ReorderableList.drawHeaderCallback = new ReorderableList.HeaderCallbackDelegate(this.DrawHeader);
this.m_ReorderableList.elementHeight += 16f;
}
示例8: OnGUI
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
if (s_Styles == null)
s_Styles = new Styles();
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty navigation = prop.FindPropertyRelative("m_Mode");
Navigation.Mode navMode = GetNavigationMode(navigation);
EditorGUI.PropertyField(drawRect, navigation, s_Styles.navigationContent);
++EditorGUI.indentLevel;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
switch (navMode)
{
case Navigation.Mode.None: return;
case Navigation.Mode.Explicit:
{
SerializedProperty selectOnUp = prop.FindPropertyRelative("m_SelectOnUp");
SerializedProperty selectOnDown = prop.FindPropertyRelative("m_SelectOnDown");
SerializedProperty selectOnLeft = prop.FindPropertyRelative("m_SelectOnLeft");
SerializedProperty selectOnRight = prop.FindPropertyRelative("m_SelectOnRight");
EditorGUI.PropertyField(drawRect, selectOnUp);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnDown);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnLeft);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnRight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
break;
}
--EditorGUI.indentLevel;
}
示例9: Init
private void Init(SerializedProperty property)
{
if (m_ReorderableList != null)
return;
SerializedProperty array = property.FindPropertyRelative("m_Options");
m_ReorderableList = new ReorderableList(property.serializedObject, array);
m_ReorderableList.drawElementCallback = DrawOptionData;
m_ReorderableList.drawHeaderCallback = DrawHeader;
m_ReorderableList.elementHeight += 16;
}
示例10: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
SerializedProperty navigation = prop.FindPropertyRelative("m_Mode");
if (navigation == null)
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
Navigation.Mode navMode = GetNavigationMode(navigation);
switch (navMode)
{
case Navigation.Mode.None: return EditorGUIUtility.singleLineHeight;
case Navigation.Mode.Explicit: return 5 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
default: return EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
示例11: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
SerializedProperty propertyRelative = prop.FindPropertyRelative("m_Mode");
if (propertyRelative == null)
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
switch (NavigationDrawer.GetNavigationMode(propertyRelative))
{
case Navigation.Mode.None:
return EditorGUIUtility.singleLineHeight;
case Navigation.Mode.Explicit:
return (float) (5.0 * (double) EditorGUIUtility.singleLineHeight + 5.0 * (double) EditorGUIUtility.standardVerticalSpacing);
default:
return EditorGUIUtility.singleLineHeight + 1f * EditorGUIUtility.standardVerticalSpacing;
}
}
示例12: OnGUI
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect position = rect;
position.height = EditorGUIUtility.singleLineHeight;
SerializedProperty propertyRelative1 = prop.FindPropertyRelative("m_NormalColor");
SerializedProperty propertyRelative2 = prop.FindPropertyRelative("m_HighlightedColor");
SerializedProperty propertyRelative3 = prop.FindPropertyRelative("m_PressedColor");
SerializedProperty propertyRelative4 = prop.FindPropertyRelative("m_DisabledColor");
SerializedProperty propertyRelative5 = prop.FindPropertyRelative("m_ColorMultiplier");
SerializedProperty propertyRelative6 = prop.FindPropertyRelative("m_FadeDuration");
EditorGUI.PropertyField(position, propertyRelative1);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
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.PropertyField(position, propertyRelative6);
}
示例13: OnGUI
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect drawRect = rect;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty normalColor = prop.FindPropertyRelative("m_NormalColor");
SerializedProperty highlighted = prop.FindPropertyRelative("m_HighlightedColor");
SerializedProperty pressedColor = prop.FindPropertyRelative("m_PressedColor");
SerializedProperty disabledColor = prop.FindPropertyRelative("m_DisabledColor");
SerializedProperty colorMultiplier = prop.FindPropertyRelative("m_ColorMultiplier");
SerializedProperty fadeDuration = prop.FindPropertyRelative("m_FadeDuration");
EditorGUI.PropertyField(drawRect, normalColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, highlighted);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, colorMultiplier);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, fadeDuration);
}
示例14: Paste
protected static void Paste(ref SerializedProperty prop)
{
if (!m_HasCopy)
return;
prop.FindPropertyRelative("m_NormalColor").colorValue = m_Copy.normalColor;
prop.FindPropertyRelative("m_HighlightedColor").colorValue = m_Copy.highlightedColor;
prop.FindPropertyRelative("m_PressedColor").colorValue = m_Copy.pressedColor;
prop.FindPropertyRelative("m_ActiveColor").colorValue = m_Copy.activeColor;
prop.FindPropertyRelative("m_ActiveHighlightedColor").colorValue = m_Copy.activeHighlightedColor;
prop.FindPropertyRelative("m_ActivePressedColor").colorValue = m_Copy.activePressedColor;
prop.FindPropertyRelative("m_DisabledColor").colorValue = m_Copy.disabledColor;
prop.FindPropertyRelative("m_ColorMultiplier").floatValue = m_Copy.colorMultiplier;
prop.FindPropertyRelative("m_FadeDuration").floatValue = m_Copy.fadeDuration;
}
示例15: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
const float iconSizeX = 30f;
const float iconSizeY = 16f;
const float asyncSizeX = 58f;
const float asyncSizeY = 16f;
const float asyncToggleSizeX = 18f;
const float controlTypeSizeX = 140f;
var propertyPosition = new Rect(position.x, position.y, position.width - iconSizeX - asyncSizeX - controlTypeSizeX + 30f, position.height);
var labelPosition = new Rect(position.x + propertyPosition.width - iconSizeX - 18f, propertyPosition.y, iconSizeX, iconSizeY);
var asyncRectLabel = new Rect(position.x + propertyPosition.width, position.y, asyncSizeX - asyncToggleSizeX, asyncSizeY);
var asyncRect = new Rect(asyncRectLabel.x + asyncRectLabel.width, position.y, asyncToggleSizeX, asyncSizeY);
var controlTypeRect = new Rect(asyncRect.x + asyncRect.width, position.y, controlTypeSizeX, asyncSizeY);
var tempObject = property.FindPropertyRelative("tempObject");
EditorGUI.ObjectField(propertyPosition, tempObject, label);
EditorGUI.BeginDisabledGroup(tempObject.objectReferenceValue == null);
var asyncToggle = property.FindPropertyRelative("async");
if (GUI.Button(asyncRectLabel, new GUIContent("Async", "Loads Object Asynchronously"), EditorStyles.miniButtonLeft) == true) {
asyncToggle.boolValue = !asyncToggle.boolValue;
}
var oldColor = GUI.color;
GUI.color = (asyncToggle.boolValue == false ? oldColor : Color.green);
asyncToggle.boolValue = GUI.Toggle(asyncRect, asyncToggle.boolValue, string.Empty, EditorStyles.miniButtonRight);
GUI.color = oldColor;
EditorGUI.EndDisabledGroup();
var attr = PropertyExtensions.GetAttribute<ResourceParametersAttribute>(this);
var controlType = property.FindPropertyRelative("controlType");
var values = System.Enum.GetValues(typeof(UnityEngine.UI.Windows.ResourceBase.ControlType));
var names = System.Enum.GetNames(typeof(UnityEngine.UI.Windows.ResourceBase.ControlType));
var items = new List<byte>();
var itemNames = new List<string>();
if (attr != null) {
for (int i = 0; i < values.Length; ++i) {
var value = (byte)values.GetValue(i);
if (value == 0) continue;
if (((byte)attr.drawOnly & value) != 0) {
items.Add(value);
itemNames.Add(names[i]);
}
}
} else {
for (int i = 0; i < values.Length; ++i) {
var value = (byte)values.GetValue(i);
if (value == 0) continue;
items.Add(value);
itemNames.Add(names[i]);
}
}
for (int i = 0; i < items.Count; ++i) {
var k = i;
var width = controlTypeRect.width / items.Count;
var value = items[i];
var enumValue = controlType.intValue;
var isOn = (enumValue & value) != 0;
isOn = GUI.Toggle(new Rect(controlTypeRect.x + (k * width), controlTypeRect.y, width, controlTypeRect.height), isOn, new GUIContent(itemNames[i], "Event when you want to initialize/deinitialize this resource"), (k == 0 ? EditorStyles.miniButtonLeft : (i == items.Count - 1 ? EditorStyles.miniButtonRight : EditorStyles.miniButtonMid)));
if (isOn == true) {
enumValue |= value;
} else {
enumValue &= ~value;
}
controlType.intValue = enumValue;
//.........这里部分代码省略.........