Exemplo n.º 1
0
 public PrefabPool(GameObject prefab, bool isUIPrefab = false)
 {
     if (m_Prefab == null)
     {
         GlobalToolsFunction.LogError("Prefab is null! ");
     }
     m_Name       = prefab.name;
     m_Prefab     = prefab;
     m_IsUIPrefab = isUIPrefab;
 }
Exemplo n.º 2
0
 //private int m_Index;
 public PrefabPool(string path, string name, bool isUIPrefab = false)
 {
     m_Name   = name;
     m_Prefab = RPrefab.Singleton.Load(path, name);
     if (m_Prefab == null)
     {
         GlobalToolsFunction.LogError(StringUtils.LinkText("Prefab is null! path:", path, name));
     }
     m_IsUIPrefab = isUIPrefab;
 }
Exemplo n.º 3
0
        /// <summary>
        /// String 转 double
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static double StringToDouble(string str)
        {
            if (str == string.Empty)
            {
                return(Global.INVALID_FLOAT);
            }
            double value = Global.INVALID_FLOAT;

            if (!double.TryParse(str, out value))
            {
                GlobalToolsFunction.LogError("StringToDouble error from " + str);
            }
            return(Convert.ToDouble(str));
        }
Exemplo n.º 4
0
        /// <summary>
        /// String 转 float
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static float StringToFloat(string str)
        {
            if (str == string.Empty)
            {
                return(Global.INVALID_FLOAT);
            }
            float value = Global.INVALID_FLOAT;

            if (!float.TryParse(str, out value))
            {
                GlobalToolsFunction.LogError("StringToFloat error from " + str);
            }
            return((float)Convert.ToDouble(str));
        }
Exemplo n.º 5
0
        /// <summary>
        /// String 转 ulong
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static ulong StringToULong(string str)
        {
            if (str == string.Empty)
            {
                return(Global.INVALID_ULONG);
            }
            ulong value = Global.INVALID_ULONG;

            if (!ulong.TryParse(str, out value))
            {
                GlobalToolsFunction.LogError("StringToULong error from " + str);
            }
            return(Convert.ToUInt64(str));
        }
Exemplo n.º 6
0
        /// <summary>
        /// String 转 uint
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static uint StringToUInt(string str)
        {
            if (str == string.Empty)
            {
                return(Global.INVALID_UINT);
            }
            uint value = Global.INVALID_UINT;

            if (!uint.TryParse(str, out value))
            {
                GlobalToolsFunction.LogError("StringToUInt error from " + str);
            }
            return(Convert.ToUInt32(str));
        }
Exemplo n.º 7
0
        /// <summary>
        /// String 转 int
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int StringToInt(string str)
        {
            if (str == string.Empty)
            {
                return(Global.INVALID_INT);
            }
            int value = Global.INVALID_INT;

            if (!int.TryParse(str, out value))
            {
                GlobalToolsFunction.LogError("StringToInt error from " + str);
            }
            return(value);
        }
Exemplo n.º 8
0
        public PrefabPool(string path, string name, int defaultCount, bool isUIPrefab = false)
        {
            m_Name   = name;
            m_Prefab = RPrefab.Singleton.Load(path, name);
            if (m_Prefab == null)
            {
                GlobalToolsFunction.LogError(StringUtils.LinkText("Prefab is null! path:", path, name));
            }
            m_IsUIPrefab = isUIPrefab;

            for (int i = 0; i < defaultCount; i++)
            {
                Despawn(Create());
            }
        }
Exemplo n.º 9
0
 public void Despawn(GameObject item)
 {
     if (item != null)
     {
         if (m_DespawnIsDestroy)
         {
             GameObject.Destroy(item);
         }
         else
         {
             item.transform.parent = GetPoolRoot(m_IsUIPrefab);
             HideItem(item);
             if (m_IsUIPrefab)
             {
                 GlobalToolsFunction.SetLayer(item, LayerManager.UI);
             }
             //item.SetActive(false);
             m_Queue.Enqueue(item);
         }
     }
 }