Beispiel #1
0
        private static void DrawArrayField(SerializedProperty _arrayProperty)
        {
            EditorGUILayout.BeginVertical(kContainerStyle);
            {
                string _displayName = ObjectNames.NicifyVariableName(_arrayProperty.name);
                _arrayProperty.isExpanded = UnityEditorUtility.DrawHeader(_displayName, _arrayProperty.isExpanded);

                // Show array contents, if its expanded
                if (_arrayProperty.isExpanded)
                {
                    // Start displaying array elements in next indentation level
                    EditorGUI.indentLevel++;

                    // Draw array size
                    EditorGUILayout.PropertyField(_arrayProperty.FindPropertyRelative("Array.size"));

                    // Get array size
                    int _arraySize = _arrayProperty.arraySize;

                    // Draw elements
                    for (int _arrayIter = 0; _arrayIter < _arraySize; _arrayIter++)
                    {
                        DrawPropertyField(_arrayProperty.GetArrayElementAtIndex(_arrayIter));
                    }

                    // Reset indentation level
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #2
0
        private static void DrawObjectField(SerializedProperty _property)
        {
            EditorGUILayout.BeginVertical(kContainerStyle);
            {
                string _displayName = _property.GetDisplayName();
                _property.isExpanded = UnityEditorUtility.DrawHeader(_displayName, _property.isExpanded);

                // If is expanded, then only show child properties
                if (_property.isExpanded)
                {
                    // Start displaying child properties in next indentation level
                    EditorGUI.indentLevel++;

                    // Draw child properties
                    DrawChildPropertyFields(_property);

                    // Reset indentation level
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.EndVertical();
        }