Ejemplo n.º 1
0
    public void DestroyObject()
    {
        m_eReturnType  = eObjectPoolReturnType.NoReturn;
        m_eDestroyType = eObjectPoolDestroyType.NoDestory;

        if (null != m_pObject)
        {
            GameObject.Destroy(m_pObject);
        }
    }
Ejemplo n.º 2
0
 public void Get <T>(string strName,
                     eObjectPoolReturnType eReturnType,
                     eObjectPoolDestroyType eDestroyType,
                     Action <T> pCallback) where T : Component
 {
     Get(strName, eReturnType, eDestroyType, (pObject) =>
     {
         pCallback(SHGameObject.GetComponent <T>(pObject));
     });
 }
Ejemplo n.º 3
0
 public void Get(string strName,
                 eObjectPoolReturnType eReturnType,
                 eObjectPoolDestroyType eDestroyType,
                 Action <GameObject> pCallback)
 {
     GetInactiveObject(strName, eReturnType, eDestroyType, (pObject) =>
     {
         SetActiveObject(strName, pObject);
         pCallback(pObject.m_pObject);
     });
 }
Ejemplo n.º 4
0
    public SHObjectPool(eObjectPoolReturnType eReturnType, eObjectPoolDestroyType eDestoryType, GameObject pObject)
    {
        m_eReturnType  = eReturnType;
        m_eDestroyType = eDestoryType;
        m_pObject      = pObject;

        if (null != m_pObject)
        {
            m_vStartPosition = m_pObject.transform.localPosition;
            m_qStartRotate   = m_pObject.transform.localRotation;
            m_vStartScale    = m_pObject.transform.localScale;
        }
    }
Ejemplo n.º 5
0
    private async void GetInactiveObject(string strName,
                                         eObjectPoolReturnType eReturnType,
                                         eObjectPoolDestroyType eDestroyType,
                                         Action <SHObjectPool> pCallback)
    {
        var pObjects = GetInactiveObjects(strName);

        if (0 == pObjects.Count)
        {
            var pObject = await Single.Resources.GetGameObject(strName);

            pCallback(new SHObjectPool(eReturnType, eDestroyType, pObject));
        }
        else
        {
            pObjects[0].m_eReturnType  = eReturnType;
            pObjects[0].m_eDestroyType = eDestroyType;
            pCallback(pObjects[0]);
        }
    }