Exemplo n.º 1
0
        public void Initialize()
        {
#if UNITY_EDITOR
            LoggerHelper.Debug("We are " + (AssetLoader2.m_SimulateAssetBundleInEditor ? "in Editor simulation mode" : "in normal mode"));
#endif


#if UNITY_EDITOR
            // If we're in Editor simulation mode, we don't need the manifest assetBundle.
            if (AssetLoader2.m_SimulateAssetBundleInEditor)
            {
                return;
            }
#endif
            preparePath();
            LoadAssetBundle(SubName, true);
            var operation = new AssetBundleLoadAssetOperationFull(SubName, "AssetBundleManifest", typeof(AssetBundleManifest), OnLoadManifest, null);
            operation.loader = this;
            m_InProgressOperations.Add(operation);
        }
Exemplo n.º 2
0
        public void LoadAsset(string assetBundleName, string assetName, System.Type type, LoadAssetCallback callback, params object[] param)
        {
            AssetBundleLoadAssetOperation operation = null;

#if UNITY_EDITOR
            if (AssetLoader2.m_SimulateAssetBundleInEditor)
            {
                string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName);
                if (assetPaths.Length == 0)
                {
                    Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName);
                    callback(null, param);
                    return;
                }

                // @TODO: Now we only get the main object from the first asset. Should consider type also.
                Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]);
                //operation = new AssetBundleLoadAssetOperationSimulation(target);
                callback(target, param);
            }
            else
#endif
            {
                if (m_Manifest == null)
                {
                    AddPendingLoad(assetBundleName);
                }
                else
                {
                    LoadAssetBundle(assetBundleName);
                }
                operation        = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type, callback, param);
                operation.loader = this;
                m_InProgressOperations.Add(operation);
            }
        }