UIWidgets
UIWidgets copied to clipboard
How to integrate this plugin with other assets using RSG.Promise library?
Hello guys,
Thanks for this project, it looks very interesting! I'm the author of this plugin https://github.com/proyecto26/RestClient and I was wondering if you can give me some instructions to integrate both plugins, I'm getting the following issue because we're using RSG.Promise library :)

Thanks in advance, Juan
Since both UIWidgets and your plugin include the RSG.Promise library, there will be two copies of this library in the integrated project. Therefore the compiler cannot figure out which copy should be used. Maybe this solution https://stackoverflow.com/questions/3672920/two-different-dll-with-same-namespace could help to solve this problem?
Hi Xingwei, thanks for your response! I can rename the namespace of RSG.Promise library but I'm not sure if it's the best way, what do you think? 😅
A better way could be removing one of the libraries. The RSG.Promise library used in UIWidgets is under [UIWidgetsPackageFolder]/Runtime/promise/, simply deleting them all may work ?
Hi Xingwei, thanks for your quickly response!
I was trying to delete that folder but I have these warnings:
Assets/UIWidgets/Runtime/async/coroutine.cs(5,7): error CS0246: The type or namespace name 'RSG' could not be found (are you missing a using directive or an assembly reference?)
Assets/UIWidgets/Runtime/cupertino/button.cs(2,7): error CS0246: The type or namespace name 'RSG' could not be found (are you missing a using directive or an assembly reference?)
Assets/UIWidgets/Runtime/cupertino/localization.cs(3,7): error CS0246: The type or namespace name 'RSG' could not be found (are you missing a using directive or an assembly reference?)
Assets/UIWidgets/Runtime/cupertino/route.cs(3,7): error CS0246: The type or namespace name 'RSG' could not be found (are you missing a using directive or an assembly reference?)
....
This is the repo of the app => https://github.com/proyecto26/unity-restclient-app
Any help is really appreciated and sorry for the delay! 👍
And guys, are you using the last version of C-Sharp-Promise? https://github.com/Real-Serious-Games/C-Sharp-Promise/releases/tag/v3.0.1
I'm getting this warning from VSCode:

Let me know 👍
Ok, I was trying to fix that issue by updating the Assembly Definitions:
- Unity.UIWidgets.asmdef
{
"name": "Unity.UIWidgets",
"references": [
"RSG",
"Unity.InternalAPIEngineBridge.024"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}
- And creating a RSG.asmdef
{
"name": "RSG",
"references": [
"Unity.InternalAPIEngineBridge.024"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}
But I have these other errors:
Assets/UIWidgets/Runtime/async/coroutine.cs(25,65): error CS1739: The best overload for 'Promise' does not have a parameter named 'isSync'
Assets/UIWidgets/Runtime/material/scaffold.cs(918,28): error CS1061: 'Promise<SnackBarClosedReason>' does not contain a definition for 'isCompleted' and no accessible extension method 'isCompleted' accepting a first argument of type 'Promise<SnackBarClosedReason>' could be found (are you missing a using directive or an assembly reference?)
Assets/UIWidgets/Runtime/widgets/routes.cs(147,49): error CS1061: 'Promise<object>' does not contain a definition for 'isCompleted' and no accessible extension method 'isCompleted' accepting a first argument of type 'Promise<object>' could be found (are you missing a using directive or an assembly reference?)
...
Any help is really appreciated, thanks!
Hi, sorry for the late reply. Please try the following steps:
(1) remove the RSG folder under UIWidgets (just as what you have done) (2) add asmdef files to UIWidgets and add "RSG" to its references (3) add "bool isCompleted { get; } " to the two classes, i.e., "IPromise<PromisedT>" and "Promise<PromisedT> : IPromise<PromisedT>, IPendingPromise<PromisedT>, IPromiseInfo" in Promise.cs under your RSG library source folder. Very sorry that in UIWidgets we modified these codes a bit to our convenience. (4) add "RSG" to the reference lists of the following two asmdef files, UIWidgetsSample.asmdef and UIWidgetsGallery.asmdef
Hope you can make it works then. Inform me if there is still anything wrong. Thanks !
Is it possible to do that without modify RSG library? Maybe in a next version of UIWidgets, what do you think? Thanks for your help mate!
mmm It looks like the modified version of RSG library requires Unity.UIWidgets.ui, and I can see a cycle dependency using asmdef files with the references, i.e. UIWidgets <= RSG <= UIWidgets 🤔
I don't think there is any cycle dependency involved here. Please refer to this commit for details: https://github.com/zhuxingwei/unity-restclient-app/commit/97e7d627b790409d4a10436fc92aefd6d6097e8c
Currently UIWidgets will remain all our modifications on the RSG library.
Ohh I mean, you're using objects of Unity.UIWidgets.ui from RSG Library
- https://github.com/UnityTech/UIWidgets/blob/master/Runtime/promise/Promise.cs#L410
- https://github.com/UnityTech/UIWidgets/blob/master/Runtime/promise/Promise.cs#L444
- https://github.com/UnityTech/UIWidgets/blob/master/Runtime/promise/Promise_NonGeneric.cs#L506
- https://github.com/UnityTech/UIWidgets/blob/master/Runtime/promise/Promise_NonGeneric.cs#L541
- https://github.com/UnityTech/UIWidgets/blob/master/Runtime/promise/Promise_NonGeneric.cs#L1050
Can we remove these references? Is that code not required? 😅
Because I'm having these warnings from the last version of my repo:
Assets/Packages/RSG/Promise.cs(6,23): error CS0234: The type or namespace name 'ui' does not exist in the namespace 'Unity.UIWidgets' (are you missing an assembly reference?)
Assets/Packages/RSG/Promise_NonGeneric.cs(6,23): error CS0234: The type or namespace name 'ui' does not exist in the namespace 'Unity.UIWidgets' (are you missing an assembly reference?)
Thanks for all your help!
Yes you are right, we did REALLY change a lot in the RSG lib :(
To solve this problem in your app, one straight-forward solution is to use the RSG lib from UIWidgets. Since the lib in UIWidgets is something that extends the original RSG lib, it seems to be just ok?
Anyway, modifying a third-party standard lib is not elegant, we will try to find a way to address this issue later when we are free.
Thanks a lot for your suggestions !
Sorry guys, any progress to fix this issue? Thanks in advance! 👍
Sorry for the late response. The team is currently working on other issues in our next milestone, therefore is not available for this fix yet.
I will work on this in the weekends and inform you my progress next week
Thanks mate, let me know if I can help in any task of that refactor 🙏
Hi. after some discussions about this issue, we believe one of the best solutions is to modify the namespace of the RSG lib in uiwidgets to something like uiwidget.RSG.
However, since this could be a huge breaking change for the users of uiwidgets, we need to come up with a full plan to release it. This means, we won't formally ship this fix until our next milestone early next year.
Before that, you can use this walkaround (https://github.com/UnityTech/UIWidgets/issues/214#issuecomment-532563254). Please let me know if you have any good ideas about this issue. Thanks a lot !