Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.29k stars 344 forks source link

DOTween Pro 1.2.375 CanvasGroup methods missing #643

Closed arvinkx closed 11 months ago

arvinkx commented 11 months ago

I am unable to use any of the UI module shortcuts in my scripts, I'm getting the following error:

'CanvasGroup' does not contain a definition for 'DOFade' and the best extension method overload 'ShortcutExtensions.DOFade(Material, float, float)' requires a receiver of type 'UnityEngine.Material'

I've setup DOTween Pro in my standard Unity project as per the instructions (http://dotween.demigiant.com/pro.php#installation), I'm not using assemblies and I have setup DOTween in the utility panel. I can verify that the UI modules are active (the code is not commented out) and I see a dll in the DOTween folder.

I've tried restarting Unity / VS, I've tried regenerating project files and deleting the csproj files manually and restarting but I still am having the same issue. I am able to initialize DOTween and use the other direct functions but the UI functions are not available.

Is there anything else I can try to get the scripts to compile?

Unity Version: 2022.3.1f1 (Mac OS)

Demigiant commented 11 months ago

Ahoy,

The only thing I can think of is that somehow the UI modules weren't activated. Can you open the file "DOTweenModuleUI.cs" (inside Assets/Plugins/Demigiant/DOTween/Modules) and see if its content is greyed out and if the condition at line 4 is active? It should read: #if true && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER and maybe for some reason (which I will investigate if this is happening) it says #if false... instead?

Demigiant commented 11 months ago

P.S. if it says #if true but the file is still greyed out, please try replacing that whole line 4 with simply this: #if true // MODULE_MARKER and see if it works?

Let me know!

arvinkx commented 11 months ago

Line 4 did have the full line (including the true and UNITY_4_6 ||... part) but the file was greyed out so I removed the rest and just left the true (#if true) which made the file activate but I still have the same issue. I also tried restarting Unity after that and still no luck.

Demigiant commented 11 months ago

Mhmm the fact that the file was still greyed out means that in that specific Unity version they forgot to enable the UNITY_2017_1_OR_NEWER define (it happened a couple times in the past then they fix it in the next version, but I'm going to fix that forever on my side). But the fact that it still doesn't work after you fixed it by replacing it all with #if true // MODULE_MARKER (don't remove the "// MODULE MARKER" part by the way, that's important in case you want to disable UI shortcuts for some reason) is just weird. In that case, I think you have an issue with VS or VSCode (those two have problems with extension methods sometimes) not updating correctly, meaning they will mark your code red while Unity won't actually find any issues. To fix that, delete all the .sln and .csproj files in your project's root and let Unity recreate them (sorry for this, gonna investigate more).

Let me know if this finally solved it.

Demigiant commented 11 months ago

P.S. Just published a new version of DOTween Pro that fixes that missing define problem, but you might still have to delete the .sln and .csproj files (I don't have any other fix for that I'm afraid: it's very rare and it's on VSCode/VS side and their Unity integration)

arvinkx commented 11 months ago

I've tried deleting the .sln and .csproj files and restarting as well as updating to 1.0.370 of DOTween Pro and I'm still experiencing the issue. I can call the static function (DOTweenModuleUI.DOFade()) but I can't call the function on a canvas group object.

Demigiant commented 11 months ago

Could you try to write a tween like this in your code?

canvasGroupReference.DOFade(0, 1);

Your IDE is going to mark it red from what I understand, but can you save and let Unity compile it, and see if Unity is reporting an error in the code (about the missing DOFade method) or if it's just your IDE (I assume it's going to be like that)? That would make it 100% sure that the problem is related to a coding IDE gone crazy, in which case let me know what IDE are you using and which version and I'll see what issues they might have. If instead Unity is also reporting errors, please attach a screenshot of the expanded console log so I can check it out.

P.S. In the meantime you can always use the generic method to animate anything, but the UI shortcuts definitely shouldn't be disabled so I'd like to understand what's happening.

arvinkx commented 11 months ago

The error was in the Unity console as well but I think this had something to do with a combination of Perforce and Visual Studio / Unity. I resolved the issue by submitting files to source control and trying on a different PC (which worked) then pushed the changes back to the Mac and it ended up working there as well.