Example #1
0
        public void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (m_RequireLocal)
            {
                var go = EditorGUIUtil.GetReferenceObject(property, m_SearchPropertyPath, false);

                if (m_SearchInfo == null)
                {
                    m_SearchInfo = new SearchInfo();
                }

                m_SearchInfo.Update(go);
            }
            else
            {
                m_SearchInfo = null;
            }

            bool hasLabel = label != GUIContent.none;  // Must be before 'begin property'.

            label = EditorGUI.BeginProperty(position, label, property);

            Rect rect = EditorGUIUtil.SingleLinePosition(position);

            if (hasLabel)
            {
                EditorGUI.LabelField(rect, label);
            }

            var origLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 80;

            if (m_SearchInfo != null)
            {
                DrawLocal(rect, property, hasLabel);
            }
            else
            {
                DrawBasic(rect, property, hasLabel);
            }

            EditorGUIUtility.labelWidth = origLabelWidth;

            EditorGUI.EndProperty();
        }