I am new to unity addressables and would like to load a scene with an AssetReference. To enforce AssetReferences being a scene, I created the following class in a utility assembly:
using System;
using UnityEngine;
using UnityEngine.AddressableAssets;
[Serializable]
public sealed class SceneReference : AssetReferenceT<SceneAsset>
{
public SceneReference(string guid) : base(guid) { }
}
JetBrains Rider then said SceneAsset had to be referenced from assembly: UnityEditor.CoreModule. I used its suggestion, and Rider automatically set up the
assembly reference. Everything worked great, and indeed I could only drag scenes into a SceneReference field.
But everything broke down when I went to make a build. I get four errors:
1:Internal build system error. Backend exited with code 139.
2:Error building Player because scripts had compiler errors
3:Build completed with a result of 'Failed' in 11 seconds (11360 ms) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
4:UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ce] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:193 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:94 UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
I have tried to manually locate assembly UnityEditor.CoreModule and reference it in my utility assembly's assembly definition asset but couldn't find it. It still works great in the editor but won't compile for a build. If anyone has a solution or at least knows why this isn't working, I would be most appreciative.
SceneAsset indeed can not be in a build and only exists within the Unity Editor - for what reason ever.
It is a special case of an asset that only exists in editor since later on in a build the scenes are handled completely different as runtime Scene.
The entire UnityEditor namespace is completely stripped of in a build.
For serialization the best option is usually to serialize and store the asset path and later use that for loading the scene.
You can still make scenes Addressables though and load them via the usual more manual Addressables route e.g. using a "normal" generic
public AssetReference Scene;
See Addressables - Scene Loading.
Related
I have an application that has an android and ios project with shared code. The android application works perfectly and uses the SDK Only linker. I also have a Linker file to enforce linker not removing used functions - Which is a fairly large file and I've also tried adding a bunch of preserve attributes. The same situation in the iOS project, however, doing the same thing doesn't work. It removes something from EF and throws this exception:
"The type initializer for 'Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions' threw an exception. ---> System.InvalidOperationException"
This whole codebase works perfectly fine without the linking. I've added a bunch of mtouch arguments to try and skip it but that ain't working either.
--linkskip=Microsoft.EntityFrameworkCore
--linkskip=Microsoft.EntityFrameworkCore.Design
--linkskip=Microsoft.EntityFrameworkCore.Sqlite
--linkskip=Microsoft.EntityFrameworkCore.Tools
--linkskip=Interactive.Async
--linkskip=Remotion.Linq
--linkskip=System.Data
--linkskip=System.Collections.Immutable
--linkskip=System.Diagnostics.DiagnosticSource
--linkskip=Microsoft.Extensions.Logging
--linkskip=System.Interactive.Async
--linkskip=Microsoft.EntityFrameworkCore.Abstractions
--linkskip=Microsoft.Extensions.DependencyInjection
--linkskip=Microsoft.Extensions.Caching.Memory
--linkskip=System.ComponentModel.Annotations
I'm about to add every DLL in the NuGet repository which will make the Linker useless. Is this a bug for the iOS Linker or what am I missing here? I've read the documentation https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=windows and searched everywhere on the internet and nothing comes up. Any help is appreciated.
Thanks,
If you are using "Link SDK assemblies only" option on iOS project, then all of those --linkskip arguments won't do anything as only the SDK assemblies are being linked. So the EntityFrameworkCore might be using something that is being linked away that is in the Xamarin.iOS SDK assemblies. System.Linq is part of the SDK and adds extension methods for many database types.
So I think you may be hitting this issue: https://github.com/xamarin/xamarin-macios/issues/3394
If so, try putting:
[assembly: Preserve (typeof (System.Linq.Queryable), AllMembers = true)]
in the Main.cs file of the iOS project outside of the namespace, e.g.:
using UIKit;
[assembly: Preserve (typeof (System.Linq.Queryable), AllMembers = true)]
namespace
{
...
}
First post. Let me know if I break any rules!
I would like to experiment with Pure Data and Unity 5. It seems uPD would be the best fit. I have followed the instructions on the github page and loaded the first sample scene. The unity console reports errors with the dll:
Failed to load 'Assets/Magicolo/AudioTools/PureData/Plugins/libpdcsharp.dll', expected 64 bit architecture (IMAGE_FILE_MACHINE_AMD64), but was IMAGE_FILE_MACHINE_I386. You must recompile your plugin for 64 bit architecture.
So I cloned the main libpd repo and used the included batch file to build an x64 dll. I replaced the libpdcsharp.dll in the unity project and the console now reports:
DllNotFoundException: Assets/Magicolo/AudioTools/PureData/Plugins/libpdcsharp.dll
LibPDBinding.LibPD.ProcessArgs[Int32] (System.Int32[] args, System.String& debug) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMessaging.cs:402)
LibPDBinding.LibPD.SendMessage[Int32] (System.String receiver, System.String message, System.Int32[] args) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMessaging.cs:354)
(wrapper synchronized) LibPDBinding.LibPD:SendMessage (string,string,int[])
LibPDBinding.LibPD.ComputeAudio (Boolean state) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:238)
(wrapper synchronized) LibPDBinding.LibPD:ComputeAudio (bool)
LibPDBinding.LibPD.Release () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:207)
(wrapper synchronized) LibPDBinding.LibPD:Release ()
LibPDBinding.LibPD.ReInit () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:79)
(wrapper synchronized) LibPDBinding.LibPD:ReInit ()
LibPDBinding.LibPD..cctor () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:65)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LibPDBinding.LibPD
Magicolo.AudioTools.PureDataBridge.SetAudioSettings () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:46)
Magicolo.AudioTools.PureDataBridge.StartLibPD () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:25)
Magicolo.AudioTools.PureDataBridge.Start () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:50)
PureData.StartAll () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:141)
PureData.Initialize () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:58)
PureData.Awake () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:173)
I have also tried copying the libPDBinding.dll file from the main libpd repo to the unity project no avail. I lack the understanding to know where to go next so any help at all would be appreciated!
Further Progress
It was suggested to try NuGet to obtain the binding dll. On this - I get an error about a framework mismatch between my unity project/visual studio solution and the nuget package libPDBinding version 0.10.0. This is to do with unitys profiles as described in an article titled: "Using NuGet in Visual Studio Tools for Unity". I cant post the link here because I am too new.
However, I think I am sucessful in compiling my own libPDBinding.dll. Apologies for dragging this out, just making sure I am doing this right:
After using libPD\mingw64_build_csharp.bat to compile a x64 version of libpdcsharp.dll, I reference this and libpd\libs\mingw64\libwinthread-1.dll in the VS solution and get the resulting LibPDBinding.dll which was built with .NET 3.5. As mentioned libpdcsharp.dll was compiled using the batch/make file, so am I correct to assume this file has been built with the correct settings?
I proceed to copy these 3 dll's the unity assets folder
For reference it's a blank unity project with uPD as the only package, loaded to a uPD example scene.
I still get some errors at run time and some visual studio warnings as follows.
Unity run time error:
EntryPointNotFoundException: libpd_safe_init
LibPDBinding.LibPD.ReInit () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:81)
(wrapper synchronized) LibPDBinding.LibPD:ReInit ()
LibPDBinding.LibPD..cctor () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:65)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LibPDBinding.LibPD
Magicolo.AudioTools.PureDataBridge.SetAudioSettings () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:46)
Magicolo.AudioTools.PureDataBridge.StartLibPD () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:25)
Magicolo.AudioTools.PureDataBridge.Start () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:50)
PureData.StartAll () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:141)
PureData.Initialize () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:58)
PureData.Awake () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:173)
Visual studio warnings x 50 or so:
Warning CS0436 The type 'LibPD' in 'D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\LibPD\LibPdNativeUnity.cs' conflicts with the imported type 'LibPD' in 'LibPDBinding, Version=0.3.0.177, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\LibPD\LibPdNativeUnity.cs'. libpdinunity.CSharp D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\PureDataCommunicator.cs 87 Active
Thanks again for any help. Much appreciated.
Looking at your error, libpdcsharp is currently placed at <ProjectDirectory>/Assets/Magicolo/AudioTools/PureData/Plugins/
This DLL file should be placed at <ProjectDirectory>/Asset.
Also, make sure that libpdcsharp is compiled with .NET 2.0 or 3.5. This won't work if you compile it with .NET 4.0 and above.
I am the maintainer of C# binding for LibPD.
You also need to change the link to the correct libwinpthread-1.dll version (64 bit instead of 32). In your final project you need all 3 dlls:
LibPDBinding.dll (the managed wrapper)
libpdcsharp.dll (the native dll)
libwinpthread-1.dll (for enabling POSIX threads on Windows)
Also: Have you tried the version from NuGet? No need to compile your own version of the binding.
EDIT: Your warning are from a different source: You have two classes named LibPD, and the C# compiler does not know, which one to use.
I am not sure, if these types are in the same namespace.
If they are in the same namespace, then change your namespace.
If they are in different namespaces, add a line using LibPd = LibPDBinding.LibPD; if you want to use the version from NuGet, or using LibPd = <yournamespace>.LibPD; if you want to use your version.
It's working. The uPD github code has an error as far as I can tell. So hopefully it gets fixed. In the meantime I just started the process from scratch and this is what I did to get the uPD test scene working in unity 5:
Get uPD from github. Theres a unity package in there
Get libPD from github.
Follow the instructions on the libPD github page to compile a x64
vresion of libpdcsharp.dll
replace the existing libpdcsharp.dll inside your unity project with
the x64 version you compiled
locate libpd\libs\mingw64\libwinthread-1.dll in the libpd files and
place this in the your unity project - the same place as the other dll is fine. I
don't think it matters where you put the Dll's (at least it made no
difference in my tests)
Run the project and notice you get an error in unity EntryPointNotFoundException: libpd_safe_init
double click the error to open up the problem script.
Find the following line of code: [DllImport("libpdcsharp", EntryPoint="libpd_safe_init")]
Change it to [DllImport("libpdcsharp", EntryPoint="libpd_init")] That's the real entry point for the init function in libpdcsharp. I don't know what libpd_safe_init is.
Thanks to the contributors who helped me to troubleshoot and find the issue!
I have this app, that builds and runs successfully in Debug mode, on both my local computer and on my Windows Phone device, when trying with the Release mode, I get these 3 errors :
Error Internal compiler error: One or more errors occurred.
The non-generic type 'PInvoke.NTSTATUS.Code__PInvoke_Windows_Core'
cannot be used with type arguments
...obj\x64\Release\ilc\intermediate\Liberte.Windows.Interop\SafeTypes.g.cs 333
The type or namespace name 'Value' could not be found (are you missing
a using directive or an assembly
reference?) ...obj\x64\Release\ilc\intermediate\Liberte.Windows.Interop\SafeTypes.g.cs 333
The actual code where the two last errors are detected is an auto generated code under a file named SafeTypes.g.cs and the line where the errors is raised is :
namespace PInvoke
{
[global::System.Runtime.InteropServices.McgRedirectedType("PInvoke.NTSTATUS,PInvoke.Windows.Core, Version=0.1.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a")]
public unsafe partial struct NTSTATUS__PInvoke_Windows_Core
{
public global::PInvoke.NTSTATUS.Code__PInvoke_Windows_Core <Value>k__BackingField;
}
}
I don't have any idea what does this mean, nor what should I do, any explanation and solution to this ?
Update :
Tried to Close VS, then Delete the Obj and the Bin content, rebuild again, but stuill have the same error.
I should mention maybe that I have reference to 2 other projects, one of them is a PCL project that uses PCLCrypto library, and the other one is a Universal App library that uses EntityFramework 7 pre-release with sqlight.
Update 2:
I tried to disable compilation with .Net native just to see what goes on, the release build succeeds, but the App crashes and quits just after startup.
Update 3:
I just discovered that the PCLCrypto library that I use in one of the two project I'm referencing, references two libs that are causing the problem, and they are mentioned in the errors above, I found this out when trying to uninstall the library to see if it is the cause of the problem :
I tried to rollback to a previous stable version, compiled in Debug mode, everything worked perfectly, when I try again Release mode with .Net native, I encounter a new problem : Out of memory.
Concerning Update 3, it seems to be a bug with .NET Native tool chain, I opened an issue on PCLCrypto repo that was moved to corert repo
I'm attempting to use the following command line command to compile an assembly of the code from my project:
C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll
As you can see, I am, I believe, correctly referencing the UnityEngine.dll.
The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems. But when I run the above command, I get the following compile error:
error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?
From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer.
As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below).
This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:
This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:
When I built my Windnows desktop app via Unity, the above dlls appeared in:
<drive>:<projectOutFolder>\<projectName>_Data\Managed
You can try:
right click on "project panel", and after "Reimport All".
It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..
Solve for me: Unity 5.2, Win 7, 32bits;
Good luck!
I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.
For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.
I'm working on IOS using Xamarin to restore some old android code. When trying to compile, there's a missing assembly error, pointing me towards this block of code:
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{...}
The error I get is as follow:
Error CS0234: The type or namespace name ApplicationSettingsBase does
not exist in the namespace System.Configuration. Are you missing an
assembly reference? (CS0234)
I get the feeling the problem lies within the "Microsoft.VisualStudio" part but I have no idea how to fix this.
Edit I see some people having similar problem being answered "Don't use Windows core dll". This might be the problem, but if it is I have no idea how to fix it.
I'm not sure how this could work on Xamarin.Android but System.Configuration (both the assembly and the namespace) are not part of the mobile profile that are shipped with Xamarin.iOS (and Xamarin.Android).
Also, more specifically to Xamarin.iOS, there's no code generation possible (no JIT is allowed by Apple) so it does not include namespaces (or types) from System.CodeDom.Compiler