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);
            }
        }
Exemplo n.º 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();
                });
            }
        }