Quantcast
Channel: Questions in topic: "native plugin"
Viewing all 376 articles
Browse latest View live

have c# code executed AFTER nativeplugin execution

$
0
0
Hi, I cannot seem to have c# executed AFTER the nativeplugin execution. I have following pseudo code: void update() { cam.targetTexture = myRenderTexture; cam.render(); cam.targetTexture = null; } void OnPostRender() { GL.IssuePluginEvent(GetFunc(), 1 ); // do some stuff AFTER native plugin execution MyMethod(); } The code inside MyMethod() seems to get data affected on the native plugin only for the NEXT frame, which make me believe the native plugin is executed AFTER the execution of the OnPostRender() function is complete. My Question: Is there any way I can fence / wait or force the unity to execute it and only AFTER continue the call to the MyMethod() ?? I've tried with no luck: 1. GL.Flush() inside OnPostRender after the GL.Issue. 2. Put the GL.IssuepLuginEvent code line inisde the Update(). Would appreciate any help on matter. regards, Idan

Custom swift framework in Unity iOS game

$
0
0
I have created a swift framework and implemented it into my Unity project in the same way as it is done in the following tutorials: https://medium.com/@kevinhuyskens/implementing-swift-in-unity-53e0b668f895 https://medium.com/@SoCohesive/unity-how-to-build-a-bridge-ios-to-unity-with-swift-f23653f6261 The project builds and runs perfectly on my iPhone. However, I get the following errors when uploading to the App Store: This bundle is invalid - The Info.plist file for /Payload/MyApp.app/Data/Raw/SwiftPlugin.framework is missing or could not be read. Invalid Bundle - The bundle at '/Payload/MyApp.app/Data/Raw/SwiftPlugin.framework' does not contain a bundle executable. The swift framework was placed in the "StreamingAssets" folder in Unity, so that it is copied through to the Xcode project. I also used the same post processing script as seen in the first tutorial. The swift framework is in a folder called "Raw" in the Xcode project, if I try moving it to the frameworks folder I get the error "Linker command failed with exit code(use -v to see invocation)" when building the application. Any help would be much appreciated

Cannot call a native Android method in the latest versions of Unity...?

$
0
0
Hi! The following code used to work in Unity versions 2018.x.x but it seems like the AndroidJavaObject::Call method doesn't work anymore in 2019.1.0? When attempting to build for Android, the line gives an error which states that Call returns void... Am I wrong in assuming it should return an AndroidJavaObject[] here? using(AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")){ using(AndroidJavaObject context = unityPlayer.GetStatic("currentActivity")){ AndroidJavaObject[] externalFilesDirs = context.Call("getExternalFilesDirs", null); //... } } The error: error CS0029: Cannot implicitly convert type 'void' to 'UnityEngine.AndroidJavaObject[]' Thanks! :)

Using Native C++ dll in Unity

$
0
0
Hi, I am new to Unity and C++ and C#. I have a UWP component (C++) I want to use in my Unity project through C# scripts. I am thinking the best way to do this is by taking the UWP component and building a dll from Visual Studio. To practice I wrote and generated a managed DLL following a tutorial and imported and used it in Unity. However, the code I want to access produced a native dll and I am unsure how to use that in Unity. So either how do I convert a native dll to a managed dll, or how do I use a native dll in Unity? Thanks.

Native Android plugin CPU subfolder approach not working

$
0
0
I wrote a native Android plugin for a Unity project. If I place the ARM version plugin into the Assets/Plugin/Android folder and build for an Android device, it all goes well and the app is running fine. However, if I try to use the CPU subfolder approach, putting different CPU versions of the plugin into the respective Assets/Plugin/Android/x86 and Assets/Plugin/Android/armeabi-v7a subfolders as outlined in the manual (https://docs.unity3d.com/Manual/PluginInspector.html), the app is no longer working and the LogCat output tells me that the DLL was not found. I even tried to set my "Run device" in the Build Settings to the actual device because I thought that perhaps, launching it from my desktop may cause it to embed the wrong version, but that didn't help either. Is there an additional step I need to go through so that Unity will embed the correct CPU plugin version in the final build? Thanks for any suggestions.

Invoking Windows Multimedia timer results to hang

$
0
0
I am on Windows 10, Unity Editor 2018.3.12f1 I have a requirement for very fast (500 Hz) and precise updates, "independent" from the Unity main thread. I am targeting windows desktop only, so the [Multimedia Timers][1] seemed as a good (the only?) fit. However I witness some weird crashes. When in Editor, when I press the play button, my sample game seems to be working correctly (ie prints in the Debug console, and with great precision when I used stopwatch to measure), but when i stop the game **and** try to run it again, the Editor hangs. When i build and play, again everything seems normal (no debug messages there of course), but when i attempt to close the program via the 'X' button it hangs again. I tried [this][2] library which also includes a working example, and I also created this very simple mono behaviour to test it but with same results: using UnityEngine; using System.Threading; using System.Runtime.InteropServices; using System; public class MultimediaTimer : MonoBehaviour { private UInt32 userCtx = 0; void Start() { // Run(); Thread r = new Thread(() => Run()); r.Start(); } void Run() { MultimediaTimerCallback Callback = new MultimediaTimerCallback(TimerCallbackMethod); uint timerId = TimeSetEvent(100, 5, Callback, ref userCtx, 1); Thread.Sleep(1000); TimeKillEvent(timerId); } private static void TimerCallbackMethod(uint id, uint msg, ref uint userCtx, uint rsv1, uint rsv2) { Debug.Log("Hi"); } private delegate void MultimediaTimerCallback(UInt32 id, UInt32 msg, ref UInt32 userCtx, UInt32 rsv1, UInt32 rsv2); [DllImport("winmm.dll", EntryPoint = "timeSetEvent")] private static extern UInt32 TimeSetEvent(UInt32 msDelay, UInt32 msResolution, MultimediaTimerCallback callback, ref UInt32 userCtx, UInt32 eventType); [DllImport("winmm.dll", EntryPoint = "timeKillEvent")] private static extern UInt32 TimeKillEvent(UInt32 uTimerId); } My question is very simple. Is it possible to reliably call the multimedia timer from a Unity program? And if not could someone explain this behaviour I observe? I could encapsulate my timer logic in a separate process and use some form of IPC to achieve my requirement, but I would prefer for convenience to stay withing Unity. (Of course if you know any alternatives, by all means do say them) [1]: https://docs.microsoft.com/en-us/windows/desktop/multimedia/multimedia-timers [2]: https://github.com/mzboray/HighPrecisionTimer

android native library: Content is not allowed in prolog

$
0
0
i Created a native android library for unity, everything works fine, but now i want to use custom fonts for my library, so in fonts folder in my res in android library project i add a new font, but when i use it in my layout, i get this error: ---------- > FAILURE: Build failed with an> exception.>> * What went wrong: Execution failed for task ':mergeReleaseResources'.>> C:\Users\Shetab\.android\build-cache\1fcd220a9bf9f309aa03411f7ac46d48f5490627\output\res\font\iran_bold.ttf:1:1:> Error: Content is not allowed in> prolog.

Error: Content is not allowed in prolog.

$
0
0
i have created a android native library for unity which is a fragment that shows a screen on the unity game screen. everything works fine, but now i'm trying to add custom font to my android library layout. but by adding any new fonts to font folder under 'res' folder in android library and exporting to arr file, i get this error in unity when trying to Build and Run: ![alt text][1] error text: > CommandInvokationFailure: Gradle build> failed. C:/Program> Files/Java/jdk1.8.0_211\bin\java.exe> -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.4.jar"> org.gradle.launcher.GradleMain> "-Dorg.gradle.jvmargs=-Xmx2048m"> "assembleRelease">> stderr[>> FAILURE: Build failed with an> exception.>> * What went wrong: Execution failed for task> ':unity-android-resources:packageReleaseResources'.>> C:\Users\Shetab\Documents\UnityPlugin\Temp\gradleOut\unity-android-resources\res\font\bahush.TTF:1:1:> Error: Content is not allowed in> prolog.>> * Try: Run with --stacktrace option to get the stack trace. Run with --info> or --debug option to get more log> output. Run with --scan to get full> insights.>> * Get more help at https://help.gradle.org>> BUILD FAILED in 7s ] stdout[ NDK is> missing a "platforms" directory. If> you are using NDK, verify the ndk.dir> is set to a valid NDK directory. It> is currently set to C:\sdk\ndk-bundle.> If you are not using NDK, unset the> NDK variable from ANDROID_NDK_HOME or> local.properties to remove this> warning.>> Observed package id> 'build-tools;29.0.0-rc2' in> inconsistent location> 'C:\sdk\29.0.0-rc2' (Expected> 'C:\sdk\build-tools\29.0.0-rc2')> Observed package id 'tools' in> inconsistent location> 'C:\sdk\toolsXXXX' (Expected> 'C:\sdk\tools') Already observed> package id 'tools' in 'C:\sdk\tools'.> Skipping duplicate at> 'C:\sdk\toolsXXXX' NDK is missing a> "platforms" directory. If you are> using NDK, verify the ndk.dir is set> to a valid NDK directory. It is> currently set to C:\sdk\ndk-bundle. If> you are not using NDK, unset the NDK> variable from ANDROID_NDK_HOME or> local.properties to remove this> warning.>> The CompileOptions.bootClasspath> property has been deprecated and is> scheduled to be removed in Gradle 5.0.> Please use the> CompileOptions.bootstrapClasspath> property instead. The> setTestClassesDir(File) method has> been deprecated and is scheduled to be> removed in Gradle 5.0. Please use the> setTestClassesDirs(FileCollection)> method instead. The> getTestClassesDir() method has been> deprecated and is scheduled to be> removed in Gradle 5.0. Please use the> getTestClassesDirs() method instead.> The> ConfigurableReport.setDestination(Object)> method has been deprecated and is> scheduled to be removed in Gradle 5.0.> Please use the method> ConfigurableReport.setDestination(File)> instead. :preBuild UP-TO-DATE> :preReleaseBuild UP-TO-DATE> :checkReleaseManifest :preDebugBuild> UP-TO-DATE> :prepareUnitylibraryDebugLibrary> :unity-android-resources:preBuild> UP-TO-DATE> :unity-android-resources:preReleaseBuild> UP-TO-DATE> :unity-android-resources:checkReleaseManifest> :unity-android-resources:prepareReleaseDependencies> :unity-android-resources:compileReleaseAidl> :unity-android-resources:compileReleaseNdk> NO-SOURCE> :unity-android-resources:compileLint> :unity-android-resources:copyReleaseLint> NO-SOURCE> :unity-android-resources:mergeReleaseShaders :unity-android-resources:compileReleaseShaders> :unity-android-resources:generateReleaseAssets> :unity-android-resources:mergeReleaseAssets> :unity-android-resources:mergeReleaseProguardFiles> UP-TO-DATE> :unity-android-resources:packageReleaseRenderscript> NO-SOURCE> :unity-android-resources:compileReleaseRenderscript> :unity-android-resources:generateReleaseResValues> :unity-android-resources:generateReleaseResources> :unity-android-resources:packageReleaseResources> C:\Users\Shetab\Documents\UnityPlugin\Temp\gradleOut\unity-android-resources\res\font\bahush.TTF:1:1:> Error: Content is not allowed in> prolog.> :unity-android-resources:packageReleaseResources> FAILED 13 actionable tasks: 12> executed, 1 up-to-date ] exit code: 1> UnityEditor.Android.Command.WaitForProgramToRun> (UnityEditor.Utils.Program p,> UnityEditor.Android.WaitingForProcessToExit> waitingForProcessToExit, System.String> errorMsg)> UnityEditor.Android.Command.Run> (System.Diagnostics.ProcessStartInfo> psi,> UnityEditor.Android.WaitingForProcessToExit> waitingForProcessToExit, System.String> errorMsg)> UnityEditor.Android.AndroidJavaTools.RunJava> (System.String args, System.String> workingdir, System.Action`1 progress,> System.String error)> UnityEditor.Android.GradleWrapper.Run> (System.String workingdir,> System.String task, System.Action`1> progress) Rethrow as> GradleInvokationException: Gradle> build failed> UnityEditor.Android.GradleWrapper.Run> (System.String workingdir,> System.String task, System.Action`1> progress)> UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute> (UnityEditor.Android.PostProcessor.PostProcessorContext> context)> UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks> (UnityEditor.Android.PostProcessor.PostProcessorContext> context)> UnityEditor.BuildPlayerWindow:BuildPlayerAndRun() [1]: /storage/temp/140172-sharedscreenshot.jpg

Upgrading my project to 2019 version

$
0
0
Hi I've been working on a project for 2 years in unity 2017 and when I tried to upload my APK to the google store and I've got the following warnings due to some native plug ins ![![alt text][1]][1] [1]: /storage/temp/140244-warning.png I read in this article => https://forum.unity.com/threads/googleplay-64bit-console-warning.672988/ how to fix this however those options aren't available in my unity 2017. I tried install the latest version of unity and open the project in unity 2019 , however it wont open the project and gives me an exclamation mark that this is an older version Please if anyone can help me out solve this problem in anyway would be appreciated

How to enable more than 2 output channels in a native audio spatializer plugin?

$
0
0
We are currently developing a spatializer plugin based on the native audio sdk on Ubuntu 18.04. --- The **goal** is to use the provided input buffer and 3D position of a mono audio source to compute the **output buffers for 8 speakers** that are placed in each corner of a room (4 at the bottom and 4 at the ceiling). The problem is that **unity provides only 2 output channels** no matter what setting is chosen in the audio preferences. If we choose mono, we get 1 channel, everything else results in 2 channels, even the 7.1 surround option. --- **How can we enable more than 2 `outchannels` in the `ProcessCallback()` function?** --- *We are using Unity 2019.2.0f1 on Ubuntu 18.04 but also experienced the same issue with earlier Linux builds. Unfortunately, we are not able to test the code on a Windows machine due to our hardware setup and can therefore not provide any comparison regarding platform specificity.*

Referencing a DLL in C#

$
0
0
I have created a .dll file that sets up printing capabilities and now I want to be able to reference the function in my C# code (on a button press) My .dll is as follows: using Android.Print; using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Graphics; using Android.Print.Pdf; using System.IO; namespace PrintIMPORTteste { public class PrintActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Print); var txtview = FindViewById(Resource.Id.textview1); txtview.Text = "Hello"; var button = FindViewById

Creating a native UAV into a meshes native vertex buffer (DX11)

$
0
0
I have a native plugin which generates mesh data using compute shaders. My ideal solution would be to pass down the native vertex buffer pointer down to the plugin, create a UAV into it, and bind that directly to my compute shader. Attempting to create the UAV returns an invalid args result. The vertex buffer appears to not be a structured buffer (buffer description has a structured byte stride of 0). Could this be why this method will not work?

GetNativeTexturePtr is not working in iOS plugin

$
0
0
I'm working on creating iOS plugin for saving screenshot. I'm trying to use GetNativeTexturePtr. But it didn't work. It will be NULL in the iOS plugin. I want to know how to use GetNativeTexturePtr. Please see my code below. // C# side System.IntPtr ptr = _buffer.GetNativeTexturePtr(); // _buffer is RenderTexture _SaveTextureImpl(ptr); // Define like below. [DllImport("__Internal")] static private extern void _SaveTextureImpl(System.IntPtr texture); Maybe you think that `_buffer` is wrong, but I visualized it on uGUI's RawImage then it worked. Move onto Objective-C side. // Objective-C side. extern "C" void _SaveTextureImpl(id texture) { [NativeTextureSaver saveTexture:texture]; } My understanding is, `GetNativeTexturePtr` will return the pointer of `id` on iOS. So I guess that we can use the pointer as `id`, but it was NULL in the plugin. Is it my mistake? or Do I need to set up something other?

Native plugin stops working properly after re-opening project

$
0
0
Hi there, hope someone can help. I'm experiencing weird behavior from native effect plugin granulator added to audio mixer group: if I close the Unity project and reopen it, the signal doesn't pass through the plugin anymore, and the only way to have the signal back is to delete and re-add the plugin from scratch (and re-tweak it). If I bypass the plugin, the dry signal path is just fine. Any idea what's happening there? Thanks in advance! I know just very little C# for now, and plugins SDK is still too complex for me to understand.

How to destroy Scriptable Objects on Reimport

$
0
0
Hi, I have a native plugin in c++ that creates and manages some allocated user data. A reference to this data created is held by an scriptable object (which is supposed to be shared among several components) I am taking care of the memory management OnAwake/OnEnable and OnDestroy/OnDisable. An instance of the scriptable object is created when I import some custom asset format. Everything works fine, until when I need to reimport this asset. Basically, I create a new instance of the object in the body of the importer, and (I suppose) Unity internally replaces the old reference with the new one. The problem is when this done, the OnDestroy (or OnDisable) is never getting called again, so my user data is never destroyed and it causes a small memory leak (it happens only on the editor, and when I reimport the asset, so it is not so critical) as a workaround, I am keeping a static dictionary that holds the asset file name as key, and the scriptable object reference as value. When I detect that a reimported asset, I directly call the destructor of the user data. besides being cumbersome, when the importer script itself is reloaded, the static data is cleared, so I still have this corner case memory leak. ideally, i wanted to rely on the OnDestroy only, so how should I properly reimport the asset so that the SO gets destroyed?

Flutter Unity iOS Build Undefined symbols for architecture arm64:

$
0
0
Hi i am trying to integrate my unity project for flutter iOS build, when i use flutter run in terminal i am getting this error below, Xcode's output: ↳ === BUILD TARGET UnityFramework OF PROJECT Unity-iPhone WITH CONFIGURATION Debug === Undefined symbols for architecture arm64: "_onUnityMessage", referenced from: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36 in Assembly-CSharp.o (maybe you meant: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Could not build the precompiled application for the device. Error launching application on iPad.

iOS native share PDF popup with QuickLook option

$
0
0
I want to download PDF from web and share this file with native iOS popup. There are many variants how to do this and I already bought assets on asset store with this functional but without one cool feature: iOS native QuickLook controller (QLPreviewController) to get preview in native window. I already saw this feature on other projects but they are written on Objective-C. And I can't make it work by changing NativeShare plugin that I download from AssetStore. Can any one help me with that?

Exception: Unkown CPU architecture for Android static library as Plugin

$
0
0
I sucessfully build an Android static library (.a) file, however if i place it into the *Assets/Plugins/Android * folder, building the Unity project fails with: *Exception: Unknown CPU architecture for library*, even if i don't actually call the plugin from scripts. Include Platform (Android) and CPU architecture (ARMv7) are set correctly in the Plugin Inspector. Unity version is 2019.3.0a3. What might be a cause for this? According to the [documentation](https://docs.unity3d.com/Manual/AndroidNativePlugins.html), Android static libraries are supported as Plugins.

Accessing config file from C/C++ android native plugin

$
0
0
Hello, I need to implement some C library as a Unity native plugin for Android. This library uses a config file with some params. I cannot filnd a way how to access some file inside apk inside C plugin. For instance this example https://en.wikibooks.org/wiki/OpenGL_Programming/Android_GLUT_Wrapper#Accessing_assets allowing to access StreamingAssets files requires 'activity' variable of ANativeActivity type with AssetManager object. this activity variable is passed in android_app struct as a param of android_main. But we dont have access to it inside a unity plugin, do we? How to get AssetManager or ANativeActivity object inside a native plugin?

Integrate Unity3D game into Native Android App,Integrate Unity3D game into a Native Android App

$
0
0
Hello so I am trying to integrate a unity game into my android app where if the user clicks a button then the game should launch.Till now I have tried all possible methods that i found online and their solutions seem to be old. What I tried : 1. https://stackoverflow.com/questions/24564470/unity3d-and-android-studio- integration/45138926#45138926 Now the version of Unity [2019.3.0a12] I use exports two folders named launcher and UnityLibrary along with bunch of gradle files so this is completely new and i dont understand how to proceed further Unity only gives two folders when i set ScriptBackend to IL2CPP and ARM64 checked.I only did this because when ScriptBackend was MONO Unity gave me only one folder and i followed the above link but i ended up with an error as below java.lang.UnsatisfiedLinkError: No implementation found for void com.unity3d.player.UnityPlayer.nativeRestartActivityIndicator() (tried Java_com_unity3d_player_UnityPlayer_nativeRestartActivityIndicator and Java_com_unity3d_player_UnityPlayer_nativeRestartActivityIndicator__) at com.unity3d.player.UnityPlayer.nativeRestartActivityIndicator(Native Method) at com.unity3d.player.UnityPlayer.resume(Unknown Source:23) at com.unity3d.player.UnityPlayerActivity.onResume(UnityPlayerActivity.java:73) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446) at android.app.Activity.performResume(Activity.java:7939) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) So in the process of solving the error I followed the below link https://stackoverflow.com/questions/51959096/no-implementation-found-for-void-com-unity3d-player-unityplayer-nativerestartact That is when Unity gave me two folders and I am lost now. 2 . https://medium.com/@davidbeloosesky/embedded-unity-within-android-app-7061f4f473a (This blog also not supported to the new unity version) Also yes I also tried the "Force Internal" thing and Still no use. Guys please guide me with the right steps that are compatible to latest android version to integrate the game into native android app . Thank you.
Viewing all 376 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>