vrm-c / UniVRM

UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.dev/en/ . 日本語 はこちら https://vrm.dev/
https://vrm.dev/en
MIT License
2.64k stars 424 forks source link

UniGLTF / VRMShader assembly file autoReference setting needs to be true for UPM package import #993

Closed dblatner closed 3 years ago

dblatner commented 3 years ago

VRMShader assembly definition file needs to set "autoReference" property to "true" .

Otherwise, when importing UniGLTF/VRMShaders as UPM package, Unity throws an error that type references are missing. (e.g. when using gltfExporter.Export(...) method).

I checked latest pre-release version 0.75 .

Should be a very quick fix :-)

ousttrue commented 3 years ago

I don't know how to reproduce the problem. Please tell me the details 👀

dblatner commented 3 years ago

@ousttrue : steps for reproduction:

  1. import VRMshaders and UniGLTF as packages into Unity
  2. create a script for runtime importing a GLB file (using ImporterContext etc.)

-> Unity shows an error in the console similar to this error CS0012: The type 'SubAssetKey' is defined in an assembly that is not referenced. You must add a reference to assembly 'VRMShaders.GLTF.IO.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Then, if you set VRMshaders assembly definition file "autoReference", Unity will work with UniGLTF/VRMshaders as expected.

Most of the time, "autoReference" should be enabled on asmdef files.

image

Santarh commented 3 years ago

Thanks your description!

For the clean code design, we use the Assembly Definition and disallow the Auto Referenced property explicitly. ​ You need to use the Assembly Definition file in your own code.

refs: https://docs.unity3d.com/2019.4/Documentation/Manual/ScriptCompilationAssemblyDefinitionFiles.htm

naninunenoy commented 3 years ago

It seems too advanced to force everyone to use asmdef. :exploding_head: I also think asmdef is useful, but I think autoReference=true is better because it gives the choice to use or not use asmdef.

Santarh commented 3 years ago

Some asmdef files has been set Auto Referenced true since v0.79.0 !