Closed vishalpvr123456 closed 7 years ago
Could you please give a little more sample code. Just from reading this short error text, it is hard to analyze what is going wrong.
Above i put my project screenshot i hope it will be help to understand my problem or error. I am trying your code in unity 5.3.1f so its a problem or other .... please help me ...thanks
This problem looks strange, because both types seem to be the same, so no cast should be needed. Nevertheless, have you tried to cast?
You could test the following three variants. (Please tell me if one of it worked for you.)
1) QRCodeData qrCodeData = (QRCodeData)qrGenerator.CreateQrCode("Hi", QRCodeGenerator.ECCLevel.Q);
2) QRCodeData qrCodeData = (qrGenerator.CreateQrCode("Hi", QRCodeGenerator.ECCLevel.Q) as QRCodeData);
3) var qrCodeData = qrGenerator.CreateQrCode("Hi", QRCodeGenerator.ECCLevel.Q);
None of these are not working..still i got same error
Can copy the stacktrace or send a more detailed log of the error? Otherwise, would you mind to upload your sample unity project, so that I can test it on my hardware?
i sent you unity package of my project in zip..
Hello, You tested my project ?
I think I got the problem. You "imported" QRCoder libs twice. On the one hand you imported the QRCoder.dll as reference and on the other hand, you added QRCodeData.cs and UnityQRCoder.cs as single files.
When Mono/Unity tries to compile, it prefers the .cs-files over the .dll. Unfortunately your .cs-files are in a different version and you added just some .cs-files but not all, which are needed. So it comes to an conflict between the .cs-file QRCoder implementation and the .dll QRCoder lib.
The easiest way to fix this, is to remove the both .cs-files (QRCodeData.cs, UnityQRCode.cs) from your Mono project. Then the complete code will be delivered by the QRCoder.dll.
If i remove both than it will work ? because all QR Code generator code in those files so i ask you
Yes that's correct. You just need the QRCoder.dll (and of course your own coding in the Behaviour.cs file). Please give a quick feedback, if it worked for you.
not even require of UnityQRCode.cs ? i am confuse here ...please
In the unitypackage you uploaded some posts ago, there were multiple files. Besides others I found the "QRCoder.dll", "UnityQRCode.cs" and "QRCodeData.cs".
You only need the QRCoder.dll - the DLL file is the complete library packed into one file. It holds the compiled versions of UnityQRCode.cs, QRCodeData.cs and all the other .cs-files of the QRCoder library.
So you have the choice. Either you include all source files from this Github repository (except the QRCoder.dll), then the library will be compiled, when your Unity project will be compiled.
Or you just embed the QRCoder.dll in you Unity project and forget about all .cs-files. The first option gives you the chance to rewrite or change the QRCoder library. The second option, is easier to implement and has less overhead.
At the moment you took a bit of both approaches. You included the QRCoder.dll and some of the .cs-files. Since the QRCoder.dll has another version as the .cs-files you embedded, Unity/MonoDevelop finds a conflict. He tries to map the QRCodeData object from the cs-file to the version of QRCodeData from the DLL library. Since they're are not at the same version you get the error.
By removing the .cs-files Unity/Monodevelop will take all code from the .dll-file. So your solution should become consistent and so the error should be resolved.
@vishalpvr123456 Did my solution work for you?
ArgumentException: The Assembly System.Drawing is referenced by QRCoder ('Assets/Plugins/QRCoder.dll'). But the dll is not allowed to be included or could not be found.
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary
2 cache, BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:156)
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary
2 cache, BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:162)
UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:194)
UnityEditor.HostView:OnGUI()
i got this error after removing files and this error comes at build time
Seems like something with your compilation target isn't right. You could try this answer: http://answers.unity3d.com/questions/53170/using-drawing-package-like-systemdrawing.html
Or otherwise you could use the PCL version of QRCoder (which I released last Saturday). Indeed the PCL version only has the BitmapByteQRCode class and not the UnityQRCode class, but therefore it's crossplatform. And there are also methods to create a Texture2D from the byte[] which is generated by the QRCoder PCL.
i got this error in unity "Cannot implicitly convert type
QRCoder.QRCodeData' to
QRCoder.QRCodeData'" help me out guys...thnks in advanced