コード例 #1
0
ファイル: SerializedFile.cs プロジェクト: wyfleb/UtinyRipper
        public PPtr <T> CreatePPtr <T>(T asset)
            where T : Object
        {
            if (asset.File == this)
            {
                return(new PPtr <T>(0, asset.PathID));
            }

            for (int i = 0; i < Metadata.Dependencies.Length; i++)
            {
                FileIdentifier  identifier = Metadata.Dependencies[i];
                ISerializedFile file       = Collection.FindSerializedFile(identifier.GetFilePath());
                if (asset.File == file)
                {
                    return(new PPtr <T>(i + 1, asset.PathID));
                }
            }

            throw new Exception("Asset doesn't belong to this serialized file or its dependencies");
        }
コード例 #2
0
ファイル: SerializedFile.cs プロジェクト: wyfleb/UtinyRipper
        private Object FindAsset(int fileIndex, long pathID, bool isSafe)
        {
            ISerializedFile file;

            if (fileIndex == 0)
            {
                file = this;
            }
            else
            {
                fileIndex--;
                if (fileIndex >= Metadata.Dependencies.Length)
                {
                    throw new Exception($"{nameof(SerializedFile)} with index {fileIndex} was not found in dependencies");
                }

                FileIdentifier identifier = Metadata.Dependencies[fileIndex];
                file = Collection.FindSerializedFile(identifier.GetFilePath());
            }

            if (file == null)
            {
                if (isSafe)
                {
                    return(null);
                }
                throw new Exception($"{nameof(SerializedFile)} with index {fileIndex} was not found in collection");
            }

            Object asset = file.FindAsset(pathID);

            if (asset == null)
            {
                if (isSafe)
                {
                    return(null);
                }
                throw new Exception($"Object with path ID {pathID} was not found");
            }
            return(asset);
        }