Beispiel #1
0
        void DrawWithEditor(SerializedProperty property)
        {
            Editor editor = Editor.CreateEditor(property.objectReferenceValue);

            if (editor == null)
            {
                return;
            }

            Rect foldoutRect = GUILayoutUtility.GetLastRect();

            foldoutRect.width   = 20.0f;
            property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "");

            if (property.isExpanded)
            {
                if (property.isArray)
                {
                    property.arraySize = EditorGUILayout.IntField("Size", property.arraySize);
                }

                try
                {
                    EditorGUILayoutHelper.Indent(() =>
                    {
                        editor.OnInspectorGUI();
                    });
                }
                catch (Exception exc)
                {
                    Dbg.LogExc(exc);
                    Dbg.LogErrorRelease("Exception thrown with InlineObjectAttriute.useEditor = true. Does the serialized object type have an Editor?");
                    throw exc;
                }
            }
        }