Exemplo n.º 1
0
    public void DisplayOptions(FaceBuilder.FaceSlot slot, SlotsPanel.SlotOptions options)
    {
        title.text = slot.name;

        var children = new List <GameObject>();

        foreach (Transform child in optionPanel.transform)
        {
            children.Add(child.gameObject);
        }
        children.ForEach(child => Destroy(child));

        AddLabel("Style");
        GameObject optionsGrid = AddGrid(new GameObject[0]);

        foreach (Sprite sprite in faceBuilder.elementOptions[slot.name])
        {
            // Set up controls for options
            AddButton(optionsGrid, sprite, () =>
            {
                faceBuilder.currentFace.UpdateSprite(slot, sprite);
                DisplayOptions(slot, options);
            }, 1f, faceBuilder.currentFace.faceElements[slot.name].getCurrentTint());
        }

        RenderOptions(slot, options);

        LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)optionPanel.transform);
    }
Exemplo n.º 2
0
    public void RenderOptions(FaceBuilder.FaceSlot slot, SlotsPanel.SlotOptions options)
    {
        if (options.adjustHorizontalPosition)
        {
            AddLabel("Horizontal Position");
            AddSlider(slot.defaultOffset.x, slot.minOffset.x, slot.maxOffset.x, x => faceBuilder.currentFace.UpdateHorizontalOffset(slot, x));
        }

        if (options.adjustVerticalPosition)
        {
            AddLabel("Vertical Position");
            AddSlider(slot.defaultOffset.y, slot.minOffset.y, slot.maxOffset.y, y => faceBuilder.currentFace.UpdateVerticalOffset(slot, y));
        }

        if (options.scales != null && options.scales.Length > 0)
        {
            AddLabel("Size");
            GameObject scaleGrid = AddGrid(new GameObject[0]);
            foreach (float scale in options.scales)
            {
                AddButton(
                    scaleGrid,
                    faceBuilder.currentFace.faceElements[slot.name].getCurrentSprite(),
                    () => faceBuilder.currentFace.UpdateScale(slot, scale),
                    scale,
                    Color.white);
            }
        }

        if (options.tints != null && options.tints.Length > 0)
        {
            AddLabel("Tint");
            GameObject tintGrid = AddGrid(new GameObject[0]);
            foreach (Color tint in options.tints)
            {
                AddButton(
                    tintGrid,
                    faceBuilder.currentFace.faceElements[slot.name].getCurrentSprite(),
                    () =>
                {
                    faceBuilder.currentFace.UpdateTint(slot, tint);
                    DisplayOptions(slot, options);
                },
                    1f,
                    tint);
            }
        }
    }