I found a way to play GIFs by using a link to it, i have a button that spawns the GIF in game and a text box, to put the URL, i would like to change the GIF script’s URL string value, for what is in my textbox, that people can write on in-game, could someone help me with this pls?
Script that instantiates the GIF
var ButtonInstantiateRequest = pc.createScript('buttonInstantiateRequest');
ButtonInstantiateRequest.attributes.add('templateToInstantiate', {
type: 'asset',
assetType: 'template',
title: 'TemplateToInstantiate'
});
ButtonInstantiateRequest.attributes.add('gifText', {
type: 'entity',
assetType: 'entity',
title: 'GIF Text',
});
// initialize code called once per entity
ButtonInstantiateRequest.prototype.initialize = function() {
this.entity.button.on('click', this.spawnInstanceRequest, this);
};
ButtonInstantiateRequest.prototype.spawnInstanceRequest = function(){
console.log("Instantiate Request (" + this.templateToInstantiate.name + ")");
this.app.fire('buttonInstantiateRequest:request', this.templateToInstantiate);
if (this.templateToInstantiate && this.templateToInstantiate.resource) {
var objString = this.templateToInstantiate.resource.objString;
var propString = objString.propString;
var novaString = propString.replace(/[^/]+$/, this.gifText);
objString.propString = novaString;
} else {
console.error("O objeto templateToInstantiate não está definido corretamente.");
}
};
the GIF is a template, with a Plane child object inside, the plane has the “gifTexture” script, the url string variable is called “gifUrl”