My steps:
Downloaded the library from https://github.com/sshnet/SSH.NET
Built the 3.5 framework one and copied the DLL at *\src\Renci.SshNet.NET35\bin\Debug\ into Unity assets
Wrote a script that should output "C" in a text field:
using System.IO;
using Renci.SshNet;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
String Host = "ftp.csidata.com";
int Port = 22;
String RemoteFileName = "TheDataFile.txt";
String LocalDestinationFilename = "TheDataFile.txt";
String Username = "yourusername";
String Password = "yourpassword";
void Start(){
using (var sftp = new SftpClient(Host, Port, Username, Password))
{
sftp.Connect();
using (var file = File.OpenWrite(LocalDestinationFilename))
{
sftp.DownloadFile(RemoteFileName, file);
tex.text += "C";
}
sftp.Disconnect();
}
}
Build solution aimed at HoloLens:
SDK - Universal 10
Target device - Any device
UWP Build Type - D3D
Changed .dll settings to SDK: Any SDK ; ScriptingBackend: Dot Net ; Don't process: Checked
Unity version: 5.5.1f1
Visual Studio version: 2015 update 3
Expected results: Successful connection and letter "C" in text box
Actual results: No change to textbox. VS Debugger tells me:
> An exception of type> 'System.IO.FileLoadException' occurred> in Renci.SshNet.dll but was not> handled in user code>> Additional information: Could not load> file or assembly 'System.Core,> Version=3.5.0.0, Culture=neutral,> PublicKeyToken=b77a5c561934e089' or> one of its dependencies. The located> assembly's manifest definition does> not match the assembly reference.> (Exception from HRESULT: 0x80131040)
Thank you in advance for the help.
↧
Getting SSH.NET to work in Unity
↧
MS SQL Database and System.Data dll
Hello, I've been trying to add the System.Data dll into unity so that I can use the DataTable, SqlConnection, SqlCommand, and SqlDataAdapter classes. I am using Unity 2018.1.
At most, I've been successful in Unity recognizing System.Data to the point of intellisense recognizes the DataTable class. However, the imported dll either fails, or depending on the compiler I chose in the player settings, says that there is two System.Data namespaces, one being the native mono System.Data dll that is integrated with .Net 2.0 and (I think) .Net 4.X.
However, mono's integrated library does not recognize System.Data.SqlClient, which is where the SqlConnection, SqlCommand, and SqlDataAdapter classes come from.
The project I am working on is for a small project for data analysis, and I am used to how MS SQL works. It is perfect for what I need. Any suggestions/workarounds would be great.
Thanks.
↧
↧
Unity iOS - Cannot import functions from .Bundle
Currently trying to create a wrapper for an iOS framework on Unity.
I made a .bundle, containing basic objective-c code :
**sample.h :**
#import
extern "C"
{
void SampleFunction(); // this is going to call already bridged swift or objc code
}
**sample.mm :**
#import "Sample.h"
#import
void SampleFunction()
{
// my sweet functions calls
}
The SDK is included in the bundle as a .framework (references in "Linked Frameworks and libraries"). The bundle target is iOS.
The bundle builds successfully.
The bundle is placed in Unity under "Assets/Plugins/iOS", marked as "iOS" and "Add to Embedded Binaries"
Then, in Unity, there is a simple C# script calling SDK functions :
**sample.cs :**
public class BundleImportSample : MonoBehaviour {
#if UNITY_IOS
[DllImport("__Internal")]
private static extern void SampleFunction();
#endif
void Start()
{
#if UNITY_IOS
SampleFunction();
#endif
}
}
When I test this code in the editor I get the following error :
EntryPointNotFoundException: SampleFunction
If I build the generated project on iOS, I get a similar issue :
ld: symbol(s) not found for architecture arm64
Note : I used the following tutorial as guideline : http://blog.mousta.ch/post/140780061168
**Why is SampleFunction() not found in __Internal ?**
↧
System.Drawing.dll usage in android
Which i'm trying to do is using System.Drawing.dll in Unity and make a texture of string.
Until in editor, it works fine.
But when i build and play at my android phone, it doesn't work causing error like:
DllNotFoundException: gdiplus.dll
System.Drawing.GDIPlus..cctor ()
or
DllNotFoundException: kernel32.dll
So i searched so many things and i already did everything people says like:
1. Api Compatibility Level: .Net 2.0 subset --> .Net 2.0
2. Stripping Level: Disabled
3. Locate System.Drawing.dll file to Assets/Plugins
4. System.Drawing.dll version should be same or lower than System.Drawing.dll in "C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0" or exactly same file.
And i found someone says that System.Drawing.dll and gdiplus.dll which has dependency on System.Drawing.dll are specific library for Windows, so they can't compatible with other platform(Android, IOS, ...).
Which i'm asking is.. is that true?
If so, is there any way i can use System.Drawing.dll in android?
Thanks for reading.
BTW, below is my code.
SpriteTextManager.cs:
using System.Collections.Generic;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using Font = System.Drawing.Font;
using Graphics = System.Drawing.Graphics;
using UnityEngine;
using FontStyle = System.Drawing.FontStyle;
public class SpriteTextManager : MonoBehaviour {
private static SpriteTextManager singleton = null;
private Font font;
private Font boldFont;
private FontFamily family;
private int defaultFontSize = 20;
private Bitmap dummyBitmap = new Bitmap(1, 1);
private Dictionary sprites = new Dictionary();
private Material defaultMaterial;
public static SpriteTextManager Get() {
if ((object)singleton == null) {
var obj = new GameObject("SpriteTextManager");
singleton = obj.AddComponent();
DontDestroyOnLoad(obj);
}
return singleton;
}
private void Awake() {
PrivateFontCollection fonts = new PrivateFontCollection();
fonts.AddFontFile(Application.dataPath + "..\\Images\\font_1.ttf");
// Get font family
family = (FontFamily) fonts.Families.GetValue(0);
font = new Font(family, defaultFontSize);
boldFont = new Font(family, defaultFontSize, FontStyle.Bold);
defaultMaterial = new Material(Shader.Find("Sprites/Default"));
}
public Sprite GetSprite(string str) {
return GetSprite(str, defaultFontSize, false, null, 0, false, false, false, false);
}
public Sprite GetSprite(string str, UnityEngine.Color color) {
return GetSprite(str, defaultFontSize, false, color, 0, false, false, false, false);
}
public Sprite GetSprite(string str, int fontSize = -1, bool bestFit = false, UnityEngine.Color? color = null,
int boundaryWidth = 0, bool shadow = false, bool outline = false, bool bold = false, bool fittedBox = false,
int verticalAlignment = 0) {
// verticalAlignment = -1 -> left, 0 -> center, 1 -> right
if (fontSize == -1) fontSize = defaultFontSize;
int key = str.GetHashCode();
if (sprites.ContainsKey(key)) {
return sprites[key];
}
Font localFont;
if (fontSize != defaultFontSize) {
if (bold) localFont = new Font(family, fontSize, FontStyle.Bold);
else localFont = new Font(family, fontSize);
} else {
if (bold) localFont = boldFont;
else localFont = font;
}
Graphics graphics = Graphics.FromImage(dummyBitmap);
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
SizeF size = graphics.MeasureString(str, localFont);
Bitmap bmp;
RectangleF boundary;
if (fittedBox) {
bmp = new Bitmap((int)size.Width, (int)size.Height);
boundary = new RectangleF(1, 1, size.Width, (size.Height * (int)Math.Ceiling(size.Width / boundaryWidth)));
} else {
bmp = new Bitmap((int)boundaryWidth, (int) (size.Height * (int)Math.Ceiling(size.Width / boundaryWidth)));
boundary = new RectangleF(1, 1, boundaryWidth, (size.Height * (int)Math.Ceiling(size.Width / boundaryWidth)));
}
if (bestFit) {
if (size.Width > boundaryWidth) {
float fontRatio = boundaryWidth / size.Width;
if (bold) {
localFont = new Font(family, localFont.Size * fontRatio, FontStyle.Bold);
} else {
localFont = new Font(family, localFont.Size * fontRatio);
}
boundary = new RectangleF(1, 1, boundaryWidth, size.Height);
bmp = new Bitmap((int)boundaryWidth, (int) size.Height);
}
}
int width = bmp.Width, height = bmp.Height;
graphics = Graphics.FromImage(bmp);
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
graphics.InterpolationMode = InterpolationMode.Bilinear;
UnityEngine.Color textColor = color ?? UnityEngine.Color.black;
SolidBrush blackBrush = new SolidBrush(System.Drawing.Color.Black);
SolidBrush brush = new SolidBrush(System.Drawing.Color.FromArgb((int) (textColor.a * 255), (int) (textColor.r * 255),
(int) (textColor.g * 255), (int) (textColor.b * 255)));
StringFormat format = new StringFormat();
switch (verticalAlignment) {
case -1:
format.Alignment = StringAlignment.Near;
break;
case 0:
format.Alignment = StringAlignment.Center;
break;
case 1:
format.Alignment = StringAlignment.Far;
break;
}
if (outline) {
boundary.X = 2;
boundary.Y = 2;
graphics.DrawString(str, localFont, blackBrush, boundary, format);
boundary.X = 0;
graphics.DrawString(str, localFont, blackBrush, boundary, format);
boundary.X = 2;
boundary.Y = 0;
graphics.DrawString(str, localFont, blackBrush, boundary, format);
boundary.X = 0;
graphics.DrawString(str, localFont, blackBrush, boundary, format);
} else if (shadow) {
boundary.X = 2;
boundary.Y = 2;
graphics.DrawString(str, localFont, blackBrush, boundary, format);
}
boundary.X = 1;
boundary.Y = 1;
graphics.DrawString(str, localFont, brush, boundary, format);
byte[] bytes;
BitmapData bitmapData;
IntPtr Iptr = IntPtr.Zero;
bytes = new byte[width * height * 4];
// bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
Rectangle bitmapRectangle = new Rectangle(0, 0, width, height);
bitmapData = bmp.LockBits(bitmapRectangle, ImageLockMode.ReadOnly, bmp.PixelFormat);
Iptr = bitmapData.Scan0;
Marshal.Copy(Iptr, bytes, 0, bytes.Length);
Texture2D texture2D = new Texture2D(width, height, TextureFormat.BGRA32, false);
texture2D.LoadRawTextureData(bytes);
texture2D.Apply();
bmp.UnlockBits(bitmapData);
Rect spriteRect = new Rect(0, 0, width, height);
Sprite sprite = Sprite.Create(texture2D, spriteRect, Vector2.zero, 100f, 0, SpriteMeshType.FullRect);
sprites.Add(key, sprite);
return sprite;
}
public Material GetDefaultMaterial() { return defaultMaterial; }
}
SpriteTextRenderer.cs:
using System;
using UnityEngine;
using UnityEngine.UI;
public class SpriteTextRenderer : MonoBehaviour {
private Image image;
private RectTransform rectTransform;
private Sprite sprite = null;
private String _text;
public String text;
public Color color = Color.black;
public int size = 20;
public bool bestFit = false;
public bool outline = false;
public bool shadow = false;
public bool bold = false;
public bool fittedBox = false;
public int horizontalAlignment = 0;
void Start () {
image = GetComponent();
image.material = SpriteTextManager.Get().GetDefaultMaterial();
rectTransform = GetComponent();
if (text != "") {
sprite = SpriteTextManager.Get().GetSprite(text, size, bestFit, color, (int)rectTransform.rect.width, shadow, outline, bold, fittedBox, horizontalAlignment);
image.sprite = sprite;
if (rectTransform.localScale.y > 0) {
rectTransform.localScale = new Vector3(rectTransform.localScale.x, rectTransform.localScale.y * -1, rectTransform.localScale.z);
}
rectTransform.sizeDelta = new Vector2(sprite.texture.width, sprite.texture.height);
_text = text;
}
}
void Update() {
if (_text != text && text != "") {
sprite = SpriteTextManager.Get().GetSprite(text, size, bestFit, color, (int)rectTransform.rect.width, shadow, outline, bold, fittedBox, horizontalAlignment);
image.sprite = sprite;
if (rectTransform.localScale.y > 0) {
rectTransform.localScale = new Vector3(rectTransform.localScale.x, rectTransform.localScale.y * -1, rectTransform.localScale.z);
}
rectTransform.sizeDelta = new Vector2(sprite.texture.width, sprite.texture.height);
_text = text;
}
}
}
↧
what configurations can let unity check Dllimport libname when building.
It is strange.
I build two projects on Mac unity 2017.3.1.p4.I will generate a APK and use some native(.so) libraries.
I change the library to a wrong name. One project will check and errors happen with "dllnotfoundexception" but another can generate the apk successfully only when installing and running the app the dllnotfound errors are logged..
So I want to know that does it have some configurations on unity to control dllimport check on building or on running???
↧
↧
How do I import MySql Connector into Unity Project?
- I've tried placing the basic dll's into unity's assets folder - Result: "blah blah will cause Unity to Crash Error."
- I've tried Manually adding references - Result: Unity refreshes its references anytime the editor refreshes, so worthless.
- I've tried Installing using NuGet - Result: Closest to success as it handles all the dependencies and whatnot but I get: Assets/Scripts/Developing/TalkToDB.cs(3,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing an assembly reference?
----------
Is it some kind of a combination of "Use NuGet then copy the dll into the Assets?" or something redundant like that? cause that's about the best guess I've got.
----------
Also, I've tried a couple older versions of the NuGet package to no avail.
As well, MySql.Data *is* listed under the References of "Assembly-CSharp"
And my Unity is set to 4.X framework Using Unity's latest 2018.2.5f1 (64bit)
(I really hope that I don't have to ditch 4.x for this to work... I'll miss initializing values to properties..)
↧
DllImport safety
I've decided to grab mouse position from os ionstead of using Unity Input, to avoid mouse lag.
What I'm using is:
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out POINT lpPoint);
I'm aware, it will make my code platform - dependent, it's not a problem. But I wonder, is it safe to use? Is there any possibility this approach will be bad for stability or performance of my game?
↧
How attach dll for debug release versions x64
Hello, I have got a c# Class Library, .Net framework is 4.7.1. This library uses dll files with different CPU configuration and Build settings.
Actually, I use the x64 version and set project configuration (.csproj file) according to debug/release building like this:.\dlls\debug\dllName.dll .\dlls\release\dllName.dll
After building, it, I want to use these libraries in my Windows Unity project. But I have got a lot of problems with it.
First is - I can't set CPU configuration for unity VS project - there is ANY CPU only, how can I change it (when I change it and close VS, after opening it's ANY CPU again)?
Second is - How can I set Unity to use debug/release versions of my library?
The problem is that when I try to build the application it throws an exception that unity can't use or can't find dllName.dll. Help me, please
Actually, I use the x64 version and set project configuration (.csproj file) according to debug/release building like this:
First is - I can't set CPU configuration for unity VS project - there is ANY CPU only, how can I change it (when I change it and close VS, after opening it's ANY CPU again)?
Second is - How can I set Unity to use debug/release versions of my library?
The problem is that when I try to build the application it throws an exception that unity can't use or can't find dllName.dll. Help me, please
↧
How to properly use my own DLLs in Unity?
I have been working on an unity tool and at this point I need an external library to be used (DLL) but at the moment of using any referenced function:
[DllImport("soloud_x86.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Soloud_create();
public Soloud()
{
objhandle = Soloud_create();
}
It return an error saying DLLNotFoundException, I supposed that the problem was the [Dllimport] but error is thrown in the fifth line that is where the function is used. Because of this I don't know if it finds the Dll and then it doesn't read properly the function or it doesn't even find the library.
I have tried putting the Dll with almost every build configuration and in every plugins/editor folder but it is always the same.
↧
↧
EntryPointNotFound exception when integrating Picovoice Porcupine
I have been trying to integrate Picovoice Porcupine (https://github.com/Picovoice/Porcupine) into a proof of concept demo built for ARMv7 Android in Unity. I am attempting to access the ARMv7 .so library supplied in the GitHub repo using the DllImport function. The library appears to load correctly (as I do not receive a DllNotFoundException), however I am experiencing EntryPointNotFoundExceptions when trying to call the native functions. I think perhaps I am declaring the function calls incorrectly - if you can help me see where I'm going wrong I'd greatly appreciate it!
I have included the relevant code below, along with the Java native calls from the Android demo I was using as a reference.
**Java reference:**
private native long init(String modelFilePath, String[] keywordFilePaths, float[] sensitivities);
private native int process(long object, short[] pcm);
private native void delete(long object);
**Unity code:**
public class PorcupineManager : ScriptableObject {
...
[DllImport("pv_porcupine")]
private static extern long init(string modelFilePath, string[] keywordFilePaths, float[] sensitivities);
[DllImport("pv_porcupine")]
private static extern int process(long porcupineObjectId, short[] pcm);
[DllImport("pv_porcupine")]
private static extern void delete(long porcupineObjectId);
public void Init() {
porcupineObject = init(Path.Combine(Application.dataPath, modelPath), new string[] { Path.Combine(Application.dataPath, keywordPath)}, new float[] { sensitivity });
}
...
}
**Excerpt from log:**
> 2018-10-16 17:51:06.654 19176-19208/com.meowtek.commandandcontrol E/Unity: EntryPointNotFoundException: init
at (wrapper managed-to-native) PorcupineManager:init (string,string[],single[])> at PorcupineManager.Init () [0x0006e] in /Users/Ronan/Unity Projects/CommandAndControl/Assets/Scripts/Porcupine/PorcupineManager.cs:40> at PorcupineTest+c__Iterator0.MoveNext () [0x0005d] in /Users/Ronan/Unity Projects/CommandAndControl/Assets/Scripts/Porcupine/PorcupineTest.cs:17> at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00028] in /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17
↧
Load DLL for specific Unity version
I have two DLLs: one only works on Unity 2018 and the other only works on Unity 2017. Is there any way I can have both DLLs in my project, but only the DLL that matches the current Unity version gets loaded?
Thanks in advance.
↧
I have a problem implementing AWS S3 sdk for HololensDevelopment to store files
I tried many different ways to implement the AWS S3 sdk to my projects, targeting Hololens (different Versions of Unity 2018.2.9,2018.2.12, 2018.3.0 and different dll-Versions targeting .net35 and .net 45). Neither the provided unityPackage works ( I think the problem is that it is for mobile use, like Android, only) nor to put the correspondig dlls in the Plugin-Folder under Assets.
During work there is no error-message in the unity-console, but when i try to make a built i get the following error:
**UnityException: Failed to run serialization weaver with command "-pdb" "-verbose" "-unity-engine=Temp\StagingArea\Data\Managed\UnityEngine.CoreModule.dll" "Temp\StagingArea\TempSerializationWeaver" "-lock=UWP\project.lock.json" "@C:\Users\[username]\AppData\Local\Temp\tmp678993c6.tmp" "-additionalAssemblyPath=Temp\StagingArea\Data\Managed".**
The error message goes on but is way to long.
If i run my testcode in a VisualStudio standalone c#-Project everything works fine with the installed nuget packages of awssdk.s3
I have no idea what I'm doing wrong. Any help is apreciated.
Thanks in advance
↧
Unable to find type or namespace of imported DLL
I downloaded the "smilenet-1.2.1-win64-academic" library from this [page][1] and imported the smileNET.dll in my Unity project. Then I restarted my visual studio, and when I tried to use the library, it gave me an error that the type or namespace could not be found. I tried `using Smile;` and `using smileNET;` as indicated in their [documentation][2] file Hello.cs but it did not work. I tried 64 bit version as well as 32 bit one.
When I inspected the downloaded dll, it said that the >NET version is `v4.0.30319` while my VS2017 is running version `4.7.03056`, could that be a problem?
I also tried manually adding references. The option to add references was not appearing, so I clicked on Project>Referneces>Analyzers as shown below and then in the top menu clicked on `Project>Add References` and then added the smileNET.dll file. Doing so fixed the error (temporarily). When I closed my VS it asked me if I want to save the changes to `Chem-o-Crypt.sln Assesmbly-CSharp*`, so I said yes (although I doubt if it was really saved). But when I restarted my Visual Studio, I found that the reference was gone, and error popped up again. meh :/
Stackoverflow post here - https://stackoverflow.com/questions/54898629/unable-to-find-type-or-namespace-of-imported-dll
![alt text][3]
[1]: https://download.bayesfusion.com/files.html?category=Academia
[2]: https://support.bayesfusion.com/docs/Wrappers/
[3]: https://i.stack.imgur.com/TxBl9.png
↧
↧
Integrate Xbim Tool external library into Unity
I'm trying to transfer geometric and architectural data from an .ifc file into Unity
In order to accomplish this task, I'm using Xbim Tool's C# libraries
[Github Link here][1]
[Nuget Link here][2]
Libraries are Xbim Essentials and Xbim Geometries.
I followed [this tutorial][3] to make Visual studio accept the packages and prevent them to be wiped out by the rebuild Unity does at every start up.
Since Unity only accept dlls to be stored into the asset folder, I've used the package "Nuget for Unity" to download the packages into the asset folder.
This is the code I wrote
using System.Collections; using System.Collections.Generic; using UnityEngine; using Xbim.Ifc; using Xbim.ModelGeometry.Scene; public class Testprogetto : MonoBehaviour { // Start is called before the first frame update void Start() { const string fileName = "Muro finestrato.ifc"; using (var Stepmodel = IfcStore.Open(fileName, null, -1)) { Stepmodel.SaveAs("Muro finestrato.ifcxml"); } using (var model = IfcStore.Open("Muro finestrato.ifcxml")) { var context = new Xbim3DModelContext(model); context.CreateContext(); } } // Update is called once per frame void Update() { } }
In visual studio this compiles heavenly, but in Unity the internal compiler returns the error like I missed to import the libraries.
![alt text][4] [1]: https://github.com/xBimTeam?utf8=%E2%9C%93&q=&type=&language= [2]: https://www.nuget.org/packages?q=xbim [3]: https://www.what-could-possibly-go-wrong.com/unity-and-nuget/#usingnugetwithaseparatevisualstudiosolution [4]: /storage/temp/134998-console-error.png
[Github Link here][1]
[Nuget Link here][2]
Libraries are Xbim Essentials and Xbim Geometries.
I followed [this tutorial][3] to make Visual studio accept the packages and prevent them to be wiped out by the rebuild Unity does at every start up.
Since Unity only accept dlls to be stored into the asset folder, I've used the package "Nuget for Unity" to download the packages into the asset folder.
This is the code I wrote
using System.Collections; using System.Collections.Generic; using UnityEngine; using Xbim.Ifc; using Xbim.ModelGeometry.Scene; public class Testprogetto : MonoBehaviour { // Start is called before the first frame update void Start() { const string fileName = "Muro finestrato.ifc"; using (var Stepmodel = IfcStore.Open(fileName, null, -1)) { Stepmodel.SaveAs("Muro finestrato.ifcxml"); } using (var model = IfcStore.Open("Muro finestrato.ifcxml")) { var context = new Xbim3DModelContext(model); context.CreateContext(); } } // Update is called once per frame void Update() { } }
In visual studio this compiles heavenly, but in Unity the internal compiler returns the error like I missed to import the libraries.
![alt text][4] [1]: https://github.com/xBimTeam?utf8=%E2%9C%93&q=&type=&language= [2]: https://www.nuget.org/packages?q=xbim [3]: https://www.what-could-possibly-go-wrong.com/unity-and-nuget/#usingnugetwithaseparatevisualstudiosolution [4]: /storage/temp/134998-console-error.png
↧
Google Cloud Integration
Hello, I'm trying to incorporate some of the APIs for Google Cloud services into my project, but I'm running into some dependency issues. All of the Google APIs are available on NuGet, but since Unity has issues with that I've been manually adding the DLLs that I need. However, this specific chain of dependencies is causing issues:
`Google.Cloud.Storage.V1` -> `Google.Api.Gax.Rest` -> `Google.Api.Gax` -> `System.Interactible.Async` -> `System.Linq.Async`
Unity doesn't seem to have any System libraries related to async, which I'm guessing is either a NET feature that's too new or was stripped out due to threading issues and replaced with coroutines. Either way I'm stuck as I can't simply override Unity's versions of the System DLLs to get the async libraries these DLLs are asking for.
Is there any way to get the Google Cloud libraries to work with Unity or am I at the mercy of Google removing these dependencies? Thanks
↧
Converting from c# string to c++ string
I'm using a Dll created from a C++ file. When I either put the .dll and .lib files in my Unity-project folder or when I use the function that I need, Unity crashes and I can't open the project untile I remove the .dll or delete the function from the c# script.
This function works well on C++, both in Visual Studio and in Dev-C++
PS: Assets/alzBraccioCorretto.json is the file that I need to read
I've tried the same procedure for more simple dlls (just functions with int or double variables) and it worked fine, so I don't know what I'm missing with this one, probably UNICODE
In the Unity script I wrote
[DllImport("QuartaLibreria.dll", CharSet = CharSet.Unicode)]
static extern string LeggiFile(string nomeFile);
Text testo;
unsafe void Start()
{
testo = GetComponent();
temp = LeggiFile("Assets/alzBraccioCorretto.json");
testo.text = temp;
}
In the header of the library I have
#define QUARTALIBRERIA_API __declspec(dllexport)
//all the other headers and #include
string leggiFile(char* nomeFile);
extern "C" {
QUARTALIBRERIA_API wstring LeggiFile(wstring nomeFile);}
In the cpp of the library I have
string leggiFile(string nomeFile) {
ifstream _stream(nomeFile.c_str());
string temp;
_stream >> temp >> temp;
_stream.close();
return temp;
}
QUARTALIBRERIA_API wstring LeggiFile(wstring nomeFile){
std::string str(nomeFile.begin(), nomeFile.end());
string daRit = leggiFile(str);
std::wstring WdaRit(daRit.length(), L' '); // Make room for characters
std::copy(daRit.begin(), daRit.end(), WdaRit.begin());
return WdaRit;
}
↧
Referencing a DLL in C#
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
↧
↧
adding my own default files,changing default startup files
I created a DLL for a function library I wanted to create, but I couldn't find a way to make a default file so that it will be in every new project I open and I could access the class inside via a namespace. Its really annoying to have to drag the DLL in from my file explorer every time I want to use the functions inside it. NOTE: I'm looking for how to make it a DEFAULT FILE. I'd be super grateful for any help.
↧
Native plugin problems with varargs on iOS (Opus)
I'm trying to add the Opus library to my project using native plugins. I have it fully working on Android, Windows, and Mac. It's almost working on iOS, except for one function which is causing problems.
This is the C declaration of the function:
`int opus_encoder_ctl(OpusEncoder *st, int request, ...)`
I use this function to get and set the bitrate. It uses varargs, but there's only two variations I use, one where the third argument is an int (for setting the value) and one where it's an int pointer (for getting the value).
This is how I have the functions declared in c sharp:
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, int value);
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, out Int32 value);
I have both variations defined as separate functions. I read that this was the recommended way to call vararg functions from c-sharp, and it works on Android, Windows, Mac, and the iOS emulator. But on iOS devices it has issues. With the "out" argument function (which should correspond to the pointer variation in c), the resulting value is always zero. And with the int argument variation the function behaves strangely, as if I had passed in a much higher bitrate.
It seems like varargs are the issue here, but maybe it's the out argument? Any ideas what could be causing this?
↧
Using Windows system dlls on Hololens 2 when compiled with IL2CPP
Hello,
I'm building an App which requires the use of the MAC Address of the Hololens 2 (I'm not uploading the App to the Windows Store so no worries about security here). To do so I've used the iphlpapi.dll. To test that this worked at all, I created a stand alone UWP App and deployed it to the Hololens. This worked perfectly well and there were no issues. I didn't need to specify the location of the dll etc, the import simply worked.
The code sample I used was from here:
https://stackoverflow.com/questions/34097870/c-sharp-get-mac-address-in-universal-apps/34098615
I built this code into my Unity App, compiled it and then deployed it to the Hololens. It didn't work of course. I tried hard coding the full dll path in the import in the generated C++ but not luck.
Is there something I need to do, to allow the code to access the DLL?
Any tips or help would be much appreciated. The exact error I can get tomorrow, I'm currently not in the office.
Many thanks in advance,
Peter
↧
EmguCV 'Assets/Plugins/Emgu.CV.UI.dll' will not be loaded due to errors...
Hello everyone,
I imported EmguCV nuget package to Unity within these steps=>
https://docs.microsoft.com/tr-tr/visualstudio/cross-platform/unity-scripting-upgrade?view=vs-2019
I believe Ive done everything properly but Im getting this error=>
***Assembly 'Assets/Plugins/Emgu.CV.UI.dll' will not be loaded due to errors:
Unable to resolve reference 'ZedGraph'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
***
Thanks for helps!
↧
↧
DLL worked on WPF but not on Unity.
I have a DLL file (not my custom dll) work as communicator to another devices. There is an example solution (WPF) that use the file which working fine. I tried to create another project (WPF) to test again the file and it is also good. But when I import on Unity (2019.2.0f) to use, it keeps crashing everytime I play.
Is there any reason makes it crashing? Or is there anything I should look into first before using the file?
Please help, thanks in advance.
Is there any reason makes it crashing? Or is there anything I should look into first before using the file?
Please help, thanks in advance.
↧
I upgraded to Unity 2019.3.7 from 2018.4.0. Firebase cannot found dll. Below is the error which appears on pressing Play button.
DllNotFoundException: FirebaseCppApp-6.0.0
Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/AppUtilPINVOKE.cs:118)
Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
Firebase.AppUtilPINVOKE..cctor () (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/AppUtilPINVOKE.cs:138)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.AppUtilPINVOKE' threw an exception.
Firebase.AppUtil.SetLogFunction (Firebase.LogUtil+LogMessageDelegate arg0) (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/AppUtil.cs:45)
Firebase.LogUtil..ctor () (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/LogUtil.cs:69)
Firebase.LogUtil..cctor () (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/LogUtil.cs:30)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.LogUtil' threw an exception.
Firebase.FirebaseApp..cctor () (at Z:/tmp/tmp.IBVQRwCCZa/firebase/app/client/unity/proxy/FirebaseApp.cs:56)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.FirebaseApp' threw an exception.
Firebase.Messaging.FirebaseMessaging+Listener..ctor () (at Z:/tmp/tmp.yvSxxzhXWW/firebase/messaging/client/unity/proxy/FirebaseMessaging.cs:37)
Firebase.Messaging.FirebaseMessaging+Listener.Create () (at Z:/tmp/tmp.yvSxxzhXWW/firebase/messaging/client/unity/proxy/FirebaseMessaging.cs:46)
Firebase.Messaging.FirebaseMessaging..cctor () (at Z:/tmp/tmp.yvSxxzhXWW/firebase/messaging/client/unity/proxy/FirebaseMessaging.cs:156)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.Messaging.FirebaseMessaging' threw an exception.
PlayFabAuthenticator.Awake () (at Assets/MyScripts/PlayFabAuthenticator.cs:62)
UnityEngine.GameObject:SetActive(Boolean)
WelcomeManager:Awake() (at Assets/MyScripts/WelcomeManager.cs:38)
UnityEngine.GameObject:SetActive(Boolean)
LauncherManager:Awake() (at Assets/MyScripts/LauncherManager.cs:68)
↧
csc.rsp works in editor but throws an error when building
Hey,
for a current project I have to scale the byte/color array of an image, therefore I found the easiest way to do that is using System.Drawing (if somebody has a better solution I am open for it :D).
System.Drawing is unfortunately not included in Unity by standard, therefore I set up a csc.rsp with the following line '-r:System.Drawing.dll'.
That does work like a charm in the editor. Unfortunately when I am trying to build I still get:
"error CS0234: The type or namespace name 'Image' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)" - errors.
Is there anything additional I need to set up to get this working?
I am using Unity 2019.3.2 building for x64 and using Mono as scripting backend.
↧
Multiple DLL with the same class reference
Hello,
I am using third party libraries in my projects, one is
[Diagflow for Unity][1] and the second is [Ros for Unity][2]
My issue comes with the fastJSON.dll and NewtonSoft.Json.dll they both are sharing classes namespaces and i get the error
"The class X exist in both LIBRARY1 and LIBRARY2"
if i remove one of the 2 libraries errors dissapear, BUT there are third libraries that depend to both libraries, so if i remove one i can run the project but i get the error
"THIRDASEMBLY can not be load because it cant locate (THE LIBRARY I HAVE JUST DELETED)"
I cant modify those libraries since they are thirdparty, I have tried adding an extern alias following [this example][3] without success
[1]: https://github.com/dialogflow/dialogflow-unity-client/tree/master/Assets/ApiAiSDK
[2]: https://github.com/siemens/ros-sharp
[3]: https://github.com/DashW/UnityExternAlias/tree/master/Assets
↧
↧
Android 64-bit .so DLL file not found error
Hello,
I am trying to update an older plugin to work for Android 64 bit builds, and am running into problems. Namely, I am trying to update the "OpenCV + Unity" plugin, and I have already created a 64bit "libOpenCvSharpExtern.so" file by editing the repo [here](https://github.com/Gobra/OpenCV-Unity).
The file I have created is available [here](https://drive.google.com/file/d/1krnXgpeG7zXexUzgp6jzJpkx0IsGW22x/view?usp=sharing). I have checked using MSYS2 "file" commands that the file is a 64bit build file, which all seems to be correct, as far as I can tell. I have then added the file to "/Assets/../Plugins/Android/arm64-v8a/libOpenCvSharpExtern.so".
By my understanding, this should work. Instead, the .so file is not added to my APK and the DLL cannot be found, resulting in the error:
AndroidPlayer(ADB@127.0.0.1:34999) DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
at OpenCvSharp.NativeMethods.core_Mat_sizeof () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at molAR.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as OpenCvSharpException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
*** An exception has occurred because of P/Invoke. ***
Please check the following:
(1) OpenCV's DLL files exist in the same directory as the executable file.
(2) Visual C++ Redistributable Package has been installed.
(3) The target platform(x86/x64) of OpenCV's DLL files and OpenCvSharp is the same as your project's.
System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.
at OpenCvSharp.NativeMethods.core_Mat_sizeof () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods.TryPInvoke () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.NativeMethods..cctor () [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception.
at OpenCvSharp.OCRHMMDecoder+ClassifierCallback..ctor (System.String fileName, OpenCvSharp.CvText+OCRClassifierType type) [0x00000] in <00000000000000000000000000000000>:0
at OpenCvSharp.Demo.AlphabetOCR..ctor (System.Byte[] model) [0x00000] in <00000000000000000000000000000000>:0
at myCode.Start () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
----------
I have also tried to create a linker file based on another answer on this site, the file is called "link.dll" and has the below contents, which are quite possibly wrong:
----------
What am I doing wrong here? I am quite new to all this and likely doing something silly.
Thank you in advance for your help!
↧
Can i call an external method from a job?
Is it possible to call a method from a .dll in a job? I'm doing some optimizing and I want to combine multithreading with SIMD for the best performance result. I do know however that the job system can be quite limiting when it comes to transferring information, so I wondered if this is even possible, or if there might be caveats.
↧
UnityEngine.dll outside Unity
Hi,
i'm working on a visual studio project trying to use UnityEngine.dll as a reference within it, outside the Unity Editor. For what I have seen and read, Unity .dlls are not accessible from outside the engine, i was wondering if there was a turnaround for this, like compiling the project with Mono or accessing directly the Unity .dlls with decompiling tools, if possible.
Thanks to all,
↧
How do I reference multiple dll files?
I, need the System.Drawing.dll for two different dependencies but when I import the .Net 2.0 version the one dependance says it needs the .Net 4.0 one and the other way around. If I import both versions VS says it can't accept multiple versions of the same dll.
↧
↧
Importing external DLLs to satisfy AssetBundle MonoBehaviour references
Hi there!
It's my understanding that AssetBundles & Addressables cannot contain scripts. As an alternative, I'm choosing to load a DLL alongside (but before loading the addressable catalog).
However, when pulling it with Assembly.LoadFile, I'm able to instantiate MonoBehaviours, etc.; but when pulling a prefab from the addressable catalog, it cannot find the referenced MonoBehaviours. Is there a way to inform Unity about these MonoBehaviours? Do I have to change something in my build process to do so, or is this something I can do at runtime?
↧