예제 #1
0
        public AssetData GetAssetData(string assetName, string ownerBundle)
        {
            if (mUUID4AssetData == null)
            {
                return(null);
            }

            string uuid = (ownerBundle + assetName).ToLower();

            AssetData result = null;

            if (mUUID4AssetData.TryGetValue(uuid, out result))
            {
                return(result);
            }

            return(null);
        }
예제 #2
0
        public AssetData GetAssetData(string assetName)
        {
            if (mAssetDataMap == null)
            {
                return(null);
            }

            string key = assetName.ToLower();

            AssetData result = null;

            if (mAssetDataMap.TryGetValue(key, out result))
            {
                return(result);
            }

            return(null);
        }
예제 #3
0
        private void Load()
        {
            if (ResMgr.IsSimulationModeLogic)
            {
#if UNITY_EDITOR
                var assetBundleNames = UnityEditor.AssetDatabase.GetAllAssetBundleNames();

                foreach (var assetBundleName in assetBundleNames)
                {
                    var assetPaths = UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);

                    var assetBundleData = new AssetBundleData
                    {
                        Name = assetBundleName,
                        DependencyBundleNames =
                            UnityEditor.AssetDatabase.GetAssetBundleDependencies(assetBundleName, false)
                    };

                    foreach (var assetPath in assetPaths)
                    {
                        var assetData = new AssetData
                        {
                            OwnerBundleName = assetBundleName,
                            // 通过路径获取名字
                            Name = assetPath
                                   .Split('/').Last()
                                   .Split('.').First()
                        };

                        assetBundleData.AssetDataList.Add(assetData);
                    }

                    AssetBundleDatas.Add(assetBundleData);
                }
#endif
            }
            else
            {
                var mainBundle =
                    AssetBundle.LoadFromFile(ResKitUtil.FullPathForAssetBundle(ResKitUtil.GetPlatformName()));

                mManifest = mainBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            }
        }
예제 #4
0
        public AssetData GetAssetData(string name)
        {
            if (m_AssetDataMap == null)
            {
                return(null);
            }

            string key = name.ToLower();

            AssetData result = null;

            if (m_AssetDataMap.TryGetValue(key, out result))
            {
                return(result);
            }

            //Log.w("Not Find AssetData:" + name);
            return(null);
        }
예제 #5
0
        private void SetSerizlizeData(SerializeData data)
        {
            if (data == null)
            {
                return;
            }

            mABUnitArray = new List <ABUnit>(data.abUnitArray);

            if (data.assetDataArray != null)
            {
                mAssetDataMap = new Dictionary <string, AssetData>();

                for (int i = 0; i < data.assetDataArray.Length; ++i)
                {
                    AssetData config = data.assetDataArray[i];
                    AddAssetData(config);
                }
            }
        }
예제 #6
0
        public ABUnit GetABUnit(string assetName)
        {
            var resSearchRule = ResSearchKeys.Allocate(assetName);

            AssetData data = GetAssetData(resSearchRule);

            resSearchRule.Recycle2Cache();

            if (data == null)
            {
                return(null);
            }

            if (mABUnitArray == null)
            {
                return(null);
            }

            return(mABUnitArray[data.AssetBundleIndex]);
        }
예제 #7
0
        public bool AddAssetData(AssetData data)
        {
            if (m_AssetDataMap == null)
            {
                m_AssetDataMap = new Dictionary <string, AssetData>();
            }

            string key = data.assetName.ToLower();

            if (m_AssetDataMap.ContainsKey(key))
            {
                AssetData old = GetAssetData(data.assetName);

                Log.e("Already Add AssetData :{0} \n OldAB:{1}      NewAB:{2}", data.assetName, m_ABUnitArray[old.assetBundleIndex].abName, m_ABUnitArray[data.assetBundleIndex].abName);
                return(false);
            }

            m_AssetDataMap.Add(key, data);
            return(true);
        }
예제 #8
0
        private string GetSceneAssetBundleName(string sceneName)
        {
            AssetData config = AssetDataTable.Instance.GetAssetData(sceneName);

            if (config == null)
            {
                Log.e("Not Find AssetData For Asset:" + sceneName);
                return(string.Empty);
            }

            string assetBundleName = AssetDataTable.Instance.GetAssetBundleName(config.assetBundleIndex);

            if (string.IsNullOrEmpty(assetBundleName))
            {
                Log.e("Not Find AssetBundle In Config:" + config.assetBundleIndex);
                return(string.Empty);
            }

            return(assetBundleName);
        }
예제 #9
0
        public SerializeData GetSerializeData()
        {
            SerializeData sd = new SerializeData();

            sd.key         = m_Key;
            sd.abUnitArray = mABUnitArray.ToArray();
            if (mAssetDataMap != null)
            {
                AssetData[] acArray = new AssetData[mAssetDataMap.Count];

                int index = 0;
                foreach (var item in mAssetDataMap)
                {
                    acArray[index++] = item.Value;
                }

                sd.assetDataArray = acArray;
            }

            return(sd);
        }
예제 #10
0
        protected void InitAssetBundleName()
        {
            m_AssetBundleArray = null;

            AssetData config = AssetDataTable.Instance.GetAssetData(m_Name);

            if (config == null)
            {
                Log.e("Not Find AssetData For Asset:" + m_Name);
                return;
            }

            string assetBundleName = AssetDataTable.Instance.GetAssetBundleName(config.assetName, config.assetBundleIndex);

            if (string.IsNullOrEmpty(assetBundleName))
            {
                Log.e("Not Find AssetBundle In Config:" + config.assetBundleIndex);
                return;
            }
            m_AssetBundleArray    = new string[1];
            m_AssetBundleArray[0] = assetBundleName;
        }