Esempio n. 1
0
    protected bool FindConnectionsRecursive(SerializedProperty iterator)
    {
        bool next  = iterator.NextVisible(true);
        var  depth = next != false ? iterator.depth : 0;

        while (next && iterator.depth >= depth)
        {
            if (iterator.hasVisibleChildren)
            {
                if (FindConnectionsRecursive(iterator))
                {
                    continue;
                }
                else
                {
                    return(false);
                }
            }
            else if (iterator.propertyType == SerializedPropertyType.ObjectReference)
            {
                var propertyType = NodeEditorUtilities.GetPropertyType(iterator);
                if (propertyType.IsSubclassOf(typeof(ScriptableObject)))
                {
                    GetNodeConnector(iterator.propertyPath, propertyType).Initialize();
                }
            }

            next = iterator.NextVisible(true);
        }

        return(next);
    }
Esempio n. 2
0
    protected bool DrawPropertiesRecursive(SerializedProperty iterator)
    {
        bool next  = iterator.NextVisible(true);
        var  depth = next != false ? iterator.depth : 0;

        while (next && iterator.depth >= depth)
        {
            if (iterator.hasVisibleChildren)
            {
                if (Settings.IndentNested)
                {
                    EditorGUI.indentLevel = iterator.depth;
                }

                iterator.isExpanded    = EditorGUILayout.Foldout(iterator.isExpanded, iterator.displayName, true);
                currentPropertyHeight += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

                if (Settings.IndentHeadersOnly)
                {
                    EditorGUI.indentLevel = 0;
                }

                if (iterator.isExpanded)
                {
                    currentPropertyHeight += EditorGUIUtility.standardVerticalSpacing;
                    EditorGUILayout.BeginVertical(Settings.SeparatorStyle);

                    var proceed = DrawPropertiesRecursive(iterator);

                    EditorGUILayout.EndVertical();

                    if (proceed)
                    {
                        if (depth == iterator.depth)
                        {
                            currentPropertyHeight += EditorGUIUtility.standardVerticalSpacing;
                        }

                        continue;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                EditorGUILayout.PropertyField(iterator, false);

                if (iterator.propertyType == SerializedPropertyType.ObjectReference)
                {
                    var propertyType = NodeEditorUtilities.GetPropertyType(iterator);
                    if (propertyType.IsSubclassOf(typeof(ScriptableObject)))
                    {
                        GetNodeConnector(iterator.propertyPath, propertyType).SetDrawProperties(currentPropertyHeight, true);
                    }
                }

                currentPropertyHeight += EditorGUI.GetPropertyHeight(iterator) + EditorGUIUtility.standardVerticalSpacing;
            }

            next = iterator.NextVisible(iterator.isExpanded);
        }

        return(next);
    }