public IResourceFile FindResourceFile(string resName)
        {
            string fixedName = FilenameUtils.FixResourcePath(resName);

            if (m_resources.TryGetValue(fixedName, out ResourceFile file))
            {
                return(file);
            }

            string resPath = m_resourceCallback?.Invoke(fixedName);

            if (resPath == null)
            {
                Logger.Log(LogType.Warning, LogCategory.Import, $"Resource file '{resName}' hasn't been found");
                m_resources.Add(fixedName, null);
                return(null);
            }

            using (ResourceFileScheme scheme = ResourceFile.LoadScheme(resPath, fixedName))
            {
                ResourceFile resourceFile = scheme.ReadFile();
                AddResourceFile(resourceFile);
            }
            Logger.Log(LogType.Info, LogCategory.Import, $"Resource file '{resName}' has been loaded");
            return(m_resources[fixedName]);
        }
예제 #2
0
        public ResourcesFile FindResourcesFile(ISerializedFile ifile, string resName)
        {
            SerializedFile file = (SerializedFile)ifile;

            resName = FilenameUtils.FixResourcePath(resName);

            // check asset bundles / web files
            string filePath = file.FilePath;

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == filePath && res.Name == resName)
                {
                    return(res.CreateReference());
                }
            }

            string resPath = m_resourceCallback?.Invoke(resName);

            if (resPath == null)
            {
                return(null);
            }
            using (SmartStream stream = SmartStream.OpenRead(resPath))
            {
                return(new ResourcesFile(stream, resPath, resName, 0, stream.Length));
            }
        }
예제 #3
0
        public IResourceFile FindResourceFile(string resName)
        {
            string fixedName = FilenameUtils.FixResourcePath(resName);

            if (m_resources.TryGetValue(fixedName, out ResourceFile file))
            {
                return(file);
            }

            string resPath = m_resourceCallback?.Invoke(fixedName);

            if (resPath == null)
            {
                m_resources.Add(fixedName, null);
                return(null);
            }

            using (ResourceFileScheme scheme = ResourceFile.LoadScheme(resPath, fixedName))
            {
                AddFile(scheme, this, AssemblyManager);
            }
            return(m_resources[fixedName]);
        }