Ejemplo n.º 1
0
    //场景及预加载资源完毕时进行的操作;
    void OnEndLoad()
    {
        if (m_levelAsset != null)
        {
            ioo.resourceManager.ReleaseAsset(m_levelAsset);
            m_levelAsset = null;
        }
        //处理map的无效shader
        GameObject _gameobject = GameObject.Find("map");

        if (_gameobject != null)
        {
            ProjectileBase.excuteShader(_gameobject);
        }
        //资源加载完成之后,所有camera 的初始化和其他变化还是交给lua处理。
        //AudioListener temp = m_bar.gameObject.GetComponent<AudioListener>();
        if (null != m_bar)
        {
            GameObject.Destroy(m_bar.gameObject);
        }

        //这里才调用lua的对应函数做进度;
        ioo.gameManager.uluaMgr.OnLevelLoaded(m_level);
        EventDispatcher.TriggerEvent(EventDefine.Event_All_Resource_Is_Load);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 从本地加载图集
    /// </summary>
    /// <param name="atlasname"></param>
    private SpriteAtlas ToLoadAtlas(string atlasname)
    {
        SpriteAtlas spriteatla = null;

        ResourceMisc.AssetWrapper aw = ioo.resourceManager.LoadAsset(atlasname, typeof(SpriteAtlas));
        if (null == aw)
        {
            Debug.LogError("The SpriteAtlas name: " + atlasname + " is not exit, please check the assetbundle");
            return(spriteatla);
        }
        spriteatla = (SpriteAtlas)aw.GetAsset();


        if (spriteatla != null)
        {
            if (SpriteDic.ContainsKey(atlasname))
            {
                SpriteDic[atlasname] = spriteatla;
            }
            else
            {
                SpriteDic.Add(atlasname, spriteatla);
            }
        }
        else
        {
            Debug.LogError("The path: " + atlasname + " is not Exit!");
        }

        return(spriteatla);
    }
Ejemplo n.º 3
0
    static int ReleaseAsset(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        ResourceManager obj = LuaScriptMgr.GetUnityObject <ResourceManager>(L, 1);

        ResourceMisc.AssetWrapper arg0 = LuaScriptMgr.GetNetObject <ResourceMisc.AssetWrapper>(L, 2);
        obj.ReleaseAsset(arg0);
        return(0);
    }
Ejemplo n.º 4
0
    static int CheckAsyncResult(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        ResourceManager obj  = LuaScriptMgr.GetUnityObject <ResourceManager>(L, 1);
        string          arg0 = LuaScriptMgr.GetLuaString(L, 2);

        ResourceMisc.AssetWrapper o = obj.CheckAsyncResult(arg0);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Ejemplo n.º 5
0
    //载入了空场景
    public void OnLoadEmptylevel()
    {
        ClearCache();
        ResourceMisc.AssetWrapper asset = ioo.resourceManager.LoadAsset(LOADING_UI_RES, typeof(GameObject));
        GameObject obj = GameObject.Instantiate(asset.GetAsset()) as GameObject;

        Init(obj);
        m_bar.SetPercentage(0);
        ioo.resourceManager.ReleaseAsset(asset);
        CoroutineController.Instance.StartCoroutine(OnSceneAssetLoading());
    }
Ejemplo n.º 6
0
    static int LoadAsset(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        ResourceManager obj  = LuaScriptMgr.GetUnityObject <ResourceManager>(L, 1);
        string          arg0 = LuaScriptMgr.GetLuaString(L, 2);
        Type            arg1 = LuaScriptMgr.GetTypeObject(L, 3);

        ResourceMisc.AssetWrapper o = obj.LoadAsset(arg0, arg1);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Ejemplo n.º 7
0
    IEnumerator OnSceneAssetLoading()
    {
        Debug.Log("Time StartLoadLevelAsset:" + Time.realtimeSinceStartup + "|" + m_levelAssetToLoad);
        if (m_levelAssetToLoad != null && m_levelAssetToLoad != "")
        {
            m_levelAsset = ioo.resourceManager.LoadAsset(m_levelAssetToLoad, typeof(GameObject));
        }
        Debug.Log("Time StartLoadLevel:" + Time.realtimeSinceStartup);
        yield return(new WaitForEndOfFrame());

        CoroutineController.Instance.StartCoroutine(OnAsyncLoading());
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Ñ°ÕÒShader
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public static Shader ShaderFind(string path)
    {
        ResourceMisc.AssetWrapper aw = ioo.resourceManager.LoadAsset(path, typeof(Shader));

        Shader shader = (Shader)aw.GetAsset();

        if (null == shader)
        {
            Debug.LogError("the shader " + path + " is not exit");
            return(null);
        }

        return(shader);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 加载对象池配置文件
    /// </summary>
    private void LoadPoolConfig()
    {
        ResourceMisc.AssetWrapper aw       = ioo.resourceManager.LoadAsset("prefabs\\pool\\gameobjectpool", typeof(GameObjectPoolList));
        GameObjectPoolList        poolList = (GameObjectPoolList)aw.GetAsset();

        if (null == poolList)
        {
            return;
        }
        foreach (GameObjectPool pool in poolList.poolList)
        {
            poolDic.Add(pool.name, pool);
        }
    }
Ejemplo n.º 10
0
    IEnumerator OnSceneAssetLoading()
    {
        Debug.Log("Time StartLoadLevelAsset:" + Time.realtimeSinceStartup + "|" + m_levelAssetToLoad);
        if (m_levelAssetToLoad != null && m_levelAssetToLoad != "")
        {
            m_levelAsset = ioo.resourceManager.LoadAsset(m_levelAssetToLoad, typeof(GameObject));
        }
        m_bar.SetPercentage(0.1f);
        Debug.Log("Time StartLoadLevel:" + Time.realtimeSinceStartup);
        //因为为unity载入资源一定需要audiolistener
        yield return(new WaitForEndOfFrame());

        //如果场景特别大,这里应该用
        Application.LoadLevel(m_levelToLoad);
    }
Ejemplo n.º 11
0
 /// <summary>
 /// 创建对象到池里
 /// </summary>
 /// <param name="resPath">对象路径</param>
 /// <param name="count">对象个数</param>
 /// <returns></returns>
 public Transform CreatePrefabPool(string resPath, int count)
 {
     if (_prefabDic.ContainsKey(resPath) == false)
     {
         ResourceMisc.AssetWrapper asset = ioo.resourceManager.LoadAsset(resPath, typeof(GameObject));
         GameObject obj = asset.GetAsset() as GameObject;
         obj.transform.position = POOL_POS;
         obj.transform.rotation = Quaternion.identity;
         ResourceManager.excuteShader(obj);
         _dogFacePrefab = obj.transform;
         PrefabPool prefabPool = new PrefabPool(_dogFacePrefab);
         prefabPool.preloadAmount  = count;     // 预创建的个数
         prefabPool.limitInstances = false;
         _dogFacePool.CreatePrefabPool(prefabPool);
         _prefabDic.Add(resPath, _dogFacePrefab);
     }
     return(_prefabDic[resPath]);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 创建新的对象
 /// </summary>
 /// <returns></returns>
 private void CreateNewInstance()
 {
     if (null == prefab)
     {
         ResourceMisc.AssetWrapper aw = ioo.resourceManager.LoadAsset(path, typeof(GameObject));
         prefab = GameObject.Instantiate(aw.GetAsset()) as GameObject;
         prefab.SetActive(false);
         prefab.transform.SetParent(PoolManager._parentTransform);
         freeList.Add(prefab);
     }
     else
     {
         GameObject go = GameObject.Instantiate(prefab) as GameObject;
         go.SetActive(false);
         go.transform.SetParent(PoolManager._parentTransform);
         freeList.Add(go);
     }
 }
Ejemplo n.º 13
0
    /// <summary>
    /// 载入一个音频
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    private AudioClip LoadAudicClip(string name)
    {
        if (!ClipIsExit(name))
        {
            Debugger.LogError("The audio name: " + name + " is not exit!");
            return(null);
        }

        AudioClip clip = null;

        if (mClipCacheDic.ContainsKey(name))
        {
            if (mClipCacheDic[name] != null)
            {
                AudioCache cache = mClipCacheDic[name];
                clip = cache.GetClip();
            }
            else
            {
                mClipCacheDic.Remove(name);
            }
        }

        if (clip != null)
        {
            return(clip);
        }

        ResourceMisc.AssetWrapper aw = ioo.resourceManager.LoadAsset(mConfigDic[name], typeof(AudioClip));
        if (null == aw)
        {
            Debugger.LogError("The AudioClip name: " + name + " is not exit, please check the assetbundle");
            return(null);
        }
        clip = (AudioClip)aw.GetAsset();

        AudioCache temp = new AudioCache();

        mClipCacheDic.Add(name, temp);
        temp.Asset = aw.GetAsset();
        clip       = temp.GetClip();

        return(clip);
    }
Ejemplo n.º 14
0
    /// <summary>
    /// 创建新的对象
    /// </summary>
    /// <returns></returns>
    private void CreateNewInstance()
    {
        if (null == asset)
        {
            ResourceMisc.AssetWrapper aw = ioo.resourceManager.LoadAsset(path, typeof(GameObject));
            asset = aw.GetAsset();
        }

        GameObject go = GameObject.Instantiate(asset) as GameObject;

        go.transform.localEulerAngles = Vector3.zero;
        go.transform.localScale       = Vector3.one;
        go.transform.localPosition    = Vector3.zero;
        go.name = name + "_" + Count++;
        go.SetActive(false);
        //AddScriptToPrefab(go);
        go.transform.SetParent(PoolManager._parentTransform);
        mFreeList.Add(go);
    }