Closed
Description
ArmorPaint 1.0 alpha-6246a99, Windows
Issue description:
Looking for some solid documentation on scripts and plugins so I can create something. I've been attempting all sorts using the hello_world example. And whilst I can get a nice UI there is no functionality because my code doesn't work.
Steps to reproduce:
My code to try and add Layers and Groups from a template quickly:
let plugin = new arm.Plugin();
let handle1 = new zui.Handle();
// Function to create and add layers
function addTemplatedLayers() {
let project = arm.Project.get();
if (project) {
console.log("Project found.");
// Create a new group layer
let groupLayer = new arm.Layer();
groupLayer.name = "New Group";
groupLayer.setType(arm.LayerType.Group);
groupLayer.init();
// Create new paint layers
let paintLayer = new arm.Layer();
paintLayer.name = "Paint Layer";
paintLayer.setType(arm.LayerType.Paint);
paintLayer.init();
let fillLayer = new arm.Layer();
fillLayer.name = "Fill Layer";
fillLayer.setType(arm.LayerType.Fill);
fillLayer.init();
let decalLayer = new arm.Layer();
decalLayer.name = "Decal Layer";
decalLayer.setType(arm.LayerType.Decal);
decalLayer.init();
// Add layers to the group
groupLayer.children.push(paintLayer);
groupLayer.children.push(fillLayer);
groupLayer.children.push(decalLayer);
console.log("Added layers to the group.");
// Add the group to the project's root layer
project.layerRoot.addChild(groupLayer);
console.log("Added group to the project's root layer.");
// Update the project and UI to reflect changes
project.layerRoot.updateChildren();
arm.UI.refresh();
console.log("Updated project and UI.");
} else {
console.error("No project found.");
}
}
plugin.drawUI = function(ui) {
if (ui.panel(handle1, "Add Templated Layers Plugin")) {
if (ui.button("Add Templated Layers")) {
addTemplatedLayers();
}
}
}