I Load Resources with “Resources.Load(“glass”, Texture2D)”
How do I release that Resources,when I don’t use it.
DestroyImmediate(Object,true) is can’t use.because it
Destroy Texture in Asset,it can’t be used again.
Thanks!
Destroy is the correct way.
should you need it again, you have to instantiate it again.
This is my Script.How do I instantiate it when I use it again.Thanks!
This is error information"NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image, ScaleMode scaleMode, Boolean alphaBlend, Single imageAspect) "
private var Test : Texture2D;
function Start () {
Test = Resources.Load(“test”, Texture2D);
}
function Update () {
}
function OnGUI () {
GUI.DrawTexture(Rect(100,100,100,100),Test);
if(GUI.Button(Rect(0,0,50,50),“”)){
DestroyImmediate(Test,true);
}
}
At some point you decide that you need it again, so you load and assign it then again.
Alternatively you don’t destroy it if you need it again