- Home /
Question by
CalUnityUser · Aug 16, 2012 at 02:10 PM ·
texturemateriallostcleanup
Any way to stop texture lookup wiping material from prefab?
I am currently trying to create a prefab based inventory system.
The objects in the inventory GUI will be displayed as the material.maintexture of the prefab in that slot, so if Slot 1 contains object A, the script should look up the prefab that is in Slot 1 (ObjectA) and set the normal.background of the GUI button to the material.maintexture of that prefab.
The code I am using is:
public var m_PlayerObject : GameObject;
public var m_PlayerScriptClone : PlayerScriptJava;
m_PlayerScriptClone = m_PlayerObject.GetComponent(PlayerScriptJava) as PlayerScriptJava; //assigns clone of playerscript, where the inventory slots are located
public var m_SlotA : GUIStyle;
m_SlotA.normal.background = m_PlayerScriptClone.m_SlotAPrefab.renderer.material.mainTexture as Texture2D;
This works, but when I stop the game playing, it will 'cleanup' the material off the prefab assigned to m_SlotAPrefab. So when I play the game again, all materials which were previously looked up have now been taken off the prefabs. Is there any way to stop this?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613075743im_/https://answers.unity.com/themes/thub/images/avi.jpg)