Unity-Technologies / com.unity.demoteam.hair

An integrated solution for authoring / importing / simulating / rendering strand-based hair in Unity.
Other
719 stars 97 forks source link

Impossible to access DemoTeam namespace in code #30

Closed methusalah closed 1 year ago

methusalah commented 1 year ago

I want to change the solver settings via code (for example to dry hair over time by having less and less gravity applied).

But it seems that I cannot access the Unity.DemoTeam namespace and end up with this message in the console "Assets\Scripts\Kinematic\HairInstanceController.cs(3,13): error CS0234: The type or namespace name 'DemoTeam' does not exist in the namespace 'Unity' (are you missing an assembly reference?)"

I'm am able to manually include the DLL in the solution in Visual Studio, but whenever I go back to Unity, it recompile and remove the dependency.

The package is present in the package manager. Here is what I tried:

Anyhow I can't access any of the demoteam.hair public script via code.

Is there something I am missing here? is it because the package is experimental?

qlee01 commented 1 year ago

Hey, see my reported issue #3 Only way to access I found was to change the assembly file and set autoreferenced to true inside the Hair package. This is far from optimal, and it would be an easy change to do this in the repo.

methusalah commented 1 year ago

@qlee01 thank you for pointing it out, but I have no knowledge on the matter. Could you be a little more explicit about how to do what you describe, for my sake and others' that might end up here?

Thank you in advance

qlee01 commented 1 year ago

In the Hair package Runtime folder, find the file Unity.DemoTeam.Hair.Runtime.asmdef, and set "autoReferenced": true. There might me more asmdef files which need change (in Editor folder). This basically allows the default namespace in C# to access the scripts. (default namespace = no explicit namespace stated). If you are already using namespaces, there might be better options to include the namespace of Hair package, but I also don't have much knowledge about this.

methusalah commented 1 year ago

Thanks, it seems to work for me. I just had to restart Unity.

I can't tell why it is like that, though. Is there any point to have the package not referenced like this? Having available components but not being able to get the associated script seems odd and a bad design. Or maybe it is a way to ensure people will not reach the API, because it is still a WIP and experimental?

Anyway it solved my issue so I close this.