示例#1
0
	IEnumerator Monster001()
	{
		yield return 1;
		
#if UNITY_IPHONE
		string path = "file://" + Application.dataPath + "/Raw/";
#elif UNITY_STANDALONE_WIN
		string path = "file://" + Application.dataPath + "/StreamingAssets/";
#else
		string path = "jar:file://" + Application.dataPath + "!/assets/";
#endif
				
		Debug.Log(path + "monster001.assetBundles");
		
		ABLoad load = new ABLoad(path + "monster001.assetBundles");
		while(true)
		{
			if (load.bundle.isDone)
				break;
			
			yield return 1;
		}
		
		Debug.Log(load);
        //GameObject res = load.LoadGameObject("monster001");
        GameObject res = load.Load<GameObject>("monster001");
		
		Debug.Log(res);
		
		Instantiate(res);
		
		load.Close();

	}
示例#2
0
    IEnumerator Scene()
    {
        yield return 1;

#if UNITY_IPHONE
		string path = "file://" + Application.dataPath + "/Raw/";
#elif UNITY_STANDALONE_WIN
        string path = "file://" + Application.dataPath + "/StreamingAssets/";
#else
		string path = "jar:file://" + Application.dataPath + "!/assets/";
#endif

        Debug.Log(path + "110101.assetBundles");

        ABLoad load = new ABLoad(path + "110101.assetBundles");
        while (true)
        {
            if (load.bundle.isDone)
                break;

            yield return 1;
        }
        
        //  加载场景
        GameObject res = load.Load<GameObject>("110101");
        Instantiate(res);

        //  加载LightMap
        ArrayList texlist = new ArrayList();// Texture2D

        Object[] objects = load.LoadAll();
        foreach (Object e in objects)
        {
            if (!e.name.StartsWith("LightmapFar-"))
                continue;

            if (e.GetType() == typeof(Texture2D))
                texlist.Add(e);
        }
        texlist.Sort();

        //  数据集数量
        int lmDataSetCount = (texlist.Count + 1) / 2;
        int lmDataIndex = 0;

        LightmapData[] lmDataSet = new LightmapData[lmDataSetCount];

        for (int i = 0; i < texlist.Count; ++i)
        {
            LightmapData lmData = new LightmapData();
            lmData.lightmapFar = (Texture2D)texlist[i];
            if ((++i) != texlist.Count) lmData.lightmapNear = (Texture2D)texlist[i];

            lmDataSet[lmDataIndex] = lmData;
        }

        LightmapSettings.lightmapsMode = LightmapsMode.Dual;
        LightmapSettings.lightmaps = lmDataSet;

        load.Close();

    }