protected string GetUniqueFileName(Object @object, string dirPath)
        {
            string fileName;

            switch (@object)
            {
            case NamedObject named:
                fileName = named.Name;
                break;

            case Prefab prefab:
                fileName = prefab.GetName();
                break;

            case MonoBehaviour monoBehaviour:
                fileName = monoBehaviour.Name;
                break;

            default:
                fileName = @object.GetType().Name;
                break;
            }
            fileName = FileNameRegex.Replace(fileName, string.Empty);

            fileName = DirectoryUtils.GetMaxIndexName(dirPath, fileName);
            fileName = $"{fileName}.{@object.ExportExtension}";
            return(fileName);
        }
Exemplo n.º 2
0
        public SkipExportCollection(IAssetExporter assetExporter, Object asset)
        {
            if (assetExporter == null)
            {
                throw new ArgumentNullException(nameof(assetExporter));
            }
            if (asset == null)
            {
                throw new ArgumentNullException(nameof(asset));
            }

            AssetExporter = assetExporter;
            Name          = asset.GetType().Name;
            m_asset       = asset;
        }
Exemplo n.º 3
0
        private Object ReadAsset(AssetStream stream, AssetInfo assetInfo, long offset, int size)
        {
            Object asset = Collection.AssetFactory.CreateAsset(assetInfo);

            if (asset == null)
            {
                return(null);
            }

            stream.BaseStream.Position = offset;
            if (Config.IsGenerateGUIDByContent)
            {
                byte[] data = stream.ReadBytes(size);
                asset.Read(data);

                using (MD5 md5 = MD5.Create())
                {
                    byte[] md5Hash = md5.ComputeHash(data);
                    assetInfo.GUID = new UtinyGUID(md5Hash);
                }
            }
            else
            {
                stream.AlignPosition = offset;
                asset.Read(stream);
                long read = stream.BaseStream.Position - offset;
                if (read != size)
                {
                    throw new Exception($"Read {read} but expected {size} for object {asset.GetType().Name}");
                }
            }
            return(asset);
        }
 public SkipExportCollection(DummyAssetExporter assetExporter, Object asset) :
     this(assetExporter, asset, asset.GetType().Name)
 {
 }