Beispiel #1
0
 /// <summary>
 /// 重置
 /// </summary>
 public virtual void Reset()
 {
     package = null;
     if (gameObject != null)
     {
         UnityEngine.Object.Destroy(gameObject);
         gameObject = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 释放游戏对象
        /// </summary>
        /// <param name="actionData"></param>
        public void ReleaseActionData(ActionData3D actionData)
        {
            ActionDataPackage3D cache = GetCache(actionData.package.packageName, actionData.package.name);

            if (cache == null)
            {
                return;
            }

            cache.Release(actionData);
            cache.Unuse();
        }
Beispiel #3
0
        /// <summary>
        /// 获取游戏对象
        /// </summary>
        /// <param name="packageName"></param>
        /// <param name="objectName"></param>
        /// <returns></returns>
        public ActionData3D GetActionData(string packageName, string objectName)
        {
            ActionDataPackage3D cache = GetCache(packageName, objectName);

            if (cache == null)
            {
                IAssetPackage assetPackage = App.assetManager.GetAssetPackage(packageName);
                if (assetPackage == null)
                {
                    return(null);
                }

                GameObject prefab = assetPackage.GetAsset(objectName) as GameObject;
                if (prefab == null)
                {
                    return(null);
                }

                cache              = App.objectPoolManager.GetObject <ActionDataPackage3D>();
                cache.packageName  = packageName;
                cache.name         = objectName;
                cache.assetPackage = assetPackage;
                cache.prefab       = prefab;

                Dictionary <string, ActionDataPackage3D> pkg;
                if (_actionCaches.TryGetValue(packageName, out pkg) == false)
                {
                    pkg = _actionCaches[packageName] = new Dictionary <string, ActionDataPackage3D>();
                }

                pkg[objectName] = cache;
            }

            cache.Use();
            return(cache.Get());
        }