本文整理汇总了C#中UnityEditor.SerializedProperty.GetInstance方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty.GetInstance方法的具体用法?C# SerializedProperty.GetInstance怎么用?C# SerializedProperty.GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SerializedProperty
的用法示例。
在下文中一共展示了SerializedProperty.GetInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var intent = EditorGUI.indentLevel;
position = EditorGUI.IndentedRect(position);
EditorGUI.indentLevel = 0;
EditorGUI.BeginChangeCheck();
var prefabInstance = property.serializedObject.targetObject as PEPrefabScript;
var modificationInstance = property.GetInstance<PEModifications.PropertyData>();
SerializedProperty prefabProperty;
SerializedProperty instanceProperty;
modificationInstance.GetProperties(out prefabProperty, out instanceProperty, prefabInstance);
if (instanceProperty == null)
return;
var mode = property.FindPropertyRelative("Mode");
var color = GUI.color;
GUI.color = mode.enumValueIndex == 0 ? new Color(1, 1, 1, 1) : (mode.enumValueIndex == 1 ? new Color(0, 1, 0, 1) : new Color(1, 0, 0, 1));
position.x -= 6;
position.width += 6;
GUI.Box(position, "", "Window");
position.x += 12;
position.width -= 18;
GUI.color = color;
var enabled = GUI.enabled;
GUI.enabled = false;
var height = EditorGUI.GetPropertyHeight(instanceProperty);
position.y += EditorGUIUtility.singleLineHeight + 3;
if (prefabProperty != null)
EditorGUI.PropertyField(new Rect(position) { height = height }, prefabProperty, true);
else
EditorGUI.LabelField(new Rect(position) { height = height }, "Property not exist");
position.y += height + 2;
GUI.enabled = enabled;
EditorGUI.PropertyField(new Rect(position) { height = height }, instanceProperty, true);
position.y += height;
var buttons = GetButtonsData(prefabInstance, prefabProperty, instanceProperty);
position.y += 3;
var startRect = new Rect(position) {
height = 15,
width = position.width / (buttons.Length + 1),
};
var lw = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 0;
EditorGUIUtility.fieldWidth = 0;
EditorGUI.PropertyField(new Rect(startRect) { width = startRect.width - 6 }, mode, new GUIContent("", "Select proprty mode"), true);
EditorGUIUtility.labelWidth = lw;
startRect.x += startRect.width;
var i = 0;
foreach (var button in buttons)
{
var style = i == 0 ? EditorStyles.miniButtonLeft : (i == buttons.Length - 1 ? EditorStyles.miniButtonRight : EditorStyles.miniButtonMid);
if (GUI.Button(startRect, button.Key, style))
button.Value();
startRect.x += startRect.width;
i++;
}
startRect.x = position.x;
startRect.y += startRect.height;
if (EditorGUI.EndChangeCheck())
{
instanceProperty.serializedObject.ApplyModifiedProperties();
if (prefabProperty != null)
prefabProperty.serializedObject.ApplyModifiedProperties();
}
EditorGUI.indentLevel = intent;
}