예제 #1
0
        static Styles()
        {
            spriteAlignmentOptions    = new GUIContent[10];
            spriteAlignmentOptions[0] = EditorGUIUtilityWrap.TextContent("Center");
            spriteAlignmentOptions[1] = EditorGUIUtilityWrap.TextContent("Top Left");
            spriteAlignmentOptions[2] = EditorGUIUtilityWrap.TextContent("Top");
            spriteAlignmentOptions[3] = EditorGUIUtilityWrap.TextContent("Top Right");;
            spriteAlignmentOptions[4] = EditorGUIUtilityWrap.TextContent("Left");
            spriteAlignmentOptions[5] = EditorGUIUtilityWrap.TextContent("Right");;
            spriteAlignmentOptions[6] = EditorGUIUtilityWrap.TextContent("Bottom Left");;
            spriteAlignmentOptions[7] = EditorGUIUtilityWrap.TextContent("Bottom");;
            spriteAlignmentOptions[8] = EditorGUIUtilityWrap.TextContent("Bottom Right");;
            spriteAlignmentOptions[9] = EditorGUIUtilityWrap.TextContent("Custom");;

            s_PivotLabel               = EditorGUIUtilityWrap.TextContent("Pivot");
            s_NoSelectionWarning       = EditorGUIUtilityWrap.TextContent("No texture or sprite selected");
            s_SpriteTessellationDetail = EditorGUIUtilityWrap.TextContent("Tessellation Detail");
        }
예제 #2
0
    public void HandleUnusedMouseEventsForItem(Rect rect, TreeViewItem item, bool firstItem)
    {
        int       itemControlId  = GetItemControlID(item);
        Event     current        = Event.current;
        EventType typeForControl = current.GetTypeForControl(itemControlId);

        switch (typeForControl)
        {
        case EventType.MouseDown:
            if (!rect.Contains(Event.current.mousePosition))
            {
                break;
            }
            if (Event.current.button == 0)
            {
                GUIUtility.keyboardControl = m_KeyboardControlID;
                Repaint();
                if (Event.current.clickCount == 2)
                {
                    if (itemDoubleClickedCallback != null)
                    {
                        itemDoubleClickedCallback(item.id);
                    }
                }
                else
                {
                    if (dragging == null || dragging.CanStartDrag(item, m_DragSelection, Event.current.mousePosition))
                    {
                        m_DragSelection = GetNewSelection(item, true, false);
                        ((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlId)).mouseDownPosition = Event.current.mousePosition;
                    }
                    GUIUtility.hotControl = itemControlId;
                }
                current.Use();
                break;
            }
            if (Event.current.button != 1)
            {
                break;
            }
            bool keepMultiSelection = true;
            SelectionClick(item, keepMultiSelection);
            break;

        case EventType.MouseUp:
            if (GUIUtility.hotControl != itemControlId)
            {
                break;
            }
            GUIUtility.hotControl = 0;
            m_DragSelection.Clear();
            current.Use();
            if (!rect.Contains(current.mousePosition))
            {
                break;
            }
            float      contentIndent = gui.GetContentIndent(item);
            Rect       rect1         = new Rect(rect.x + contentIndent, rect.y, rect.width - contentIndent, rect.height);
            List <int> selectedIds   = state.selectedIDs;
            if (m_AllowRenameOnMouseUp && selectedIds != null && (selectedIds.Count == 1 && selectedIds[0] == item.id) && (rect1.Contains(current.mousePosition) && !EditorGUIUtilityWrap.HasHolddownKeyModifiers(current)))
            {
                BeginNameEditing(0.5f);
                break;
            }
            SelectionClick(item, false);
            break;

        case EventType.MouseDrag:
            if (GUIUtility.hotControl != itemControlId || dragging == null)
            {
                break;
            }
            DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlId);
            if (dragAndDropDelay.CanStartDrag() && dragging.CanStartDrag(item, m_DragSelection, dragAndDropDelay.mouseDownPosition))
            {
                dragging.StartDrag(item, m_DragSelection);
                GUIUtility.hotControl = 0;
            }
            current.Use();
            break;

        default:
            if (typeForControl != EventType.DragUpdated && typeForControl != EventType.DragPerform)
            {
                if (typeForControl != EventType.ContextClick || !rect.Contains(current.mousePosition) || contextClickItemCallback == null)
                {
                    break;
                }
                contextClickItemCallback(item.id);
                break;
            }
            if (dragging == null || !dragging.DragElement(item, rect, firstItem))
            {
                break;
            }
            GUIUtility.hotControl = 0;
            break;
        }
    }
예제 #3
0
        static Styles()
        {
            GUIContent[] guiContentArray1 = new GUIContent[10];
            int index1 = 0;
            GUIContent guiContent1 = EditorGUIUtilityWrap.TextContent("Center");
            guiContentArray1[index1] = guiContent1;
            int index2 = 1;
            GUIContent guiContent2 = EditorGUIUtilityWrap.TextContent("Top Left");
            guiContentArray1[index2] = guiContent2;
            int index3 = 2;
            GUIContent guiContent3 = EditorGUIUtilityWrap.TextContent("Top");
            guiContentArray1[index3] = guiContent3;
            int index4 = 3;
            GUIContent guiContent4 = EditorGUIUtilityWrap.TextContent("Top Right");
            guiContentArray1[index4] = guiContent4;
            int index5 = 4;
            GUIContent guiContent5 = EditorGUIUtilityWrap.TextContent("Left");
            guiContentArray1[index5] = guiContent5;
            int index6 = 5;
            GUIContent guiContent6 = EditorGUIUtilityWrap.TextContent("Right");
            guiContentArray1[index6] = guiContent6;
            int index7 = 6;
            GUIContent guiContent7 = EditorGUIUtilityWrap.TextContent("Bottom Left");
            guiContentArray1[index7] = guiContent7;
            int index8 = 7;
            GUIContent guiContent8 = EditorGUIUtilityWrap.TextContent("Bottom");
            guiContentArray1[index8] = guiContent8;
            int index9 = 8;
            GUIContent guiContent9 = EditorGUIUtilityWrap.TextContent("Bottom Right");
            guiContentArray1[index9] = guiContent9;
            int index10 = 9;
            GUIContent guiContent10 = EditorGUIUtilityWrap.TextContent("Custom");
            guiContentArray1[index10] = guiContent10;

            Styles.spriteAlignmentOptions = guiContentArray1;
            GUIContent[] guiContentArray2 = new GUIContent[3];
            int index11 = 0;
            GUIContent guiContent11 = EditorGUIUtilityWrap.TextContent("Delete Existing|Delete all existing sprite assets before the slicing operation");
            guiContentArray2[index11] = guiContent11;
            int index12 = 1;
            GUIContent guiContent12 = EditorGUIUtilityWrap.TextContent("Smart|Try to match existing sprite rects to sliced rects from the slicing operation");
            guiContentArray2[index12] = guiContent12;
            int index13 = 2;
            GUIContent guiContent13 = EditorGUIUtilityWrap.TextContent("Safe|Keep existing sprite rects intact");
            guiContentArray2[index13] = guiContent13;
            Styles.slicingMethodOptions = guiContentArray2;
            Styles.methodLabel = EditorGUIUtilityWrap.TextContent("Method");
            Styles.pivotLabel = EditorGUIUtilityWrap.TextContent("Pivot");
            Styles.typeLabel = EditorGUIUtilityWrap.TextContent("Type");
            Styles.sliceButtonLabel = EditorGUIUtilityWrap.TextContent("Slice");
            Styles.columnAndRowLabel = EditorGUIUtilityWrap.TextContent("Column & Row");
            Styles.columnLabel = EditorGUIUtilityWrap.TextContent("C");
            Styles.rowLabel = EditorGUIUtilityWrap.TextContent("R");
            Styles.pixelSizeLabel = EditorGUIUtilityWrap.TextContent("Pixel Size");
            Styles.xLabel = EditorGUIUtilityWrap.TextContent("X");
            Styles.yLabel = EditorGUIUtilityWrap.TextContent("Y");
            Styles.offsetLabel = EditorGUIUtilityWrap.TextContent("Offset");
            Styles.paddingLabel = EditorGUIUtilityWrap.TextContent("Padding");
            Styles.automaticSlicingHintLabel = EditorGUIUtilityWrap.TextContent("To obtain more accurate slicing results, manual slicing is recommended!");
            Styles.customPivotLabel = EditorGUIUtilityWrap.TextContent("Custom Pivot");
        }