当前位置: 首页>>代码示例>>C#>>正文


C# ReorderableList.onSelectCallback方法代码示例

本文整理汇总了C#中UnityEditorInternal.ReorderableList.onSelectCallback方法的典型用法代码示例。如果您正苦于以下问题:C# ReorderableList.onSelectCallback方法的具体用法?C# ReorderableList.onSelectCallback怎么用?C# ReorderableList.onSelectCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEditorInternal.ReorderableList的用法示例。


在下文中一共展示了ReorderableList.onSelectCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddProperty

            public void AddProperty(SerializedProperty property)
            {
                // Check if this property actually belongs to the same direct child
                if (GetGrandParentPath(property).Equals(Parent) == false)
                    return;

                ReorderableList propList = new ReorderableList(
                    property.serializedObject, property,
                    draggable: true, displayHeader: false,
                    displayAddButton: true, displayRemoveButton: true)
                {
                    headerHeight = 5
                };

                propList.drawElementCallback = delegate(Rect rect, int index, bool active, bool focused)
                {
                    SerializedProperty targetElement = property.GetArrayElementAtIndex(index);
                    bool isExpanded = targetElement.isExpanded;
                    rect.height = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, isExpanded);

                    if (targetElement.hasVisibleChildren)
                        rect.xMin += 10;

                    // Get Unity to handle drawing each element
                    EditorGUI.PropertyField(rect, targetElement, isExpanded);

                    // Height might have changed when dealing with serialized class
                    // Call the select callback when height changes to reset the list elementHeight
                    float newHeight = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, targetElement.isExpanded);
                    if (rect.height != newHeight)
                    {
                        propList.onSelectCallback(propList);
                #if UNITY_5_1 || UNITY_5_2
                        propList.elementHeight = Mathf.Max(propList.elementHeight, newHeight);
                #endif
                    }
                };

                propList.onSelectCallback = delegate(ReorderableList list)
                {
                    SerializedProperty targetElement = property.GetArrayElementAtIndex(list.index);
                    list.elementHeight = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, targetElement.isExpanded);
                };

                propList.onChangedCallback = delegate(ReorderableList list)
                {
                    list.onSelectCallback(list);
                };

                // Unity 5.3 onwards allows reorderable lists to have variable element heights
                #if UNITY_5_3_OR_NEWER
                propList.elementHeightCallback = delegate(int index)
                {
                    SerializedProperty arrayElement = property.GetArrayElementAtIndex(index);
                    return EditorGUI.GetPropertyHeight(arrayElement, GUIContent.none, arrayElement.isExpanded);
                };
                #endif
                propList.onAddCallback = delegate(ReorderableList list)
                {
                    list.serializedProperty.arraySize++;
                    propList.onSelectCallback(list);
                };

                propIndex.Add(property.propertyPath, propList);
            }
开发者ID:ChemiKhazi,项目名称:UnityToolbag,代码行数:65,代码来源:SortableArrayInspector.cs


注:本文中的UnityEditorInternal.ReorderableList.onSelectCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。