private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect = GUIUtil.DrawBoxRect(rect, index.ToString());
            var prop      = prop_paragraphs.GetArrayElementAtIndex(index);
            var prop_type = prop.FindPropertyRelative("type");
            var typeRect  = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);

            prop_type.enumValueIndex = EditorGUI.Popup(typeRect, prop_type.enumValueIndex, prop_type.enumNames);
            if (prop_type.enumValueIndex == (int)ParagraphType.Text)
            {
                var prop_textContent = prop.FindPropertyRelative("text");
                DrawTextContent(rect, prop_textContent);
            }
            else if (prop_type.enumValueIndex == (int)ParagraphType.Sprite)
            {
                var prop_spriteContent = prop.FindPropertyRelative("sprite");
                DrawSpriteContent(rect, prop_spriteContent);
            }
        }
 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);
     }
 }
Esempio n. 3
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();
                });
            }
        }