Exemplo n.º 1
0
    public void LoadPrefab(string prefabName, ResBackHandle callBack)
    {
        object obj = null;
        bool   ret = resPool.TryGetValue(prefabName, out obj);

        if (ret)
        {
            if (callBack != null)
            {
                callBack(obj);
            }
        }
        else
        {
            LoadFromDisc(prefabName, (object go) =>
            {
                resPool.Add(prefabName, go);
                GameObject gameObj = go as GameObject;
                gameObj.SetActive(false);
                if (callBack != null)
                {
                    callBack(go);
                }
            });
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// prefabName 先填Asset/...
    /// </summary>
    /// <param name="prefabName"></param>
    /// <param name="callBack"></param>
    private void LoadFromDisc(string prefabName, ResBackHandle callBack)
    {
#if UNITY_EDITOR
        if (!Application.isMobilePlatform)
        {
            Object prefab = UnityEditor.AssetDatabase.LoadAssetAtPath <Object>(prefabName);
            if (callBack != null)
            {
                callBack(prefab);
            }
        }
        else
        {
            LoadFromAssetBundle(prefabName, callBack);
        }
#else
        LoadFromAssetBundle(prefabName, callBack);
#endif
    }
Exemplo n.º 3
0
 private void LoadFromAssetBundle(string prefabName, ResBackHandle callBack)
 {
 }