public static void Create(string prefabName, Vector3 position, string text) { if (popupCache == null) { popupCache = new Dictionary <string, GameObject>(); } if (!popupCache.ContainsKey(prefabName)) { Object obj = Resources.Load(prefabName); if (obj != null) { popupCache.Add(prefabName, (GameObject)obj); } else { Debug.LogError("Não foi possivel achar o prefab correspondente ao TextPopup: " + prefabName); } } GameObject newPopup = UniversalObjectPooling.PooledInstantiate(popupCache[prefabName], position, Quaternion.identity); Text newText = newPopup.transform.GetChild(0).GetComponent <Text>(); newText.text = text; }
// Use this for initialization void OnEnable() { // print("START"); UniversalObjectPooling.DesativateObjectAfterSeconds(gameObject, seconds); if (fadeOut != 0f) { var sr = GetComponent <SpriteRenderer>(); if (sr != null) { sr.StopFades(); sr.color = Color.white; this.StopAllCoroutines(); this.DelayedCall(() => sr.FadeOut(fadeOut), seconds - fadeOut); } } }
// Use this for initialization void Start() { log = _log; instance = this; pooledObjects = new Dictionary <GameObject, PoolData>(); desactivateObjectsSchedule = new Dictionary <GameObject, float>(); for (int i = 0; i < ToPool.Length; i++) { List <GameObject> objs = new List <GameObject>(); for (int ib = 0; ib < ToPool[i].Quantity; ib++) { var obj = (GameObject)Instantiate(ToPool[i].Prefab, Vector3.left * 100f, Quaternion.identity); obj.name = ToPool[i].Prefab.name + " pool " + ib; obj.SetActive(false); objs.Add(obj); } pooledObjects.Add(ToPool[i].Prefab, new PoolData(objs.ToArray())); } }
public static void Create(GameObject prefab, Vector3 position, string text) { GameObject newPopup = UniversalObjectPooling.PooledInstantiate(prefab, position, Quaternion.identity); newPopup.GetComponentInChildren <Text>().text = text; }