Skip to content

Commit

Permalink
fix some module-related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Sep 2, 2022
1 parent 0306636 commit f73cf8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ private struct ImageInfo
private List<ImageInfo> _imageInfos;
private List<Texture> _textures;
private Dictionary<int, int> _exportedMaterials;
#if ANIMATION_SUPPORTED
private List<(Transform tr, AnimationClip clip)> _animationClips;
#endif
private bool _shouldUseInternalBufferForImages;
private Dictionary<int, int> _exportedTransforms;
private List<Transform> _animatedNodes;
Expand Down Expand Up @@ -299,7 +301,9 @@ public GLTFSceneExporter(Transform[] rootTransforms, ExportOptions options)
_imageInfos = new List<ImageInfo>();
_exportedMaterials = new Dictionary<int, int>();
_textures = new List<Texture>();
#if ANIMATION_SUPPORTED
_animationClips = new List<(Transform, AnimationClip)>();
#endif

_buffer = new GLTFBuffer();
_bufferId = new BufferId
Expand Down Expand Up @@ -811,6 +815,7 @@ private void ExportAnimation()
}

#region Public API
#if ANIMATION_SUPPORTED

public int GetAnimationId(AnimationClip clip, Transform transform)
{
Expand All @@ -821,6 +826,7 @@ public int GetAnimationId(AnimationClip clip, Transform transform)
}
return -1;
}
#endif

public MaterialId GetMaterialId(GLTFRoot root, Material materialObj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public UnityWebRequestLoader(string dir)
{
this.dir = dir;
}

#if UNITY_WEBREQUEST
public async Task<Stream> LoadStreamAsync(string relativeFilePath)
{
var path = Path.Combine(dir, relativeFilePath).Replace("\\","/");
Expand Down Expand Up @@ -41,6 +41,13 @@ public async Task<Stream> LoadStreamAsync(string relativeFilePath)
var stream = new MemoryStream(results, 0, results.Length, false, true);
return stream;
}
#else
public async Task<Stream> LoadStreamAsync(string relativeFilePath)
{
await Task.CompletedTask;
throw new System.ApplicationException("The module com.unity.modules.unitywebrequest is required for this functionality. Please install it in your project.");
}
#endif

// TODO: figure out how to do this correctly in a streaming fashion.
// private class DownloadStreamHandler : DownloadHandlerScript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace UnityGLTF
{
public partial class GLTFSceneExporter
{
#if ANIMATION_EXPORT_SUPPORTED
#if ANIMATION_SUPPORTED
private readonly Dictionary<(AnimationClip clip, float speed), GLTFAnimation> _clipToAnimation = new Dictionary<(AnimationClip, float), GLTFAnimation>();
#endif
#if ANIMATION_SUPPORTED
Expand Down Expand Up @@ -66,7 +66,7 @@ public void ExportAnimationFromNode(ref Transform transform)
exportAnimationFromNodeMarker.End();
}

#if ANIMATION_EXPORT_SUPPORTED
#if ANIMATION_SUPPORTED
private IEnumerable<AnimatorState> GetAnimatorStateParametersForClip(AnimationClip clip, AnimatorController animatorController)
{
if (!clip)
Expand Down

0 comments on commit f73cf8b

Please sign in to comment.