Creating Wp8 Unity Plugin in Unity 5.0 - c#

I have a windows phone 8.0 plugin created for an app. This app worked perfectly fine in Unity 4.5. I recently updated my Unity to 5.0. I also saw all the needed alterations.
Initially, we needed to create two plugin dlls. One actual and one empty simply like an interface for the editor. This went pretty well in unity 4.5
Now i open the same app in Unity 5.0 by upgrading it. and i am unable to build it for wp8 anymore. I set the inspector platforms correctly to WP8 player for my plugin dll.
But, i keep getting errors like ::
1. Plugins are colliding.
2. There are errors in the script (which are actually not)
3. Cannot load classes from module.
4.System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
etc.
Can anybody help me? I have tried several things already but none seems to work.
I tried :
1. Reimporting everything
2. Rebuilding the dlls.
3. Removing the empty interfaced dll for editor
4. Changing the folder structure for plugins. (Default being
Assets/Plugins/WP8)
I am stuck here since two days now.

Well, it's too late to reply. But anybody else stuck in same problem may get help.
One should know that WP8 Plugins are based on real and fake dlls in order to work in Unity Editor.
In Unity 5, you can specify platform to dll, irrespective of folder structures. However if you put dll in Assets->Plugins->WP8. Unity will mark it as WP8 dll.
Solution is,
1- Put Fake dll in Assets->Plugins->AnyFolder->plugin.dll, where any AnyFolder is other than WP8 folder. Mark it as Editor instead of Any Platform (from inspector [Select platform for plugins]).
2- Put Original dll in Assets->Plugins->WP8->plugin.dll, mark it as WP8Player
3- Keeping original dll selected, in Platfrom Settings [Inspector] modify settings like, CPU -> Any CPU, check mark on Don't Process, Select placeholder.
Placeholder drop down would show the path of fake dll, just set it.
Now you are all done :)

You must set the editor DLLs to "Editor" instead of "Any Platform" and the WP8 plugins to "WP8Player" in the plugin settings.

Related

Xamarin.Forms App crashes on iOS when installed via Testlfight

Hello fellow developers!
I am developing a Xamarin.Forms App for android and iOS.
It works fine in Debug and Release mode on Android Emulators, Android Devices, iOS Emulators.
But there is a problem with iOS Devices. Directly deploying the Debug/Release Builds to a device works. But when I upload the app to the AppStore and install it via Testflight on my device, it crashes on startup.
From the console I can see following errors:
"System.MissingMethodException: Default constructor not found for type App.Views.Login"
"Default constructor not found for type ColorPicker.iOS.Effects.ColorPickerTouchEffectiOS"
The first one is related to my Login View, which has a default constructor and works fine in debug and release builds.
The second one is related to a nugget package.
My question is:
Why are the default constructors available in Debug and Release but not when i download the app via Testflight? And how can I fix this?
Linking behaviour is set to "Link all".
That's because when you use the Link all assemblies option you need to manually preserve the classes in your project and potentially mark out library code that isn't linker safe.
There is a Microsoft document specifically catering to this question : https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=macos
You could set your linker behaviour to Link SDK assemblies only temporarily while you manually get ready for a full link.
Preservin code:
When you use the linker it can sometimes remove code that you might have called dynamically either using System.Reflection.MemberInfo.Invoke, or by exporting your methods to Objective-C using the [Export] attribute and then invoking the selector manually.
In those cases, you can instruct the linker to consider either entire classes to be used or individual members to be preserved by applying the [Xamarin.iOS.Foundation.Preserve] attribute either at the class-level or the member-level. Every member that is not statically linked by the application is subject to be removed. This attribute is hence used to mark members that are not statically referenced, but that are still needed by your application.
Skipping Assemblies
It is possible to specify assemblies that should be excluded from the linker process, while allowing other assemblies to be linked normally. This is helpful if using [Preserve] on some assemblies is impossible (e.g. 3rd party code) or as a temporary workaround for a bug.
--linkskip=NameOfAssemblyToSkipWithoutFileExtension // Single assembly
--linkskip=NameOfFirstAssembly --linkskip=NameOfSecondAssembly // Multiple Assemblies
Hope this helps. Make sure you go through the MS doc for more details

Unity Editor freezes for couple of seconds when hitting play - Firebase.Editor error

I am building an Android game and the problem is that any time I click Play in Unity editor, it has a delay of 6-10 seconds (and maybe more) at the very beginning (like freezing) every time I make a change and build the project which is very frustrating and time consuming (only in editor though, on Android devices it's fine). In this link, it looks like there are more people having this problem. So, one suggestion was to remove Google.IOSResolver_v1.2.156.dll and it's .meta files from ExternalDependenceManager folder. I tried it and indeed it's loading much faster which clearly points out that there is a problem with IOSResolver in Unity Editor. Removing the files, bring me following errors:
Assembly 'Assets/Firebase/Editor/Firebase.Crashlytics.Editor.dll' will not be loaded due to errors:
Reference has errors 'Firebase.Editor'.
Assembly 'Assets/Firebase/Editor/Firebase.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'Google.IOSResolver'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
I can ignore them since they are not really causing any problems, but is there any other solution?
Maybe completely remove iOS Firebase plugin? I already installed only Android plugins though.
I checked also this link but doesn't really helped me.
Note that I already tried with a completely empty project using Firebase causes the same problem.
UPDATE
Installed the latest version of EDM4U (external-dependency-manager) 1.2.157 and the problem persists.
I had the same issue with AdMob earlier. Make sure the IOS plugin is installed by going into Unity Hub -> Installs -> 3 dots on Unity version -> Add Modules and select iOS Build Support. That fixed for me even though I don't develop for IOS.

Unity 3D single build for various projects

I need to develop a single Unity3D standalone build for separate project modules.
Consider, I have various projects related to 'Physics' for the 12th grade, which contains separate models, images and their respective functionality. For example, Project1: 'Optics', Project2: 'Electrostatics', Project3: 'Dual Nature of matter' and so on. All of these projects are independent of each other in terms of functionality and are complete on their own. Now, I create a 'Unity build'(say, for android initially) that contains a menu layout along with hyperlinks to download separate projects aforementioned from a server. The requirement is to allow the user to download a project(Say, project1: 'Optics') jar/build out of many projects available as an extension/addition to the previous 'Unity build'(even if the size of the build already installed might increase on device). As soon as the project is downloaded, the user should be able to run the project module over the 'Unity Build' instead of running a separate application. Similarly, when the user is done with the downloaded project module(Project1: 'Optics'), another project module(say,Project2 : 'Electrostatics') can be downloaded from the menu of the build which will run over the same 'Unity Build'. The 'Unity build' application serves as an interface which can add a separate layer of encryption so that the projects cannot be downloaded over and run separately by any unrestricted user. Somewhat similar to a media player which can play various kinds of video files. However, in this scenario, I need to run various project modules.
I am looking to create builds for different platforms - Android, Windows, iOS and Web browser (if possible) with similar functionality.
Any kind of help will be appreciated :)
Thanks!
There is a an "example" that comes with Unity as an install option and I believe it does exactly what you want, it has a menu where you can select different demos, where each demo is a project in itself. You should look into that.
Your question is mostly about organisation.
Sounds like your 'Unity build' is a kind of downloader with menue. May be this could be a website. Is the server a webserver?
The server has to have all projects for all possible plattforms, like a matrix.
If somebody starts to download a project, you have to choose the right build for his plattform.
To estimate the plattform, you could send a parameter with the link.
All of these points have many solutions depending on your requirements.
Good luck.
What you need are Asset Bundles.
What are they?
Compressed packages that serve as game extensions that can be downloaded and imported to a unity build at any time. With AssetBundles you can package scenes and load them into unity and load them.
How to create AssetBundles?
Basically you can select any Asset from your project and in the inspector you assign that Asset to a new AssetBundle in the inspector (at the bottom it says Create AssetBundle). A detailed section can be read here https://docs.unity3d.com/Manual/BuildingAssetBundles.html
In your case you should create many Asset Bundles with one scene in each.
How to download and load unity scene files from AssetBundles?
It could be a bit tricky but it has already been accomplished here http://forum.unity3d.com/threads/dynamically-load-scene-from-assetbundle.379316/
Common pitfall
Remember that AssetBundles aren't cross platform compatible. In other words, the Asset Bundle created is restricted only to the platform it is built for so you need to recreate your AssetBundles for each platform
Hope this helped!

Developing a Cross Platform XNA Library

I'm trying to develop a cross platform application.
Currently I have set up following solutions, with their platform specified template:
GameBase
Windows
Xbox
WindowsPhone
The Windows, Xbox and WindowsPhone uses the GameBase as reference, but I want to separate different code for each platform used in the GameBase library as the example below:
#if WINDOWS
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 480;
graphics.ApplyChanges();
#elif WINDOWS_PHONE
TargetElapsedTime = TimeSpan.FromTicks(333333);
InactiveSleepTime = TimeSpan.FromSeconds(1);
#endif
It does not work, and I can see that in the Configuration Manager, that GameBase's platform is Any CPU, so I wonder if it has anything to due with the GameBase being a Class Library?
If so how do I fix it, and if possible I would like to keep the #if tags.
Directory setup | Windows Solution Game.cs | Solution Explorer
You have to create separate Visual Studio projects for the different platforms. You can reuse code across multiple projects by adding the source using Add As Link. Within a shared source file that is linked to multiple project you can use #if etc. to separate platform specific code.
How "It does not work" is not clear from your question but in general you cannot build an assembly (e.g. class library) for Windows and then use it on XBox and Windows Phone.
Sharing projects between different project types is a tricky thing to do - just because of the way Visual Studio project types are used and because the different project types actually need to reference different versions of the dot net framework.
There are a few things that can assist:
the Portable Class Library tools - http://msdn.microsoft.com/en-us/library/gg597391.aspx
the Project Linker plugin - http://msdn.microsoft.com/en-us/library/ff921108(v=PandP.20).aspx
manual cut and paste (including add link like above)
Hope that helps a bit. Personally I'm currently mainly using manual cut and paste and hoping that the next version of the Portable Class Library helps (it is due for Win8 Metro stuff)
Not sure if this is your only problem but you mispelled WINDOWS_PHONE:
WINDOWS_HPONE
should be:
WINDOWS_PHONE
UPDATE:
The way that I would do it is I would create a class library solution calling it something like GameBaseLibrary. Then create a project there called GameBase and add all code in there that you would like to share across all the platforms. (I.E. Physics, data access, etc...)
Then in that same solution add XboxBaseLibrary, WindowsBaseLibrary, WindowsPhoneBaseLibrary and add code which is specific to each platform, add a reference in each of those projects to the GameBase project to use code from there in each of the three other projects.
Then create 3 different solutions types - Xbox, Window, Windows Phone and add the compiled dlls from GameBaseLibrary as a reference in each of them to be able to use the code. As you're working on each version of code (xbox, windows, windows phone) pay attention to code that you're typing to ensure that it's not something which can live within the GameBase class because you don't want to keep rewriting the same code.
This way, the bulk of the code is sitting in GameBaseLibrary and the platform specific code is sitting within each of the 3 other projects.
I hope this is clear.

Are there any known compatibility issues with Microsoft Media Platform: Player Framework (formerly SMF) and Silverlight 5?

I'm trying to get the default template (adaptive streaming) for the MMPPF framework to work.
Currently I'm not getting any error, but the player does not play any videos. I've tried adding other sources besides the default, I can see them added in the playlist, but they won't play either.
Using Fiddler I can see that the player does not even attempt to retrieve the manifest (or anything else).
The online example here works fine, I've even tried using that manifest as a source, but it still won't play when I run it in Visual studio.
So my question, could this have anything to do with having Silverlight 5 toolkit installed? I would assume that the MMPPF/SMF template is supposed to work out of the box (which is also stated on the Codeplex site). Or is there something else I'm missing?
You may need to add some references to your project. MMPPF is using MEF to resolve plugins at run-time, and it can fail silently if it doesn't find a suitable plugin.
For Smooth Streaming, you need both Microsoft.SilverlightMediaFramework.Plugins.SmoothStreaming and Microsoft.Web.Media.SmoothStreaming for it to work for instance.
Update:
I've encountered another reference issue when migrating a project. I had to remove and re-add System.ComponentModel.Composition, then add System.ComponentModel.Composition.Initialization.
I tried to uninstall the Smooth Streaming Client that the MMPPF client installed and installed the newest from here, added a reference to the new dll (Microsoft.Web.Media.SmoothStreaming.dll) and everything worked.

Categories