Open DmitriyYukhanov opened 4 years ago
Dmitriy! :)
I know and I tried various times with different approaches, but the problem is that DOTween relies a lot on the ability to modify its files (that's how the modules work), so they can't stay inside the UPM storage, and it's complicated to implement a mixed system like that aaaand make it work also on older version of Unity :P
(but in general it's complicated regardless of older versions of Unity :P)
Ah, yeah, I totally understand this, thank you for trying anyways! Just hope some day you'll be able to solve this, I believe you'll win this battle! \o/
But until this will happen, it would be super great to just let it work from packages as is ^^
I mean something like this:
move settings out from the Assets folder to the Project\ProjectSettings using
UnityEditorInternal.InternalEditorUtility.SaveToSerializedFileAndForget() UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForget()
make plugin's root path dynamic and try look for resources and such independently from current DOTween \ DOTweenPro path
disable ability to change modules when working from packages
So it could be imported and configured as usual in Unity's Assets folder but keep working in that state while it's wrapped in package as is and used in such state from the UPM ecosystem.
Ohhhh I didn't know those UnityEditorInteral methods, I like that!!!!
I thought of disabling module changes when using UPM, but the problem is that some modules depend on if the relative asset is present (like TextMesh Pro) so they need to be activated/deactivated. Otherwise if I keep them always deactivated there will be no TextMesh Pro shortcuts, and if I keep them always activated it will not work on projects without TextMesh Pro :|
Buuuut! I could use SaveToSerializedFileAndForget for the modules too. I will test this :)
Thank you!
Even without possibility to switch modules it would be already great - those who wish to switch could make two different packages =D
Since it's just a workaround - it's totally fine!
but the problem is that some modules depend on if the relative asset is present (like TextMesh Pro) so they need to be activated/deactivated
How about the conditional compilation symbols? You could define something like DOTWEEN_TMPRO in the project rather than toggle this #if true // MODULE_MARKER
in the source code
but the problem is that some modules depend on if the relative asset is present (like TextMesh Pro) so they need to be activated/deactivated
How about the conditional compilation symbols? You could define something like DOTWEEN_TMPRO in the project rather than toggle this
#if true // MODULE_MARKER
in the source code
I have seen this in zenject, they have support for unirx which can be enabled if you have unirx installed and define a symbol as seen here, don't know if you would be able to edit asmdef from a upm package
Ohhhh I didn't know those UnityEditorInteral methods, I like that!!!!
I thought of disabling module changes when using UPM, but the problem is that some modules depend on if the relative asset is present (like TextMesh Pro) so they need to be activated/deactivated. Otherwise if I keep them always deactivated there will be no TextMesh Pro shortcuts, and if I keep them always activated it will not work on projects without TextMesh Pro :|
Buuuut! I could use SaveToSerializedFileAndForget for the modules too. I will test this :)
Unity a year ago brought out this 2018.4+ compatible package (I don't know if it works in older versions) that I have personally used many times in our code base and it works very well.
https://docs.unity3d.com/Packages/com.unity.settings-manager@1.0/manual/index.html
On the one hand it tries to homogenize the fact of where the configuration files are saved and avoid what has happened so far that everyone has done it as they wanted: ScriptableObjects, XML, JSON, Resources, StreamingAssets, at the root of the project, hardcoded relative paths...
On the other hand, it allows it to be more integrated in the project configuration windows as one more section and to be integrated in the search.
And finally and most importantly, for simple cases the windows are built "alone" through the data model. For complex cases it's also possible and it's not hard to implement (there are examples in the package).
Unity a year ago brought out this 2018.4+ compatible package (I don't know if it works in older versions) that I have personally used many times in our code base and it works very well.
https://docs.unity3d.com/Packages/com.unity.settings-manager@1.0/manual/index.html
Yeah this is nice generalized way to store settings in packages though it makes me upset they choose EditorPrefs over UserSettings folder (default one for 2020.1+) for the UserSettingsRepository (implemented own settings storage at UserSettings \ ProjectSettings in my plugins).
Relates to: https://github.com/Demigiant/dotween/issues/251
Hey, just hit this issue as well. I just wanted to point out that the UniTask DOTween extensions only work with the UPM fork. This is because it uses some system that changes precompiler flags based on presence of the DOTween dependency.
This issue could of course be raised with UniTask, but as far as I can tell their approach is pretty airtight, so it'd be best to fix this on your end.
Also, annoyingly, the fork is currently behind this repository by quite a few commits.
I think you can get rid of the conditional compilation of each of the sub-modules by putting them in different asmdefs and letting the user choose which they wish to add as dependencies of their main asmdef. Obviously this is going to be have back-compatibility issues, but perhaps you could either maintain two forks, or simply drop support with a major version update?
Anyway, just wanted to share some thoughts. Thanks for the package. :-)
Unity also now supports conditionally defining Preprocessor Symbols based on currently installed packages like TextMeshPro: https://docs.unity3d.com/2020.1/Documentation/Manual/ScriptCompilationAssemblyDefinitionFiles.html?_ga=2.36724064.1999471002.1620662952-1271225660.1595348587
This might help with reducing the need to modify any script files.
+1 For this. Working on converting an internal framework to UPM, and we did use DOTween in some places. Would love to keep using it but since I can't add it as a package dependency it's not viable to keep dragging asmdef files, Started rewriting chunks to remove it as a dependency. PS: I agree, not having modules is an acceptable compromise.
Bump
Anyone commenting here should probably take a look at the main thread in #251
I'm trying to use DOTween inside one of our private UPM packages, and having similar sorts of issues as here. In our case, we already put the Modules
folder in the right place, so that worked fine, it was just having trouble loading the right logos and things for the editor windows.
To fix it, I copied the files from Demigiant\DOTween\Editor\Imgs
to Assets/s/com.mycompany.mypackage/Demigiant/DOTween/Editor/Imgs
Getting those paths required a little digging, but if you want to do it programmatically (say, in an editor window or menu or something), something like this worked for me:
var PackageImgsDir = $"{EditorUtils.dotweenDir}Editor/Imgs";
var TargetImgsDir = $"{EditorUtils.projectPath}/Assets/{EditorUtils.editorADBDir}Imgs"
Directory.CreateDirectory(TargetImgsDir);
Debug.Log($"Copying {PackageImgsDir} to {TargetImgsDir}");
foreach (var srcPath in Directory.GetFiles(PackageImgsDir, "*.*", SearchOption.AllDirectories))
{
if (srcPath.EndsWith(".meta")) continue;
var destinationPath = srcPath.Replace(PackageImgsDir, TargetImgsDir);
Debug.Log($"Copying {srcPath} to {destinationPath}");
File.Copy(srcPath, destinationPath, true);
AssetDatabase.Refresh();
}
I don't know why there's an /s
folder there there. This was done on Windows, use at your own risk, et. al.
Heya Daniele! =B
Would be great to make it possible to use DOTween Pro from the UPM package ^^ For now it does not works - I see errors when adding DOTweenAnimation for example:
NullReferenceException: Object reference not set to an instance of an object DG.DOTweenEditor.EditorUtils.SetEditorTexture (UnityEngine.Texture2D texture, UnityEngine.FilterMode filterMode, System.Int32 maxTextureSize) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/EditorUtils.cs:75) DG.DOTweenEditor.UI.EditorGUIUtils.get_logo () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/UI/EditorGUIUtils.cs:41) DG.DOTweenEditor.UI.EditorGUIUtils.InspectorLogo () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/UI/EditorGUIUtils.cs:124) DG.DOTweenEditor.DOTweenAnimationInspector.OnInspectorGUI () (at Packages/com.modumlab.thirdparty.tools.dotween-pro/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs:219) UnityEditor.InspectorWindow.DoOnInspectorGUI (System.Boolean rebuildOptimizedGUIBlock, UnityEditor.Editor editor, System.Boolean wasVisible, UnityEngine.Rect& contentRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1625) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
And I see empty settings window with this text (no scripts compilations is in process at that moment):![image](https://user-images.githubusercontent.com/883587/81460919-0e194f00-91b1-11ea-9496-bfbf445f5ea9.png)