// todo figure out a way to call messages on all objects... // so we can get actorstate.GameValue("Health") for instance... public static ObjectLoadState AddNewObject(PrefabReference prefabRef, string scene, Vector3 pos, Quaternion rot, bool permanent, out object obj, out string id) { bool sceneIsLoaded = SceneLoading.currentLoadedScenes.Contains(scene); id = GetNewGUID(); DynamicObjectState objectState = new DynamicObjectState(id, scene, prefabRef, permanent); id2ObjectState.Add(id, objectState); if (sceneIsLoaded) { DynamicObject dynamicObject = GetAvailableInstance(prefabRef, pos, rot, id, false, false, false); MoveDynamicObjectToTransform(dynamicObject, pos, rot.eulerAngles, false); dynamicObject.AdjustState(objectState, scene, pos, rot.eulerAngles, false); obj = dynamicObject; } // add an unloaded representation, instantiate later when the scene is loaded else { if (!prefabRef.isEmpty) { DynamicObject basePrefab = PrefabReferenceCollection.GetPrefabReference <DynamicObject>(prefabRef); obj = basePrefab.AdjustState(objectState, scene, pos, rot.eulerAngles, true); } else { obj = objectState; } } return(objectState.isLoaded ? ObjectLoadState.Loaded : ObjectLoadState.Unloaded); }
public static GameObject GetPrefabReference(PrefabReference refInfo) { PrefabReferenceCollection obj = GameSettings.GetSettings <PrefabReferenceCollection>(refInfo.collection); if (obj != null) { return(obj.GetPrefabReference(refInfo.name)); } return(null); }
public static T GetPrefabReference <T> (PrefabReference refInfo) where T : Component { PrefabReferenceCollection obj = GameSettings.GetSettings <PrefabReferenceCollection>(refInfo.collection); if (obj != null) { return(obj.GetPrefabReference <T>(refInfo.name)); } return(null); }
void Start() { if (_isPlayer) { return; } if (isInPool) { return; } Debug.Log("Adding to pool: " + name); DynamicObjectManager.pool.AddManualInstance(PrefabReferenceCollection.GetPrefabReference <DynamicObject>(prefabRef), this, onPoolCreateAction); }
public static T GetAvailableInstance <T> (PrefabReference prefabRef, Vector3 position, Quaternion rotation, string gUID, bool createState, bool createID, bool permanentState) where T : Component { return(GetAvailableInstance <T>(PrefabReferenceCollection.GetPrefabReference <DynamicObject>(prefabRef), position, rotation, gUID, createState, createID, permanentState)); }