Example #1
0
    void Load(SpriteColliderData scd)
    {
        spriteColliderData = scd;

        clipSprites   = SpriteSlicer.GetSpritesFromClip(spriteColliderData.Clip);
        slicedSprites = SpriteSlicer.SliceSprites(clipSprites);

        selectedFrame        = 0;
        selectedColliderData = -1;
        selectedFrameChanged = true;
    }
Example #2
0
    void OnGUI()
    {
        if (!isStyleSetup)
        {
            SetupStyles();
        }

        if (spriteColliderData == null)
        {
            DrawDefaultView();
            return;
        }

        HandleEvent(Event.current);

        using (new GUILayout.VerticalScope())
        {
            using (new GUILayout.VerticalScope(SpriteColliderStyle.Background2Style.Copy().WithHeight(511)))
            {
                DrawSlicer();
            }
            using (new GUILayout.VerticalScope(SpriteColliderStyle.Background1Style))
            {
                using (new GUILayout.HorizontalScope(SpriteColliderStyle.MenuBarStyle))
                {
                    if (spriteColliderData != null)
                    {
                        GUILayout.Label($"{spriteColliderData.Clip.name}", SpriteColliderStyle.MenuHeaderStyle);
                    }
                    else
                    {
                        GUILayout.Label($"SpriteCollider", SpriteColliderStyle.MenuHeaderStyle);
                    }

                    if (GUILayout.Button("Save", SpriteColliderStyle.MenuBarButtonStyle))
                    {
                        Save();
                    }
                    RepaintOnHover();
                    if (GUILayout.Button("Load", SpriteColliderStyle.MenuBarButtonStyle))
                    {
                        Load();
                    }
                    RepaintOnHover();
                    if (GUILayout.Button("Add", SpriteColliderStyle.MenuBarButtonStyle))
                    {
                        ShowAddMenu();
                    }
                    RepaintOnHover();
                    if (GUILayout.Button("Close", SpriteColliderStyle.MenuBarButtonStyle))
                    {
                        Save();
                        spriteColliderData   = null;
                        selectedColliderData = -1;
                        selectedFrame        = 0;
                    }
                    RepaintOnHover();
                }
            }
            using (new GUILayout.VerticalScope(SpriteColliderStyle.Background1Style.Copy().WithHeight(467)))
            {
                using (new GUILayout.VerticalScope(SpriteColliderStyle.Background2Style.Copy().WithHeight(467).WithMargin(0, 5, 5, 5)))
                {
                    DrawEventArea();
                }
            }
        }
    }