private void init(SerializedProperty groupProperty)
        {
            Assert.IsNotNull(groupProperty);
            _groupProperty = groupProperty;

            _multiFeatureList     = _groupProperty.FindPropertyRelative("_features");
            _multiRenderingMethod = _groupProperty.FindPropertyRelative("_renderingMethod");

            _featureTable = MultiTypedListUtil.GetTableProperty(_multiFeatureList);
            Assert.IsNotNull(_featureTable);

            if (_featureList == null || !SerializedProperty.EqualContents(_featureList.serializedProperty, _featureTable))
            {
                _featureList = new ReorderableList(_serializedObject,
                                                   _featureTable,
                                                   draggable: true,
                                                   displayHeader: false,
                                                   displayAddButton: false,
                                                   displayRemoveButton: false);

                _featureList.showDefaultBackground = false;
                _featureList.headerHeight          = 0;
                _featureList.elementHeight         = EditorGUIUtility.singleLineHeight;
                _featureList.elementHeightCallback = featureHeightCallback;
                _featureList.drawElementCallback   = drawFeatureCallback;
                _featureList.onReorderCallback     = onReorderFeaturesCallback;
            }

            _renderingMethod = MultiTypedReferenceUtil.GetReferenceProperty(_multiRenderingMethod);
            _supportInfo     = _groupProperty.FindPropertyRelative("_supportInfo");

            _cachedPropertyList    = new List <SerializedProperty>();
            _cachedPropertyHeights = new List <float>();

            for (int i = 0; i < _featureTable.arraySize; i++)
            {
                var idIndex       = _featureTable.GetArrayElementAtIndex(i);
                var referenceProp = MultiTypedListUtil.GetReferenceProperty(_multiFeatureList, idIndex);
                _cachedPropertyList.Add(referenceProp);

                //Make sure to add one line for the label
                _cachedPropertyHeights.Add(EditorGUI.GetPropertyHeight(referenceProp) + EditorGUIUtility.singleLineHeight);
            }

            _renderingMethod = MultiTypedReferenceUtil.GetReferenceProperty(_multiRenderingMethod);

            if (_renderingMethodMonoScript == null)
            {
                _renderingMethodMonoScript = AssetDatabase.FindAssets(_renderingMethod.type).
                                             Query().
                                             Where(guid => !string.IsNullOrEmpty(guid)).
                                             Select(guid => AssetDatabase.GUIDToAssetPath(guid)).
                                             Where(path => Path.GetFileNameWithoutExtension(path) == _renderingMethod.type).
                                             Select(path => AssetDatabase.LoadAssetAtPath <MonoScript>(path)).
                                             FirstOrDefault();
            }
        }
Ejemplo n.º 2
0
    protected override void OnEnable()
    {
        base.OnEnable();

        hideField("_anchor");
        hideField("_featureData");
        hideField("_attachedRenderer");
        hideField("_attachedGroupIndex");
        hideField("_preferredRendererType");

        _featureList  = serializedObject.FindProperty("_featureData");
        _featureTable = MultiTypedListUtil.GetTableProperty(_featureList);

        dontShowScriptField();
    }