Class Destructor

I’m wandering if this LoadItemc = null; is good destructor for class

I’m wandering if unity really stops following that class

I was searching for delete destroy kill but nothing seem to destroy my class

is there any better destructor as I saw in editor mode that item still had class there but everything inside it was null

Script on item

using UnityEngine;
using System.Collections;

public class PickUpObject : MonoBehaviour {
public string ItemName = "" ;
public LoadItemC LoadItemc ;
void Start () {
	LoadItemc = new LoadItemC(ItemName) ;
	ItemPrefab = LoadItemc.ItemPrefab;
	LoadItemc = null;
}

Class

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]

public class LoadItemC {
	public GameObject ItemPrefab ;
	public LoadItemC(string Name){
		if 		(Name == "Hatchet")	{ItemPrefab = Resources.Load("Hatchet") as GameObject ;}
	}
}

yeah I know I could call function but I don’t want to write 50 same type functions for same stuff in different scripts

When your setting the variable to null then Unity will eventually throw that instance of the object out with the garbage Collection (read more about that here).

However I think your much better of having the ItemPrefab attached to your PickupObject class instead like below. This gives you the same functionality of your LoadItemC class without having to create a new class just to load a prefab.

public class PickUpObject : MonoBehaviour {

public string ItemName;
public GameObject ItemPrefab;

    void Start () {
        ItemPrefab = Resources.Load(ItemName) as GameObject;
    }

}

use DestoryImmediate(GameObject), that will call the desturctor after everything was cleaned.

instead you can use Destory(GameObject), will delete the object after Update() was called