コード例 #1
0
    public void SynLoadAsset(string prefab, Action <Object> loaded)
    {
        ResourceInfo resourceInfo;
        var          flag = m_resourcesDic.TryGetValue(prefab, out resourceInfo);

        if (!flag)
        {
            resourceInfo = new ResourceInfo();
            if (m_filesDic.ContainsKey(prefab))
            {
                resourceInfo.Path    = m_filesDic[prefab];
                resourceInfo.ResType = UtilsEx.GetTypeByExtension(Path.GetExtension(prefab));
            }
            else
            {
                LoggerHelper.Error("prefab not exist: " + prefab);
                if (loaded != null)
                {
                    loaded(null);
                }
                return;
            }
            m_resourcesDic.Add(prefab, resourceInfo);
        }

        resourceInfo.ReferenceCount++;
        if (loaded != null)
        {
            loaded(resourceInfo.GameObject);
        }
    }
コード例 #2
0
    public Object SynLoadAsset(string prefab)
    {
        if (string.IsNullOrEmpty(prefab))
        {
            LoggerHelper.Error("null prefab name.");
            return(null);
        }
        ResourceInfo resourceInfo;
        var          flag = m_resourcesDic.TryGetValue(prefab, out resourceInfo);

        if (!flag)
        {
            resourceInfo = new ResourceInfo();
            if (m_filesDic.ContainsKey(prefab))
            {
                resourceInfo.Path    = m_filesDic[prefab];
                resourceInfo.ResType = UtilsEx.GetTypeByExtension(Path.GetExtension(prefab));
            }
            else
            {
                LoggerHelper.Error("prefab not exist: " + prefab);
                return(null);
            }
            m_resourcesDic.Add(prefab, resourceInfo);
        }

        resourceInfo.ReferenceCount++;
        return(resourceInfo.GameObject);
    }
コード例 #3
0
    public void LoadAsset(string prefab, Action <Object> loaded, Action <float> progress)
    {
        if (string.IsNullOrEmpty(prefab))
        {
            LoggerHelper.Error("null prefab name.");
            if (loaded != null)
            {
                loaded(null);
            }
            return;
        }
        ResourceInfo resourceInfo;
        var          flag = m_resourcesDic.TryGetValue(prefab, out resourceInfo);

        if (!flag)
        {
            resourceInfo = new ResourceInfo();
            if (m_filesDic.ContainsKey(prefab))
            {
                resourceInfo.Path    = m_filesDic[prefab];
                resourceInfo.ResType = UtilsEx.GetTypeByExtension(Path.GetExtension(prefab));
            }
            else
            {
                LoggerHelper.Error("prefab not exist: " + prefab);
                if (loaded != null)
                {
                    loaded(null);
                }
                return;
            }
            m_resourcesDic.Add(prefab, resourceInfo);
        }

        resourceInfo.ReferenceCount++;
        //if (loaded != null)
        //	loaded(resourceInfo.GameObject);
        //if (prefab.EndsWith(".exr"))
        //{
        //	if (loaded != null)
        //		loaded(resourceInfo.GameObject);
        //}
        //else
        //{
        StartCoroutine(resourceInfo.GetGameObject(loaded));
        //}
    }