示例#1
0
    public void AddCallback(IResourceLoadCallback cb)
    {
        if (!m_CallBackList.Contains(cb))
        {
            int index = 0;
            for (; index < m_CallBackList.Count; index++)
            {
                if (m_CallBackList[index].LoadCallbackPriority() > cb.LoadCallbackPriority())
                {
                    break;
                }
            }

            index = index == 0 ? 0 : index - 1;
            m_CallBackList.Insert(index, cb);
        }
    }
示例#2
0
    public void LoadResource(string name, string path, ResourceType type, IResourceLoadCallback callback)
    {
        ResourceInfo info = new ResourceInfo(name, path, type);

        if (m_AllLoadInfoDic.ContainsKey(info.m_RPath))
        {
            info = m_AllLoadInfoDic[info.m_RPath];
        }

        info.AddCallback(callback);

        LoadedObjectInfo oj = new LoadedObjectInfo(info.m_RType, info.m_RPath);

        if (m_LoadedObjects.Contains(oj))
        {
            for (int index = 0; index < m_LoadedObjects.Count; index++)
            {
                if (m_LoadedObjects[index].Equals(oj))
                {
                    GameObject go = GameObject.Instantiate(m_LoadedObjects[index].m_GameObject);
                    info.SetNoumenon(go);
                    break;
                }
            }
        }
        else
        {
            GameObject go = Resources.Load(info.m_RPath, typeof(GameObject)) as GameObject;
            if (go != null)
            {
                go.SetActive(false);
                m_LoadedObjects.Add(new LoadedObjectInfo(info.m_RType, info.m_RPath, go));
                info.SetNoumenon(GameObject.Instantiate(go));
            }
            else
            {
                Debug.LogWarning("the object is null." + info);
            }
        }

        m_AllLoadInfoDic.Remove(info.m_RPath);
    }
示例#3
0
    public void LoadResource(string name, ResourceType type, IResourceLoadCallback callback)
    {
        ResourceInfo info = new ResourceInfo(name, type);

        LoadResource(info.m_RName, info.m_RPath, info.m_RType, callback);
    }