Example #1
0
        //--------------------------------------------------------
        // 内部接口,主要给Resourceloader使用
        //--------------------------------------------------------

        /// <summary>
        /// 设置AssetObject,会增加其引用计数
        /// </summary>
        public void set_obj(AssetObject _asset_obj)
        {
            // 之前有Obj_要先destroy
            if (obj_ != null)
            {
                Debug.LogError("reused a assetresource");
                destroy();
            }

            // 设置AssetObject,并增加引用计数
            obj_ = _asset_obj;
            _asset_obj.add_ref();
            destroyed_ = false;
        }
Example #2
0
        /// <summary>
        /// 将_asset中的Object实例化成GameObject
        /// 实例化后并增加AssetResource的引用计数
        /// </summary>
        public GameObject instantiate_prefab_from_asset_object(AssetResource _asset, Transform parent = null)
        {
            AssetObject ao = _asset.get_obj();
            GameObject  go = null;

            if (parent != null)
            {
                go = GameObject.Instantiate(ao.get_obj_, parent) as GameObject;
            }
            else
            {
                go = GameObject.Instantiate(ao.get_obj_) as GameObject;
            }

            ao.add_ref();
            dic_gameobj_asset_.Add(new xc.Tuple <GameObject, AssetObject>(go, ao));
            return(go);
        }