Пример #1
0
        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);
        }
Пример #2
0
 private void ObjectPool_CreatingObject(object sender,
                                        CreatingObjectEventArgs e)
 {
     e.Data = LoadFromPool(e.SubTag);
 }
Пример #3
0
 protected virtual void OnCreatingObject(CreatingObjectEventArgs e)
 {
     CreatingObject?.Invoke(this, e);
 }