public static void OnPostprocessAllAssets( string[] importedAssets , string[] deletedAssets , string[] movedAssets , string[] movedFromAssetPaths) { foreach (string assetName in importedAssets) { if (assetName.EndsWith(".gaf")) { byte [] fileBytes = null; using (BinaryReader freader = new BinaryReader(File.OpenRead(assetName))) { fileBytes = freader.ReadBytes((int)freader.BaseStream.Length); } if (fileBytes.Length > sizeof(int)) { int header = System.BitConverter.ToInt32(fileBytes.Take(4).ToArray(), 0); if (GAFHeader.isCorrectHeader((GAFHeader.CompressionType)header)) { GAFAnimationAsset animationAsset = ScriptableObject.CreateInstance <GAFAnimationAsset>(); animationAsset = GAFAssetUtils.saveAsset(animationAsset, Path.GetDirectoryName(assetName) + "/" + Path.GetFileNameWithoutExtension(assetName) + ".asset"); animationAsset.init(fileBytes); GAFTracking.sendAssetCreatedRequest(assetName); } } } } }
protected virtual void drawInitMovieClipButton(GAFAnimationAsset _Asset) { GUILayout.Space(3f); if (GUILayout.Button("Create GAF movie clip")) { foreach (var target in targets) { target.initialize(_Asset, m_TimelineID); target.reload(); GAFTracking.sendMovieClipCreatedRequest(_Asset.name); } } }
public static void OnPostprocessAllAssets( string[] importedAssets , string[] deletedAssets , string[] movedAssets , string[] movedFromAssetPaths) { foreach (string assetName in importedAssets) { if (assetName.EndsWith(".gaf")) { byte[] fileBytes = null; using (BinaryReader freader = new BinaryReader(File.OpenRead(assetName))) { fileBytes = freader.ReadBytes((int)freader.BaseStream.Length); } if (fileBytes.Length > sizeof(int)) { int header = System.BitConverter.ToInt32(fileBytes.Take(4).ToArray(), 0); if (GAFHeader.isCorrectHeader((GAFHeader.CompressionType)header)) { var path = Path.GetDirectoryName(assetName) + "/" + Path.GetFileNameWithoutExtension(assetName) + ".asset"; var asset = AssetDatabase.LoadAssetAtPath(path, typeof(GAFAnimationAsset)) as GAFAnimationAsset; if (asset == null) { asset = ScriptableObject.CreateInstance <GAFAnimationAsset>(); asset = GAFAssetUtils.saveAsset(asset, path); } asset.name = Path.GetFileNameWithoutExtension(assetName); asset.initialize(fileBytes, AssetDatabase.AssetPathToGUID(path)); EditorUtility.SetDirty(asset); GAFResourceManager.createResources(asset); GAFTracking.sendAssetCreatedRequest(assetName); } } } } }