public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     serializedObject.Update();
     using (var hor = new EditorGUILayout.HorizontalScope())
     {
         EditorGUILayout.PropertyField(prop_document);
         if (GUILayout.Button("new", GUILayout.Width(60)))
         {
             GUIUtil.CreateNewScriptObjectToProp <Document>((x) => {
                 serializedObject.FindProperty("document").objectReferenceValue = x;
                 serializedObject.ApplyModifiedProperties();
             });
         }
     }
     serializedObject.ApplyModifiedProperties();
     if (prop_document.objectReferenceValue != null)
     {
         DrawDocument(prop_document.objectReferenceValue);
     }
 }
예제 #2
0
        private void DrawChapterElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect = GUIUtil.DrawBoxRect(rect, index.ToString());
            var rect1 = new Rect(rect.x, rect.y, rect.width - 60, rect.height);
            var prop  = prop_chapters.GetArrayElementAtIndex(index);

            EditorGUI.PropertyField(rect1, prop, new GUIContent());
            if (isActive && prop.objectReferenceValue != null)
            {
                DrawChapterDetail(prop.objectReferenceValue);
            }
            var rect2 = new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height);

            if (GUI.Button(rect2, "new"))
            {
                GUIUtil.CreateNewScriptObjectToProp <Chapter>((x) => {
                    prop_chapters             = serializedObject.FindProperty("chapters");
                    prop                      = prop_chapters.GetArrayElementAtIndex(index);
                    prop.objectReferenceValue = x;
                    prop.serializedObject.ApplyModifiedProperties();
                });
            }
        }