コード例 #1
0
    void OnGUI()
    {
        Object oldObj = obj;

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("拖入检测的assetbundle文件");
        obj = EditorGUILayout.ObjectField(obj, typeof(Object), false);
        EditorGUILayout.EndHorizontal();

        if (obj != null && oldObj != obj)
        {
            string path = AssetDatabase.GetAssetPath(obj);
            path = Application.dataPath + path.Replace("Assets", string.Empty);
            abr  = new AssetBundleReader(path);
        }

        GUILayout.Space(16);

        if (abr != null)
        {
            if (abr.header.HasValidSignature())
            {
                GUILayout.Label("not a valid assetbundle file");
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("");
                GUILayout.EndHorizontal();
            }
        }
    }
コード例 #2
0
ファイル: AbLoooker.cs プロジェクト: sonygod/abLoooker
    void OnGUI()
    {
        Object oldObj = obj;
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("拖入检测的assetbundle文件");
        obj = EditorGUILayout.ObjectField(obj, typeof(Object), false);
        EditorGUILayout.EndHorizontal();

        if (obj != null && oldObj != obj)
        {
            string path = AssetDatabase.GetAssetPath(obj);
            path = Application.dataPath + path.Replace("Assets", string.Empty);
            abr = new AssetBundleReader(path);
        }

        GUILayout.Space(16);

        if (abr != null)
        {
            if (abr.header.HasValidSignature())
            {
                GUILayout.Label("not a valid assetbundle file");
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("");
                GUILayout.EndHorizontal();
            }
        }
    }
コード例 #3
0
ファイル: ResMgr.cs プロジェクト: liuzhognxiu/ThreeIdoits
    public void LoadAssetAndInitialize(string assetName, Transform parent, Vector3 pos, System.Action <GameObject> call = null)
    {
        UnityEngine.Object ret = LoadAssetFromResource(assetName);
        if (ret == null)
        {
            AssetBundleReader reader = AssetBundleReaderManager.Instance.LoadAssetBundle(assetName);
            AssetPack         ap     = null;
            CoroutineAgent.WaitOperation(
                () => reader.IsLoaded,
                () =>
            {
                if (reader.IsLoaded && reader.AssetBundleData != null)
                {
                    ret = reader.AssetBundleData.LoadAsset(assetName.AssetFileName().NoExtension());
                    reader.UnLoadAssetBundle();
                }

                if (ret != null)
                {
                    if (!m_dicAsset.ContainsKey(assetName))
                    {
                        ap = new AssetPack(ret, false);
                        m_dicAsset.Add(assetName, ap);
                    }
                    else
                    {
                        ap = m_dicAsset[assetName];
                        Debug.logger.LogWarning("ResMgr", "ResMgr.LoadAssetAndInitialize: asset name->" + assetName + ", already in asset pool");
                    }
                }
                else
                {
                    Debug.logger.LogError("ResMgr", "ResMgr.LoadAssetAndInitialize: assetName->" + assetName + ", finds no asset!");
                }
                //targetObj.GetComponent<UITexture>().mainTexture = (Texture)ret;
                GameObject go              = GameObject.Instantiate(ret) as GameObject;
                go.transform.parent        = parent;
                go.transform.localPosition = pos;
                go.transform.localScale    = Vector3.one;
                if (call != null)
                {
                    call(go);
                }
            }, this);
        }
        else
        {
            GameObject go = GameObject.Instantiate(ret) as GameObject;
            go.transform.parent        = parent;
            go.transform.localPosition = pos;
            go.transform.localScale    = Vector3.one;
            if (call != null)
            {
                call(go);
            }
        }
    }
コード例 #4
0
    public AssetBundleReader LoadAssetBundle(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            return(null);
        }
        AssetBundleReader reader = new AssetBundleReader(name);

        return(reader);
    }
コード例 #5
0
    void Awake()
    {
        Instance = this;

        localRoot =
#if UNITY_EDITOR
            "file://" + Application.streamingAssetsPath;
#elif UNITY_ANDROID
            Application.streamingAssetsPath;
#else
            "file://" + Application.streamingAssetsPath;
#endif
    }
コード例 #6
0
ファイル: ResMgr.cs プロジェクト: liuzhognxiu/ThreeIdoits
    public void LoadAssetTexture(string assetName, GameObject targetObj, bool isKeepInMemory = false)
    {
        UnityEngine.Object ret = LoadAssetFromResource(assetName);
        if (ret == null)
        {
            AssetBundleReader reader = AssetBundleReaderManager.Instance.LoadAssetBundle(assetName);
            AssetPack         ap     = null;
            CoroutineAgent.WaitOperation(
                () => reader.IsLoaded,
                () =>
            {
                if (reader.IsLoaded && reader.AssetBundleData != null)
                {
                    ret = reader.AssetBundleData.LoadAsset(assetName.AssetFileName().NoExtension());
                    reader.UnLoadAssetBundle();
                }

                if (ret != null)
                {
                    if (!m_dicAsset.ContainsKey(assetName))
                    {
                        ap = new AssetPack(ret, isKeepInMemory);
                        m_dicAsset.Add(assetName, ap);
                    }
                    else
                    {
                        ap = m_dicAsset[assetName];
                        Debug.logger.LogWarning("ResMgr", "ResMgr.LoadAssetTexture: asset name->" + assetName + ", already in asset pool");
                    }
                }
                else
                {
                    Debug.logger.LogError("ResMgr", "ResMgr.LoadAssetTexture: assetName->" + assetName + ", finds no asset!");
                }
                targetObj.GetComponent <UITexture>().mainTexture = (Texture)ret;
            }, this);
        }
        else
        {
            targetObj.GetComponent <UITexture>().mainTexture = (Texture)ret;
        }
    }
コード例 #7
0
    public AssetBundleReader LoadStreamBundle(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            return(null);
        }

        if (m_cacheAssets.ContainsKey(name))
        {
            return(m_cacheAssets[name]);
        }

        AssetBundleReader reader = new AssetBundleReader(name);

        if (reader != null)
        {
            m_cacheAssets.Add(name, reader);
        }

        return(reader);
    }
コード例 #8
0
 void Start()
 {
     reader = AssetBundleReader.Instance;
 }
コード例 #9
0
 void Start()
 {
     reader = AssetBundleReader.Instance;
 }