public GameObject Create(IPrototype proto) { var objFromPool = new CreatingObjectEventArgs(proto); OnCreatingObject(objFromPool); GameObject go = objFromPool.Data; if (go == null) { go = Instantiate(Resources.Load(proto.SubTag.ToString()) as GameObject); go.AddComponent <MetaInfo>().SetValue(proto); // Puslish an event to add specific components when necessary. OnAddingComponent(new AddingComponentEventArgs(go)); } else { go.SetActive(true); // TODO: Puslish an event to reset object data. } go.transform.position = GetComponent <ConvertCoordinate>().Convert( proto.Position); OnCreatedObject(new CreatedObjectEventArgs(go)); return(go); }
private void ObjectPool_CreatingObject(object sender, CreatingObjectEventArgs e) { e.Data = LoadFromPool(e.SubTag); }
protected virtual void OnCreatingObject(CreatingObjectEventArgs e) { CreatingObject?.Invoke(this, e); }