# Change model texture in runtime (SOLVED)

**URL:** <https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764>\
**Category:** Feature requests (USE GITHUB)\
**Created:** [February 12, 2018, 12:55pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764 "2018-02-12T12:55:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [February 12, 2018, 12:55pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/1 "2018-02-12T12:55:06Z")

</div>

Add some way to change model texture in runtime. To make something like skins or animated textures.

> [@Change model texture in runtime?](https://forum.defold.com/t/change-model-texture-in-runtime/10952):
>
> Can i change a texture of model in runtime?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [February 12, 2018, 1:11pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/2 "2018-02-12T13:11:30Z")

</div>

I think this is coming _soon_ based on mentions of being able to dynamically change textures and materials at runtime.

---

<div class="post-metadata">

**Author:** ![splashshadow](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/splashshadow/32/2374_2.png) [@splashshadow](https://forum.defold.com/u/splashshadow)\
**Post date:** [February 13, 2018, 6:33pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/3 "2018-02-13T18:33:39Z")

</div>

I am waiting too for this feature …

---

<div class="post-metadata">

**Author:** ![sergey.lerg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sergey.lerg/32/3970_2.png) [@sergey.lerg](https://forum.defold.com/u/sergey.lerg)\
**Post date:** [January 23, 2019, 8:53pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/4 "2019-01-23T20:53:26Z")

</div>

@britzl just got this issue in my project. I am downloading many png images from a server and I need to display them on the screen. I am using model component with a quad mesh. When I load an image and set it as a texture for one object on the screen, all objects get this image.  
Is it still impossible to create a new separate resource for a model and load it with downloaded data?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [January 23, 2019, 9:01pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/5 "2019-01-23T21:01:25Z")

</div>

What are the images/how are they being used?

---

<div class="post-metadata">

**Author:** ![sergey.lerg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sergey.lerg/32/3970_2.png) [@sergey.lerg](https://forum.defold.com/u/sergey.lerg)\
**Post date:** [January 23, 2019, 9:03pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/6 "2019-01-23T21:03:58Z")

</div>

Images are PNG icons for some sort of a catalog. I create a list view of items with a name label and an icon. Game objects are created with factory.create(), so they share the resource. I want to change the texture resource individually, but they change altogether.

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [January 23, 2019, 9:09pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/7 "2019-01-23T21:09:58Z")

</div>

You can try gui.new\_texture. I don’t use it, but looks like it can change texture in runtime. Model still can’t change texture. [PNG file save (SOLVED) - #6 by HG17](https://forum.defold.com/t/png-file-save-solved/12005/6)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [January 23, 2019, 9:37pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/8 "2019-01-23T21:37:22Z")

</div>

Are the sizes of the images consistent? [GitHub - subsoap/imagebatch: Download images and put them into a single texture to reduce drawcalls in Defold · GitHub](https://github.com/subsoap/imagebatch) might help as a starting point possibly.

---

<div class="post-metadata">

**Author:** ![sergey.lerg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sergey.lerg/32/3970_2.png) [@sergey.lerg](https://forum.defold.com/u/sergey.lerg)\
**Post date:** [January 24, 2019, 5:31am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/9 "2019-01-24T05:31:56Z")

</div>

Good stuff, but still won’t solve the issue entirely.

---

<div class="post-metadata">

**Author:** ![sergey.lerg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sergey.lerg/32/3970_2.png) [@sergey.lerg](https://forum.defold.com/u/sergey.lerg)\
**Post date:** [January 24, 2019, 5:32am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/10 "2019-01-24T05:32:45Z")

</div>

Hm. Any way to use gui texture in the game object world?

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [January 24, 2019, 7:05am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/11 "2019-01-24T07:05:11Z")

</div>

Transfer world coord to gui coords every frame, to update gui pos. Or create and attach gui to go. Not good way but no normal way, for changing texture.

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [January 24, 2019, 9:27am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/12 "2019-01-24T09:27:48Z")

</div>

I think it must have feature for engine. Plz add it. @sven @britzl

---

<div class="post-metadata">

**Author:** ![BunBunBun](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/bunbunbun/32/25691_2.png) [@BunBunBun](https://forum.defold.com/u/BunBunBun)\
**Post date:** [January 24, 2019, 9:33am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/13 "2019-01-24T09:33:35Z")

</div>

that’s necessary feature.

---

<div class="post-metadata">

**Author:** ![Mattias\_Hedberg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mattias_hedberg/32/433_2.png) [@Mattias\_Hedberg](https://forum.defold.com/u/Mattias_Hedberg)\
**Post date:** [January 24, 2019, 10:44am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/14 "2019-01-24T10:44:15Z")

</div>

> Hm. Any way to use gui texture in the game object world?

Not an expert but I do think you should be able to kinda do it with some workarounds.

1. Copy the GUI material from the builtins folder and changed the tag to `tile`. This will make it move with the camera (will be rendered in worldspace), but the positions changes from a parent go will not propegate to the gui. Therefore:
2. Create a script that tracks the delta position of the go and send that to the gui. This isn’t free because you would have to send a message to the gui each frame.

`parent_gui.script`

```
local position

function init(self)
	position = go.get_position()
	self.action = {x=position.x, y=position.y, dx=0, dy=0}
end

function update(self, dt)
	position = go.get_position()
	self.action.dx = self.action.x - position.x
	self.action.dy = self.action.y - position.y

	self.action.x = position.x
	self.action.y = position.y
	
	msg.post(".", "parent_update", self.action)
end

```

`world_gui.gui_script`

```
function init(self)
	self.root = gui.get_node("root")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("parent_update") then
		local p = gui.get_position(self.root)
		p.x = p.x - message.dx
		p.y = p.y - message.dy
		gui.set_position(self.root, p)
	end
end

```

Collection Setup

 ![09](https://forum-defold-uploads.b-cdn.net/original/2X/4/4965f60270eb2a274f840196547d0a4dc408d407.png)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [February 27, 2020, 4:35pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/15 "2020-02-27T16:35:11Z")

</div>

> [@Pkeod](#):
>
> I think this is coming _soon_ based on mentions of being able to dynamically change textures and materials at runtime.

Is changing individual model textures at runtime still in the backlog?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [February 27, 2020, 4:47pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/16 "2020-02-27T16:47:09Z")

</div>

It may be possible now with the resources update but that is something I have not gotten around to testing.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 28, 2020, 6:25am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/17 "2020-02-28T06:25:33Z")

</div>

> [@totebo](#):
>
> Is changing individual model textures at runtime still in the backlog?

You can use resource properties to change texture: [Script component properties](https://defold.com/manuals/script-properties/#resource-properties)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [February 28, 2020, 7:35am UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/18 "2020-02-28T07:35:12Z")

</div>

Amazing, thanks!

---

<div class="post-metadata">

**Author:** ![dlannan](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dlannan/32/39440_2.png) [@dlannan](https://forum.defold.com/u/dlannan)\
**Post date:** [March 30, 2021, 12:56pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/19 "2021-03-30T12:56:02Z")

</div>

Is it possible to change the texture of a material at runtime?  
(or is this a new question?)

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [March 30, 2021, 1:38pm UTC](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764/20 "2021-03-30T13:38:44Z")

</div>

You can set the material of a model, or the individual textures of a model

[Next page](https://forum.defold.com/t/change-model-texture-in-runtime-solved/16764.md?page=2)
