コード例 #1
0
    public void OnGUI()
    {
        for (int i = 0; i < 4; i++)
        {
            dragNDrop.DropAreaBegin("A" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("A" + i);


            dragNDrop.DropAreaBegin("B" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("B" + i);


            dragNDrop.DropAreaBegin("C" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("C" + i);
        }

        dragNDrop.DropAreaBegin("D");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("D");

        dragNDrop.DropAreaBegin("inner1");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("inner1");

        dragNDrop.DropAreaBegin("inner2");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("inner2");


        foreach (String stri in strings)
        {
            dragNDrop.DragObjectBegin(stri);
            CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
            GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, stri.ToString());
            GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
            dragNDrop.DragObjectEnd(stri);
        }



        foreach (object obj in objects)
        {
            dragNDrop.DragObjectBegin(obj);

            if (dragNDrop.CurrentDragObject.IsDragging)
            {
                Rect drawRect = dragNDrop.CurrentDragObject.CurrentRect;
                drawRect.width = drawRect.height = 50;
                drawRect.x     = InputHelpers.MouseOnGUI().x - drawRect.width / 2;
                drawRect.y     = InputHelpers.MouseOnGUI().y - drawRect.height / 2;
                GUI.DrawTexture(drawRect, DefaultIconSet.Device);
            }
            else
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, obj.ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
            }



            dragNDrop.DragObjectEnd(obj);
        }


        //foreach (DropArea dropArea in dragNDrop.dropAreas.Values)
        //{
        //    if (dropArea.Object != null)
        //    {
        //        if (dropArea.Object.GetType() == typeof(A))
        //        {
        //            A readA = dropArea.GetObject<A>();
        //            Debug.Log("A gelesen: " + readA.ToString());
        //        }
        //    }
        //}
    }
コード例 #2
0
    public void OnGUI()
    {
        if (dragNDrop.DropAreaBegin("outer"))
        {
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("outer");
        }

        if (dragNDrop.DropAreaBegin("outer2"))
        {
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("outer2");
        }

        if (dragNDrop.DragObjectBegin(strings[0]))
        {
            CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
            GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[0].ToString());
            GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);

            // DropAreas
            if (dragNDrop.DropAreaBegin("inner1"))
            {
                Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                drawRect.x     += 10;
                drawRect.y     += 10;
                drawRect.width  = 130;
                drawRect.height = 150;

                dragNDrop.ThisDropArea.Rect = drawRect;
                CustomGUIUtils.DrawBox(drawRect, XKCDColors.LightRed);
                GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString());
                dragNDrop.DropAreaEnd("inner1");
            }

            if (dragNDrop.DropAreaBegin("inner2"))
            {
                Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                drawRect.x     += 10;
                drawRect.y     += 210;
                drawRect.width  = 130;
                drawRect.height = 150;

                dragNDrop.ThisDropArea.Rect = drawRect;
                CustomGUIUtils.DrawBox(drawRect, XKCDColors.GreenApple);
                GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString());
                dragNDrop.DropAreaEnd("inner2");
            }


            // DragObjects
            if (dragNDrop.DragObjectBegin(strings[1]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[1].ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(strings[1]);
            }

            if (dragNDrop.DragObjectBegin(strings[2]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[2].ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(strings[2]);
            }


            dragNDrop.DragObjectEnd(strings[0]);
        }


        //foreach (DropArea dropArea in dragNDrop.dropAreas.Values)
        //{
        //    if (dropArea.Object != null)
        //    {
        //        if (dropArea.Object.GetType() == typeof(A))
        //        {
        //            A readA = dropArea.GetObject<A>();
        //            Debug.Log("A gelesen: " + readA.ToString());
        //        }
        //    }
        //}
    }
コード例 #3
0
    public void OnGUI()
    {
        GUI.Label(new Rect(boxWidth + 50, 0, 500, 500), "Dragging String = " + draggingString + "\n strings.Count " + strings.Count + "\n" + strings.ListToString <String>());

        accumulatedHeight = gap;

        // Draw DropAreas
        for (int i = 0; i < strings.Count; i++)
        {
            if (dragNDrop.DropAreaBegin(i.ToString()))
            {
                CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Orangeish);
                //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                GUI.Label(dragNDrop.ThisDropArea.Rect, "   " + i);

                dragNDrop.ThisDropArea.Rect = new Rect(gap, accumulatedHeight, boxWidth, boxHeight);
                accumulatedHeight          += gap + boxHeight;

                dragNDrop.SetObject(i.ToString(), strings[i]);
                dragNDrop.DropAreaEnd(i.ToString());
            }
        }


        accumulatedHeight = gap;
        List <String> concurrentStrings = new List <string>(strings);
        int           currentItem       = 0;

        foreach (String str in concurrentStrings)
        {
            DragObject currentstr = dragNDrop.TryGetDragObject(str);

            int i = concurrentStrings.IndexOf(str);

            if (currentstr.IsDragging)
            {
                draggingStringOldIndex = i;
                draggingString         = strings[i];
                strings.RemoveAt(i);
                Debug.Log("Dragging String = " + draggingString + "\n" + strings.ListToString <String>());
            }
            if (dragNDrop.DragObjectBegin(concurrentStrings[i]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, concurrentStrings[i].ToString());

                Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                icon.width = icon.height;
                GUI.DrawTexture(icon, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(concurrentStrings[i]);
            }

            currentItem++;
        }


        if (draggingString != null)
        {
            for (int i = 0; i < strings.Count; i++)
            {
                DropArea dropArea;
                if (dragNDrop.dropAreas.TryGetValue(i.ToString(), out dropArea))
                {
                    dragNDrop.TryCreateDropArea("before" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray());
                    dragNDrop.TryCreateDropArea("after" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y + dropArea.Rect.height / 2f, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray());

                    if (dragNDrop.DropAreaBegin("before" + i))
                    {
                        if (dragNDrop.ThisDropArea.ContainsMouse())
                        {
                            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                            //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                            GUI.Label(dragNDrop.ThisDropArea.Rect, "before   " + i);
                        }
                        dragNDrop.DropAreaEnd("before" + i);
                    }

                    if (dragNDrop.DropAreaBegin("after" + i))
                    {
                        //CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                        ////GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                        //GUI.Label(dragNDrop.ThisDropArea.Rect, "after   " + i);
                        if (dragNDrop.ThisDropArea.ContainsMouse())
                        {
                            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                            //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                            GUI.Label(dragNDrop.ThisDropArea.Rect, "after   " + i);
                        }
                        dragNDrop.DropAreaEnd("after" + i);
                    }
                }
            }


            bool newDropArea = false;
            if (dragNDrop.DragObjectBegin(draggingString))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, draggingString.ToString());

                Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                icon.width = icon.height;
                GUI.DrawTexture(icon, DefaultIconSet.Device);
                newDropArea = dragNDrop.DragObjectEnd(draggingString);
            }

            //if (newDropArea)
            //{

            //}

            DragObject currentstr = dragNDrop.TryGetDragObject(draggingString);
            if (!currentstr.IsDragging)
            {
                Debug.Log(currentstr.DropArea.Id);
                if (currentstr.DropArea.Id.StartsWith("before") || currentstr.DropArea.Id.StartsWith("after"))
                {
                    if (currentstr.DropArea.Id.StartsWith("before"))
                    {
                        int newIndex = int.Parse(currentstr.DropArea.Id.Replace("before", ""));
                        strings.Insert(newIndex, draggingString);
                    }
                    else if (currentstr.DropArea.Id.StartsWith("after"))
                    {
                        int newIndex = int.Parse(currentstr.DropArea.Id.Replace("after", "")) + 1;
                        strings.Insert(newIndex, draggingString);
                        currentstr.t           = 0f;
                        currentstr.Ease        = true;
                        currentstr.EaseEndRect = dragNDrop.dropAreas[newIndex.ToString()].Rect;
                    }
                }
                else
                {
                    //strings.Capacity += 1;
                    Debug.Log("old Index" + draggingStringOldIndex);
                    strings.Insert(draggingStringOldIndex, draggingString);
                }
                draggingString         = null;
                draggingStringOldIndex = -1;
            }
        }
    }
コード例 #4
0
    public void OnGUI()
    {
        if (dragNDrop.DropAreaBegin("outer"))
        {
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("outer");
        }

        if (dragNDrop.DropAreaBegin("outer2"))
        {
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, color);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            if (dragNDrop.ThisDropArea.ContainsMouse() && InputHelpers.ClickedLeft())
            {
                color = XKCDColors.Blue;
            }

            if (color == XKCDColors.Blue)
            {
                dragNDrop.ThisDropArea.Rect = EasingCurves.EaseRect(
                    "outer2",
                    dragNDrop.ThisDropArea.Rect,
                    new Rect(dragNDrop.ThisDropArea.Rect).AddOffset(new Rect(-100, -100, -200, -200)),
                    EasingCurves.EaseType.easeOutElastic);
            }
            dragNDrop.DropAreaEnd("outer2");
        }

        if (dragNDrop.DragObjectBegin(strings[0]))
        {
            CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
            GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[0].ToString());
            GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);

            // DropAreas
            if (dragNDrop.DropAreaBegin("inner1"))
            {
                Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                drawRect.x     += 10;
                drawRect.y     += 10;
                drawRect.width  = 130;
                drawRect.height = 150;

                dragNDrop.ThisDropArea.Rect = drawRect;
                CustomGUIUtils.DrawBox(drawRect, XKCDColors.LightRed);
                GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString());
                dragNDrop.DropAreaEnd("inner1");
            }

            if (dragNDrop.DropAreaBegin("inner2"))
            {
                Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                drawRect.x     += 10;
                drawRect.y     += 210;
                drawRect.width  = 130;
                drawRect.height = 150;

                dragNDrop.ThisDropArea.Rect = drawRect;
                CustomGUIUtils.DrawBox(drawRect, XKCDColors.GreenApple);
                GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString());
                dragNDrop.DropAreaEnd("inner2");
            }


            // DragObjects
            if (dragNDrop.DragObjectBegin(strings[1]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[1].ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(strings[1]);
            }

            if (dragNDrop.DragObjectBegin(strings[2]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[2].ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(strings[2]);
            }


            dragNDrop.DragObjectEnd(strings[0]);
        }


        //foreach (DropArea dropArea in dragNDrop.dropAreas.Values)
        //{
        //    if (dropArea.Object != null)
        //    {
        //        if (dropArea.Object.GetType() == typeof(A))
        //        {
        //            A readA = dropArea.GetObject<A>();
        //            Debug.Log("A gelesen: " + readA.ToString());
        //        }
        //    }
        //}
    }