Beispiel #1
0
        private void CreateContentRects(GUIStyle style, int indentLevel, out GUIContentRect nodeGUI, out GUIContentRect foldoutGUI, out GUIContentRect iconGUI, out GUIContentRect labelGUI)
        {
            GUIContent iconContent, labelContent;
            var        foldoutContent = GetFoldoutContent(indentLevel);

            GetObjectNodeContents(_objectNode, out iconContent, out labelContent);

            nodeGUI    = new GUIContentRect(GUIContent.none, GUILayoutUtility.GetRect(foldoutContent, style));
            foldoutGUI = new GUIContentRect(foldoutContent, nodeGUI);
            iconGUI    = new GUIContentRect(iconContent, nodeGUI);
            labelGUI   = new GUIContentRect(labelContent, nodeGUI);

            foldoutGUI.SetWidth(InterfaceableGUIHelper.GetMinWidth(foldoutContent, style) + 2.0f);

            iconGUI.MoveNextTo(foldoutGUI);
            iconGUI.SetWidth(iconContent == null ? 0.0f : (InterfaceableGUIHelper.GetScaledTextureWidth(iconContent.image, foldoutGUI.Rect.height, style) + 2.0f));

            labelGUI.MoveNextTo(iconGUI);
            labelGUI.SetWidth(InterfaceableGUIHelper.GetMinWidth(labelContent, style));
        }
    private static void DrawInterfaceableContainer <TResult>(Rect position, GUIContent label, SerializedContainer serializedContainer)
        where TResult : class
    {
        _currentEvent = Event.current;
        var resultTypeName = NeverLab.Interfaceable.InterfaceableContainerBase.ConstructResolvedName(CachedType <TResult> .Type);

        if (string.IsNullOrEmpty(label.tooltip))
        {
            label.tooltip = resultTypeName;
        }
        var labelRect = new GUIContentRect(label, position);

        labelRect.SetWidth(EditorGUIUtility.labelWidth);

        var resultRect = new GUIContentRect(null, position);

        resultRect.MoveNextTo(labelRect);
        resultRect.Rect.xMax -= (ButtonSpace + ButtonWidth) * 2;

        var nullButonRect = new GUIContentRect(null, position);

        nullButonRect.MoveNextTo(resultRect, ButtonSpace);
        nullButonRect.SetWidth(ButtonWidth);

        var listButtonRect = new GUIContentRect(null, position);

        listButtonRect.MoveNextTo(nullButonRect, ButtonSpace);
        listButtonRect.SetWidth(ButtonWidth);

        var isProjectAsset = serializedContainer.IsProjectAsset;
        var pingable       = !serializedContainer.ObjectFieldProperty.hasMultipleDifferentValues && InterfaceableGUIHelper.IsPingable(serializedContainer.ObjectField);
        var dragDropResult = GetDragAndDropResult <TResult>(resultRect, isProjectAsset, serializedContainer);

        EditorGUI.LabelField(labelRect, label);
        InterfaceableGUIHelper.EnabledBlock(() =>
        {
            GUI.enabled = pingable;

            InterfaceableGUIHelper.ColorBlock(() =>
            {
                if (serializedContainer.Selecting || serializedContainer.Dropping)
                {
                    GUI.color = new Color(1, 1, 1, 2);
                }
                else
                {
                    GUI.color = pingable ? new Color(1, 1, 1, 2) : Color.white;
                }

                DrawField(serializedContainer, resultRect, pingable);
            });
        });

        if (dragDropResult != null)
        {
            serializedContainer.ObjectField = dragDropResult as Object;
            GUI.changed = true;
        }

        if (GUI.Button(nullButonRect, new GUIContent("○", "Set to null"), InterfaceableGUIHelper.InspectorStyles.NullOutButton))
        {
            serializedContainer.ObjectField = null;
        }

        InterfaceableGUIHelper.EnabledBlock(() =>
        {
            if (GUI.Button(listButtonRect, new GUIContent("◉", "Select from list"), InterfaceableGUIHelper.InspectorStyles.SelectFromListButton))
            {
                _selectWindow = InterfaceableContainerSelectWindow.ShowSelectWindow(resultTypeName, isProjectAsset, serializedContainer, GetSelectable <TResult>(isProjectAsset));
            }
        });
    }
        private void CreateContentRects(GUIStyle style, int indentLevel, out GUIContentRect nodeGUI, out GUIContentRect foldoutGUI, out GUIContentRect iconGUI, out GUIContentRect labelGUI)
        {
            GUIContent iconContent, labelContent;
            var foldoutContent = GetFoldoutContent(indentLevel);
            GetObjectNodeContents(_objectNode, out iconContent, out labelContent);

            nodeGUI = new GUIContentRect(GUIContent.none, GUILayoutUtility.GetRect(foldoutContent, style));
            foldoutGUI = new GUIContentRect(foldoutContent, nodeGUI);
            iconGUI = new GUIContentRect(iconContent, nodeGUI);
            labelGUI = new GUIContentRect(labelContent, nodeGUI);

            foldoutGUI.SetWidth(IUnifiedGUIHelper.GetMinWidth(foldoutContent, style) + 2.0f);

            iconGUI.MoveNextTo(foldoutGUI);
            iconGUI.SetWidth(iconContent == null ? 0.0f : (IUnifiedGUIHelper.GetScaledTextureWidth(iconContent.image, foldoutGUI.Rect.height, style) + 2.0f));

            labelGUI.MoveNextTo(iconGUI);
            labelGUI.SetWidth(IUnifiedGUIHelper.GetMinWidth(labelContent, style));
        }