losttech / Gradient

This repository serves as a public issue tracker and documentation host for Gradient, full TensorFlow binding for .NET
Other
86 stars 4 forks source link

Namespace Gradient makes tool incompatible with Unity 2019.3 #25

Closed maxiboch closed 4 years ago

maxiboch commented 4 years ago

Unity has an internal type called Gradient, which it references in scripts that are automatically generated by Unity 2019.3's package manager. As such, it's impossible to use Gradient with Unity 2019.3.

Given that the source isn't available, would it be possible for you to compile & provide another version of this library with an alternate, less generic namespace?

lostmsu commented 4 years ago

This will probably miss Preview 7, but we are planning to switch the namespace to LostTech.TensorFlow and LostTech.Gradient in subsequent releases.

Was this type introduced in Unity recently? This would help to decide severity of the issue.

Also, in C# you can refer to specific names via global:: prefix and extern alias keyword. E.g. using global::Gradient; should import Gradient's types even if Unity has a class with the same name.

If the problem is in the generated scripts, which you can't control, this issue should be reported to Unity too, as generated code should always use fully qualified names (e.g. with global:: prefix) to avoid conflicts like this.

lostmsu commented 4 years ago

I must also warn you, that there's a known issue with Unity and Python.Runtime package Gradient uses, that leads to crashes in Unity, which is related to domain reloading.

maxiboch commented 4 years ago

Thanks for the prompt reply! Glad to hear about the upcoming changes.

This type is long-standing in Unity, but I was able to get around it using prefixes & the like, but with 2019.3, they've introduced some generated scripts related to the UI for UnityEngine.Gradients.

I've let my Unity rep know about this issue as well.

I was previously using TensorSharp, but was transitioning to Gradient when I upgraded the engine to the latest release. Can you avoid the issues with the Python.Runtime by disabling Domain Reloading?

lostmsu commented 4 years ago

At this moment you will just have to try it. I believe it should alleviate the problem, but from the documentation it looks like this might complicate game development loop, as you'd have to write code resetting state correctly when playback is started/stopped in the IDE.

We have not actually tried to use Gradient inside Unity yet, but I am working closely with a team within Unity, who are using Python.Runtime themselves, and are thus working on the domain reloading problem.