Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

If you enable the set_scale code in the AutoUiImage script, does that do what you're asking for?  I've done some minimal testing and it does work that way, but I'm unsure specifically what issue you're running into.  You can also copy your code here and I can maybe help point you in the right direction.

(3 edits)

set_scale partially works, but seems to only scale the X dimension (while padding elements as if they were unscaled) for my container_h. These are vector images, if that matters.

I'll include my code, but as a warning it's very split up. I'll try and copy all the relevant snippets.
Both attempts (using a manual workaround and using set_scale) are included here. The only difference (aside from the two sections in the first block) is the last line of the first block, which calls uiContainerToElement instead of uiContainerImagesToElements when using set_scale.


        for (var i = 0; i < ds_list_size(_unit.actions); i++){
            var _action = ds_list_find_value(_unit.actions, i);
            var _sprite = _action.iconSprite;
            
            var _element = auto_image(_sprite);
            
            //SET_SCALE IMPLEMENTATION
            _element.set_scale(0.1);
             actionsSubContainer.add(_element);
            
            //MANUAL WORKAROUND IMPLEMENTATION
            /**           
            _element.set_visible(false);
            _element.staticScale = 0.1; //Easiest to toss a new field into the struct for reference later
            
            actionsSubContainer.add(_element);
            actionsSubContainer.add_space(-sprite_get_width(_sprite)*0.9);
            
            array_push(_actionImagesArray, _element);
            **/
        }
        
        actionsSubContainer.step(600*global.uiScale, (_yBase + 50) * global.uiScale);
        
        uiElements = array_concat(uiElements, uiContainerImagesToElements(actionsSubContainer, _actionImagesArray));


function uiContainerImagesToElements(_container, _images){
    
    var _array = [uiContainerToElement(_container)];
    
    for (var i = 0; i < array_length(_images); i++){
        var _subElement = createEmptyUIElement();
        var _imageElement = _images[i];
        
        _subElement.drawFunction = method({_imageElement}, function(_element){
            draw_sprite_ext(_imageElement.get_sprite(), 0, _imageElement.get_bbox_left(), _imageElement.get_bbox_right(), _imageElement.staticScale, _imageElement.staticScale, 0, c_white, 1);
        });
        array_push(_array, _subElement);
    }
    
    return _array;
}


function uiContainerToElement(_container){
    var _element = createEmptyUIElement();
    
    _element.drawFunction = method({_container}, function(_element){
        _container.draw();
    });
    
    return _element;
}


    if (true) {
        for (var i = 0; i < array_length(uiElements); i++){
            uiArray[i].drawFunction(uiElements[i]);
        }
    }

Correction - set_scale works for the y axis as well. I left out the second scale argument, and forgot that GML doesn't throw syntax errors for that sort of thing. Once this was fixed, the padding behaved as expected. Seems to be good for now!

Perfect!  I'll have to see if I can find a reason I commented that out and maybe undo that in the next update :)


Thanks!

Hey, just popping up in this conv, I tried to enable the set_scale code but for some reasons it wont detect it as an existing function, being greyed out when I write it and crashing when called in game for "not set before reading it". Is there something more that needs to be done?

It'll be coming in the next update, but for the time being, just set your image.__private__.xscale and yscale to the scale you want.

Thanks! It actually ended up randomly working after a bit.

But it made me have another question : so I have this sprite of a button that's from my figma design, it has a precise size and all. I would like to create a button that uses this sprite (without nine slice), with hovering and all, but AutoUI seems to automatically resize it. Is there a way I can disable this automatic resizing for buttons? 

It shouldn’t be automatically resizing - are you using “auto_button_sprite”?  That should use the sprites dimensions for the button. If that doesn’t work copy your code for your button and I can take a look. 

Ahhh my bad that's on me for not figuring out this existed. Works perfectly now, thank you :3 

Btw, are you planning on adding controller support for next update?

No current plans.  I'm mulling around rebuilding the entire AutoUI - there are a few things that bother me having used it as much as I have, and that is one of the things I'd love to integrate.