/* * Loads an Object * 'i' is the number of the object we are loading. */ private void LoadObject(int i, string file) { int uniqueID = ES2.Load <int>(file + "?tag=uniqueID" + i); string prefabName = ES2.Load <string>(file + "?tag=prefabName" + i); // Create or get an object based on our loaded id and prefabName GameObject loadObject; // If our prefab name is blank, we're loading a scene object. if (prefabName == "") { loadObject = UniqueID.FindTransform(uniqueID).gameObject; } else { loadObject = UniqueObjectManager.InstantiatePrefab(prefabName); } Transform t = loadObject.GetComponent <Transform>(); if (t != null) { // Auto-assigning Load is the best way to load Components. ES2.Load <Transform>(file + "?tag=transform" + i, t); // Now we'll get the parent object, if any. int parentuID = ES2.Load <int>(file + "?tag=parentID" + i); Transform parent = UniqueID.FindTransform(parentuID); if (parent != null) { t.parent = parent; } } }