droptimal

I'm using the script to export from AI to Spine and whenever I import assets, they tend to shift around a bit. I don't see any detailed documentation on use of the script and I know it's VERY fussy about certain assets (often not even rendering a json if something is wrong). Is there a best practices guide to trouble shoot this? I find I'm always repositioning my assets with a reference image.
droptimal
  • Сообщения: 19

Erikari

The little shifting you experience might be caused by the assets getting rasterized at small sizes and the approximation caused by the pixels. If you export at higher resolution the shift should be minimized. While working at too high resolutions in Spine may not be ideal, having double the resolution of the in-game assets, exported from Spine at half the resolution is fairly common.

You can find the instructions of the script here: spine-scripts/illustrator at master · EsotericSoftware/spine-scripts

If you decide you want very precise placing and prefer rescaling the assets so that Spine calculates where the images should be placed after importing them, you could also follow this procedure to resize the skeleton in a second moment: how to properly resize your project?
Аватара пользователя
Erikari

Erikari
  • Сообщения: 2009

droptimal

The assets are already double size. We're taking 2560x1440 AI files and reducing them in Spine. Some assets in it jump wildly in certain directions and others are perfectly fine. A layer could be over 100 pixels off position.

I've also read those instructions, but they don't cover how your AI layers need to be setup. There's many times the way a layer is setup doesn't agree with the export script and will result in no png being made for that layer or the json wont render is one of them is wrong. There's no debug or Dos and Dont's guide to specify what causes this, so it's become trial and error (flattening layers, expanding, not using certain objects, etc...). I'm betting some setup in my AI layers is what results in the positioning errors.
droptimal
  • Сообщения: 19

nimbling

FYI: if you use clipping masks in AI - the extents of the asset you export will be of all the artwork in that asset, which INCLUDES the boundaries of the CLIPPED art. In other words: the stuff you hid using the clipping mask is still used to determine the asset's size for export. FML, I know.

To fix it I just flatten the assets using this script:
This script assumes you have a single object being a clipping mask selected.
#target Illustrator
#targetengine main

// script.name = Unclip.jsx;
// script.parent = Herman van Boeijen, www.nimbling.com // 28-01-2019;
// Big thanks to CarlosCanto and MuppetMark on the Adobe Illustrator Scripting Forums
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function Main(curDoc, sel, amountofselectedobjects, clipobject){
if (amountofselectedobjects){
if(curDoc.activeLayer.locked || !curDoc.activeLayer.visible){
alert("Please select objects on an unlocked and visible layer,\nthen run this script again.");
}else{
app.executeMenuCommand('ungroup');
app.executeMenuCommand('copy');
app.executeMenuCommand('Live Pathfinder Crop');
app.executeMenuCommand('expandStyle');
app.executeMenuCommand('ungroup');
app.executeMenuCommand('pasteBack');
app.executeMenuCommand('releaseMask');
sel = curDoc.selection;
amountofselectedobjects = sel.length;
app.executeMenuCommand('deselectall');
for (i = 1; i < amountofselectedobjects ; i++) {
killobject = sel[i];
killobject.remove();
}
}
}
}

//INIT, Is there a document open?
if ( app.documents.length > 0 ) {
var curDoc = app.activeDocument;
}else{
Window.alert("You must open at least one document.");
}

var sel = curDoc.selection; // get selection
var origsel = curDoc.selection;
var amountofselectedobjects = sel.length;
var clipobject = sel[amountofselectedobjects -1]; // BOTTOM OBJECT
var clipcolors = [];

Main(curDoc, sel, amountofselectedobjects, clipobject);
Standard disclaimer: if your computer ends up as a burning ball of flames, it's on you for not checking the script, not on me for trying to help.

If you use blurs or other pixel effects, also have a look at your rasterization settings, and the "margin" or something it adds around those effects.
Аватара пользователя
nimbling
  • Сообщения: 163


Вернуться в Bugs