Exemplo n.º 1
0
	// Load level from the given assetBundle.
	static public AssetBundleLoadOperation LoadLevelAsync (string assetBundleName, string levelName, bool isAdditive)
	{
		AssetBundleLoadOperation operation = null;
#if UNITY_EDITOR
		if (SimulateAssetBundleInEditor)
		{
			string[] levelPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, levelName);
			if (levelPaths.Length == 0)
			{
				///@TODO: The error needs to differentiate that an asset bundle name doesn't exist
				//        from that there right scene does not exist in the asset bundle...
			
				Debug.LogError("There is no scene with name \"" + levelName + "\" in " + assetBundleName);
				return null;
			}

			if (isAdditive)
				EditorApplication.LoadLevelAdditiveInPlayMode(levelPaths[0]);
			else
				EditorApplication.LoadLevelInPlayMode(levelPaths[0]);

			operation = new AssetBundleLoadLevelSimulationOperation();
		}
		else
#endif
		{
			LoadAssetBundle (assetBundleName);
			operation = new AssetBundleLoadLevelOperation (assetBundleName, levelName, isAdditive);

			m_InProgressOperations.Add (operation);
		}

		return operation;
	}
    // Load level from the given assetBundle.
    public AssetBundleLoadOperation LoadLevelAsync(string a_assetBundleName, string a_levelName, bool a_isAdditive, bool a_allowSceneActivation)
    {
        AssetBundleLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            var levelPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(a_assetBundleName, a_levelName);
            if (levelPaths.Length == 0)
            {
                ///@TODO: The error needs to differentiate that an asset bundle name doesn't exist
                //        from that there right scene does not exist in the asset bundle...

                Debug.LogError("There is no scene with name \"" + a_levelName + "\" in " + a_assetBundleName);
                return(null);
            }

            if (a_isAdditive)
            {
                EditorApplication.LoadLevelAdditiveInPlayMode(levelPaths[0]);
            }
            else
            {
                EditorApplication.LoadLevelInPlayMode(levelPaths[0]);
            }

            operation = new AssetBundleLoadLevelSimulationOperation();
        }
        else
#endif
        {
            var key = AssetToKey(a_assetBundleName, a_levelName);

            AssetBundleLoadOperation inProgressOperation;
            if (m_inProgressOperationsByName.TryGetValue(key, out inProgressOperation))
            {
                var loadLevelOperation = inProgressOperation as AssetBundleLoadLevelOperation;
                if (loadLevelOperation != null)
                {
                    return(loadLevelOperation);
                }
            }

            LoadAssetBundle(a_assetBundleName);
            operation = new AssetBundleLoadLevelOperation(a_assetBundleName, a_levelName, a_isAdditive, a_allowSceneActivation);

            m_inProgressOperationsByName.Add(key, operation);
            m_inProgressOperations.Add(new KeyValuePair <string, AssetBundleLoadOperation>(key, operation));
        }

        return(operation);
    }
Exemplo n.º 3
0
    public static AssetBundleLoadOperation LoadLevelAsync(string assetBundleName, string levelName)
    {
        AssetBundleLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName);
        }
        else
#endif
        {
            assetBundleName = RemapVariantName(assetBundleName);
            LoadAssetBundle(assetBundleName, true);
            operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName);
            m_InProgressOperations.Add(operation);
        }
        return(operation);
    }
Exemplo n.º 4
0
    // Load level from the given assetBundle.
    public static AMLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
    {
        AMLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName, isAdditive);
        }
        else
#endif
        {
            LoadAssetBundle(assetBundleName, false);
            operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName, isAdditive);

            m_inProgressOperations.Add(operation);
        }

        return(operation);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Loads the level async.
    /// </summary>
    /// <returns>The level async.</returns>
    /// <param name="assetBundleName">Asset bundle name.</param>
    /// <param name="levelName">Level name.</param>
    /// <param name="isAdditive">If set to <c>true</c> is additive.</param>
    public static AssetLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
    {
        AssetLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName, isAdditive);
        }
        else
#endif
        {
            CollectionDependenciesLoadTask(assetBundleName);

            operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName, isAdditive);

            m_InProgressOperations.Add(operation);
        }

        return(operation);
    }
Exemplo n.º 6
0
    // Load level from the given assetBundle.
    // *********** 주요 사용하는 함수 ***********
    static public AssetBundleLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
    {
        Log(LogType.Info, "Loading " + levelName + " from " + assetBundleName + " bundle");

        AssetBundleLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName, isAdditive);
        }
        else
#endif
        {
            assetBundleName = RemapVariantName(assetBundleName);
            LoadAssetBundle(assetBundleName);
            operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName, isAdditive);

            m_InProgressOperations.Add(operation);
        }

        return(operation);
    }
        // Starts a load operation for a level from the given asset bundle.
        static public AssetBundleLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
        {
            Log(LogType.Info, "Loading " + levelName + " from " + assetBundleName + " bundle");

            AssetBundleLoadOperation operation = null;
    #if UNITY_EDITOR
            if (SimulateAssetBundleInEditor)
            {
                operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName, isAdditive);
            }
            else
    #endif
            {
                assetBundleName = RemapVariantName(assetBundleName);
                LoadAssetBundle(assetBundleName);
                operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName, isAdditive);

                m_InProgressOperations.Add(operation);
            }

            return operation;
        }
    // Load level from the given assetBundle.
    public static AssetBundleLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
    {
        AssetBundleLoadOperation operation = null;
        #if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            string[] levelPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, levelName);
            if (levelPaths.Length == 0)
            {
                ///@TODO: The error needs to differentiate that an asset bundle name doesn't exist
                //        from that there right scene does not exist in the asset bundle...

                Debug.LogError("There is no scene with name \"" + levelName + "\" in " + assetBundleName);
                return null;
            }

            if (isAdditive)
                EditorApplication.LoadLevelAdditiveInPlayMode(levelPaths[0]);
            else
                EditorApplication.LoadLevelInPlayMode(levelPaths[0]);

            operation = new AssetBundleLoadLevelSimulationOperation();
        }
        else
        #endif
        {
            LoadAssetBundle (assetBundleName);
            operation = new AssetBundleLoadLevelOperation (assetBundleName, levelName, isAdditive);

            m_InProgressOperations.Add (operation);
        }

        return operation;
    }