// Use this for initialization void Start() { //根据绝对路径设置与获取数据 ObjectPoolComponent poolComponent = GameEntry.GetComponent <ObjectPoolComponent>(); m_HPBarItemObjectPool = poolComponent.CreateSingleSpawnObjectPool <HPBarItemObject>("HPBarItem", 10); //HPBarItem hpBarItem = Instantiate(m_HPBarItemTemplate); //Transform transform = hpBarItem.GetComponent<Transform>(); //transform.SetParent(m_HPBarInstanceRoot); //transform.localScale = Vector3.one; //m_HPBarItemObjectPool.Register(HPBarItemObject.Create(null), true); }
private void Start() { m_ObjectPoolComponent = GameBox.GetComponent <ObjectPoolComponent>(); m_IObjectPoo01 = m_ObjectPoolComponent.CreateSingleSpawnObjectPool <OPDemo>("对象池01"); m_IObjectPoo02 = m_ObjectPoolComponent.CreateSingleSpawnObjectPool <OPDemo>("对象池02", 10, 1); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false); m_IObjectPoo02.Register(new OPDemo("对象池02_对象2", m_Target), false); m_Target = GameObject.Instantiate(m_Target); m_Target.Register <OPDemo>("对象池03_对象1", "对象1"); m_Target = GameObject.Instantiate(m_Target); m_Target.Register <OPDemo>("对象池03_对象1", "对象1"); gameObject.Register <OPDemo>("对象池04_对象1", "对象1"); }
public void SetTimeActionPool(string objectName, float autoReleaseInterval, float expireTime, int capacity) { ObjectPoolComponent m_ObjectPoolManager = CentorPivot.This.GetComponent <ObjectPoolComponent>(); if (m_ObjectPoolManager == null) { throw new Exception("ObjectPool Component is invalid."); } m_TimeActionObjectPool = m_ObjectPoolManager.CreateSingleSpawnObjectPool <TimeActionObject>(objectName); m_TimeActionObjectPool.AutoReleaseInterval = autoReleaseInterval; m_TimeActionObjectPool.ExpireTime = expireTime; m_TimeActionObjectPool.Capacity = capacity; }