Quantcast
Channel: Questions in topic: "dll"
Viewing all 706 articles
Browse latest View live

Transfer scene from project that uses DLL back to original source code

$
0
0
Hi, As the title says, the game I am developing gives a DLL out to the community to create new levels. Due to certain changes between Unity versions, the old method I had to play community created levels no longer works. I was wondering if there is a way for me to package the community levels up as a normal package, then unpackage them in the original project? At the moment, doing this breaks all the script connections (as they are trying to reference scripts in the DLL). If I import the DLL with the scene, there are obviously hundreds of conflicts between the DLL and the original scripts (error CS0433: The type 'x' exists in both 'DLLAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'OriginalAPI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null') Any suggestions would be appreciated, thanks!

Pass a GameObject to a DLL

$
0
0
Hey,I have a DLL that I use to save the player's position, but when passing the parameters I can only pass Floats created by me, but I want to pass the entire GameObject to the DLL. This is my code in the DLL; using System; using System.Text; using System.Xml; using System.Xml.Serialization; namespace SaveXML { public class MyXML { public void Save(float lx, float ly, float lz) { XmlDocument xmlDoc = new XmlDocument(); XmlNode rootNode; string filename = "MiPrimerXML.xml"; if (System.IO.File.Exists(filename)) { xmlDoc.Load(filename); rootNode = xmlDoc.SelectSingleNode("Game"); } else { rootNode = xmlDoc.CreateElement("Game"); xmlDoc.AppendChild(rootNode); } XmlNode userNode = xmlDoc.CreateElement("GameObject"); XmlAttribute attribute = xmlDoc.CreateAttribute("name"); attribute.Value = "Player"; userNode.Attributes.Append(attribute); rootNode.AppendChild(userNode); XmlNode Vector = xmlDoc.CreateElement("Vector"); XmlAttribute x = xmlDoc.CreateAttribute("X"); x.Value = lx.ToString(); XmlAttribute y = xmlDoc.CreateAttribute("Y"); y.Value = ly.ToString(); XmlAttribute z = xmlDoc.CreateAttribute("Z"); z.Value = lz.ToString(); Vector.Attributes.Append(x); Vector.Attributes.Append(y); Vector.Attributes.Append(z); userNode.AppendChild(Vector); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(false); // Falso = no escribir BOM settings.Indent = true; XmlWriter writer = XmlTextWriter.Create(filename, settings); xmlDoc.Save(writer); } } } And this is my code in Unity using System.Collections; using System.Collections.Generic; using UnityEngine; using SaveXML; public class Save : MonoBehaviour { private SaveXML.MyXML savedll; private GameObject Jugador; // Start is called before the first frame update void Start() { savedll = new MyXML(); Jugador = GameObject.FindGameObjectWithTag("Player"); } // Update is called once per frame public void SaveXML() { float x = Jugador.transform.position.x; float y = Jugador.transform.position.y; float z = Jugador.transform.position.z; savedll.Save(x, y, z); } }

Return a Exist GameObject

$
0
0
Hi! I have a DLL to save and load a GameObject, I use a script in Unity to get this GameObject. In the DLL I do; gameObject go; public GameObject Load () { ... return go; } And in Unity I have GameObject Player; Player = GameObject.FindGameObjectWithTag("Player"); public void LoadXML() { Jugador = usedll.Load(); } How can I make sure that a new gameObject is not created and that when using the Load function make the Player be edited?

How to import UnityEngine.dll in C++

$
0
0
I am currently working on a project in which I have to use `UnityEngine.dll` located in `install_location/Editor/data/Managed/UnityEngine.dll` in `C++` and export that project as a `C++/CLI` DLL. Is there any way we can use this with the help of `Visual Studio`. If someone knows how to import the dll in any `C++` project and use it, please answer, I would be really grateful to you. Thanks in advance.

Get icon files in Unity

$
0
0
I'm trying to get icon files on a project oriented for windows only. I'm using system.Drawing. The dll has been included from a csc.rsp file: -r:System.drawing.dll Works fine without errors and can be compiled also. But I obtain always an empty image; Here is the code: ![public class SaveIcons : MonoBehaviour { void Start() { Icon appIcon = Icon.ExtractAssociatedIcon("C:\\Users\\Arrasss\\Pictures\\dexwallpapers\\ac96ba3b4338dafc2244757021992163-1000.jpg"); System.Drawing.Image MyIMG = appIcon.ToBitmap(); MyIMG.Save("test.bmp"); } }][1] You can see on the image what I always get. what I'm doing wrong? [1]: /storage/temp/173149-test.png

Managed plugin missing components

$
0
0
I have a managed plugin that's been working without issue until I updated to Unity 2020.2. Now, when my project builds for iOS/Android in Unity Cloud Build, the builds succeed, but there are a bunch of new warnings like `Script attached to 'object' in scene 'scene' is missing or no valid script is attached`, and the builds crash at runtime on a device. Following [this post's][1] recommendations, I made a fresh clone of my project locally and the objects in question *do* show the usual missing component warnings. However, I am unable to select the *correct* script (a class from my managed plugin) in this fresh clone. The DLL *is* present in the project, but expanding it in Unity's Project view, the class I need isn't there. When I reimport that DLL, suddenly all the missing classes come back, and the components show up again on my objects. Unfortunately, nothing in my project changes when this happens; no scene or .meta files are updated, so I have no way of committing this seemingly fixed state to my repo for Cloud Build to see. And if I Reimport All, those script references are broken again. I've tried deleting the Library folder manually, rebuilding the managed plugin, deleting its .meta file so Unity regenerates it, and deleting the entire DLL and adding it back in. Nothing is permanently fixing my project. What confuses me the most is that Reimport All is effectively "undoing" the reimport of my plugin. Its like Unity decides that a different "version" of the plugin is correct depending on what gets reimported. I would really appreciate some insight here. Thanks in advance! [1]: https://forum.unity.com/threads/script-attached-to-in-scene-is-missing-or-no-valid-script-is-attached-errors-on-ios.372735/

Unity XR plugin manager Tries to load oculus dll on windows even if its disabled.

$
0
0
I am working on a project where I use both a vive cosmos and an oculus quest 2, for the oculus quest my build target is android and for the vive cosmos its standalone/windows. Now my XR Plugin Manager only has the OpenVRLoader enabled for the standalone tab and on the android tab only the oculus loader is enabled.

Now for some reason, when I build for the vive I get the DllNotFoundException: OculusXRPlugin error. I have checked all of my scripts and assemblies and none of them reference oculus while on windows. I completely removed the Oculus plugin just to check if its really not referenced anywhere and once it was removed the build worked fine.

I really don't understand why exactly my build tries to load this .dll even if it isn't referenced by me.

I am using the Oculus.Plugin 1.7.0
Unity 2020.1.13f1 XR Plugin Management 3.2.17

System.ExecutableAndDlls eating up memory

$
0
0
Seem like my System.ExecutableAndDlls consuming RAM very badly. I'm trying to play a 360 video on HTC Vive Focus Plus, but when running, I can't ignored that memory had been consuming till the point when I testing at my headset, it crashes. Is there any methods to reduce it? ![alt text][1] [1]: /storage/temp/175105-144280419-4269876443040661-7808172673670374951-o.jpg

Shared memory between c# and c++

$
0
0
I'm working on a project to create a VR sculpting tool voxel based, this project that involved two main process. On Unity I manage the user interaction and the storage of data structure. For the data manipulation I use c++ libraries. The voxel grid is very big, about 4000x4000 voxels, I need more efficiency, this is the reason why I chose to use the c++ dll. I have read more tutorial e docs about the intoroperability berween c# and c++, but I'm still confused about how to implement the comunication from two process. I have to manipulate two structure, one fixed size array of int `(c#: int[] -> c++: int[])` and one variable size vector of pointer to a vector `(c#: List -> c++: std::vector*>)`. Up till now, I've been able to read\write from the `int[]`, I have some problem for the second one, I can't add element to the vector from c++ dll, if I add an element from c# I don't have problems to read and write it from c++. The code of the two processes: /************ C++ *************/ #define EXPORT_API __declspec(dllexport) //Function to write into a int[] array EXPORT_API bool GetIndices(int indices[], int indicesLenght) { for(int i = 0; i < indicesLenght; i++){ indices[i] = 10; } return true; } static void* blocksBufferHandle = NULL; static void* blocksBufferHandleOriginal = NULL; static int blocksBufferVertexCount; static std::vector g_VertexSource; EXPORT_API void SetBlocksBuffersFromUnity(void* blocksBufferHandleFromUnity, int blocksCount) { blocksBufferHandle = blocksBufferHandleFromUnity; blocksBufferHandleOriginal = blocksBufferHandleFromUnity; blocksBufferVertexCount = blocksCount; g_VertexSource.resize(blocksCount); for (int i = 0; i < blocksCount; ++i) { auto *b = new std::vector(16, 5); g_VertexSource[i] = b->data(); } } /************ C# *************/ using System; using System.Runtime.InteropServices; using System.Collections.Generic; using UnityEngine; public class PluginImport : MonoBehaviour { [DllImport("libUnityPlugin", CallingConvention = CallingConvention.Cdecl)] public static extern bool GetIndices([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr indices, int indicesLength); [DllImport("__Internal")] private static extern void SetBlocksBuffersFromUnity(IntPtr blocks, int blockSize); public int size; //Grid size void Start() { int indicesLenght = 10; int[] indices = new int[indicesLenght]; GCHandle indicesHandle = GCHandle.Alloc(indices, GCHandleType.Pinned); IntPtr addressIndices = indicesHandle.AddrOfPinnedObject(); GetIndices(addressIndices, indicesLenght); Debug.Log("Indices value: " + (int)indices[0]); //Output: 10 OK int blocksLength = 10; var blocks = new List(); GCHandle blocksHandle = GCHandle.Alloc(blocks, GCHandleType.Pinned); IntPtr addressBlocks = indicesHandle.AddrOfPinnedObject(); SetBlocksBuffersFromUnity(addressBlocks, blocksLength); Debug.Log("Block value: " + blocks[o]); //Error indicesHandle.Free(); blocksHandle.Free(); } } If I try to read the first element Unity of the vector, returns this error, If I print the length of `blocks` is 0 : ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. I suppose c# doesn’t notice the addition of elements made by c++. For some parts of the code (Setblocksbuffersfromunity) I took the cue from the Unity documentation. I'm working on this code from about 2 month, I tried several solutions, but any worked for the vector. Any suggestions? thanks

Native C++ plugin on Hololens2

$
0
0
* I have created a naive C++ dll that I'm able to run within Unity itself, but when I try to run / build / deploy onto the Hololens2 it does nothing. * It is a real basic script, all it does it change the 3D text * It does not throw any errors, at least nothing I see * The text shows up on the Hololens, but the fact it does not change, leads me to believe that the C++ code is never executed Any thoughts?

Unity Included DLLS Size

$
0
0
Hi, i try to reduce space of my build. Textures 2.1 mb 9.3% Meshes 0.0 kb 0.0% Animations 246.4 kb 1.1% Sounds 4.5 mb 19.5% Shaders 32.3 kb 0.1% Other Assets 599.8 kb 2.6% Levels 73.1 kb 0.3% Scripts 1.8 mb 7.9% Included DLLs 13.4 mb 59.0% File headers 41.7 kb 0.2% Total User Assets 22.8 mb 100.0% Complete build size 67.4 mb For some reason, Included DLLS use 59% of the space, how can i reduce that?. Thank you.

Exception: dll could not be located at..

$
0
0
Hello I upgraded the unity version because it is my build problem But I ran into this error please help :( Exception: dll could not be located at D:\Unity Oyunları\Flappy\Library\ScriptAssemblies\com.unity.multiplayer-hlapi.Runtime.dll! Unity.UNetWeaver.Program.CheckDLLPath (System.String path) (at Library/PackageCache/com.unity.multiplayer-hlapi@1.0.8/Editor/Tools/Weaver/Program.cs:41) Unity.UNetWeaver.Program.Process (System.String unityEngine, System.String unetDLL, System.String outputDirectory, System.String[] assemblies, System.String[] extraAssemblyPaths, System.Action`1[T] printWarning, System.Action`1[T] printError) (at Library/PackageCache/com.unity.multiplayer-hlapi@1.0.8/Editor/Tools/Weaver/Program.cs:29) UnityEditor.Networking.WeaverRunner.OnCompilationFinished (System.String targetAssembly, UnityEditor.Compilation.CompilerMessage[] messages) (at Library/PackageCache/com.unity.multiplayer-hlapi@1.0.8/Editor/WeaverRunner.cs:133) UnityEditor.Compilation.CompilationPipeline+<>c.b__18_3 (System.String assemblyPath, UnityEditor.Compilation.CompilerMessage[] messages) (at <8d21067e8d9c494db25a2b2485216e63>:0) UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)

method body replaced by unityLinker.exe with a notsupportedexception

$
0
0
I'm working with mysql.data and newtonsoft json dll for my game. There is a problem. I'm building my game with mono scriptbaackend method. My game works perfectly. But when i use il2cpp My game mysqlconnection not working. it says method body replaced by unityLinker.exe with a notsupportedexception Editor works fine. But when i try on my mobile device i'm getting this error when i try to connect my database.

Problems with using openhardwaremonitorlib.dll with Unity.

$
0
0
Hello everyone! So, I am trying to work the OpenHardwareMonitorLib.dll with Unity to get some hardware stats displayed within Unity. I have added the plugin and it seems to be placed okay. I am getting some NullReferenceExceptions when I hit Play. Its because of the library for sure but I couldn't figure out exactly how to fix that. Could anyone please share their experiences with it? Any help would be really appreciated! The code I am using is as follows: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using OpenHardwareMonitor; using OpenHardwareMonitor.Hardware; using OpenHardwareMonitor.Collections; public class MenuManager : MonoBehaviour { // Start is called before the first frame update void Start() { GetSystemInfo(); } // Update is called once per frame void Update() { } public class UpdateVisitor : IVisitor { public void VisitComputer(IComputer computer) { computer.Traverse(this); } public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this); } public void VisitSensor(ISensor sensor) { } public void VisitParameter(IParameter parameter) { } } public static void GetSystemInfo() { UpdateVisitor updateVisitor = new UpdateVisitor(); Computer computer = new Computer(); computer.Open(); computer.CPUEnabled = true; computer.Accept(updateVisitor); for (int i = 0; i < computer.Hardware.Length; i++) { if (computer.Hardware[i].HardwareType == HardwareType.CPU) { for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++) { if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Temperature) Console.WriteLine(computer.Hardware[i].Sensors[j].Name + ":" + computer.Hardware[i].Sensors[j].Value.ToString() + "\r"); } } } computer.Close(); } } ![alt text][1] [1]: /storage/temp/177006-logohm.png

I want to change the dll reference setting when I start the program.

$
0
0
Write the same name and namespace and create multiple dlls with only different versions. Only one of the dlls activates autoReference.(Otherwise, an error such as [The type ' ' exists in both] will occur.) I want to know how I can change the reference to dll when I run the program in this state.

The Assembly is referenced, But the dll is not allowed to be included or could not be found

$
0
0
I am getting the following error when I try to build my project: `ArgumentException: The Assembly nunit.framework is referenced by MapboxAssembly ('Library/PlayerScriptAssemblies/MapboxAssembly.dll'). But the dll is not allowed to be included or could not be found.` The dll is located at `Packages/com.unity.ext.nunit/net35/unity-custom/nunit.framework.dll` But when I inspect the dll to attempt to set this to be excluded on standalone platforms, all the inspector options are greyed out. I can't just set the MapboxAssembly to be only included in Editor platforms because I have references to it. What can I do here? Why is this nunit dll installed at this location? When I try to remove it from this location and add it back somewhere else, I get compile errors. I have also tried setting the API compatibility to .NET Standard 2.0 (from .NET 4.x) but this does not solve the issue.

How to add a custom module to Unity?

$
0
0
Greetings, I have been trying to look for some information concerning my issue with no avail. I humbly ask for your help and I apologize if this has been solved already, I have been unable to find it. My intention is to add a Custom Platform/Plugin to the Unity install. I already have my own native plugin C++ DLL and also a managed plugin C# DLL with the required dllimports: *[DllImport("ASimplePlugin", CallingConvention = CallingConvention.Cdecl)] private static extern int PrintANumber();* I also have noticed the **modules.json** file with all platforms and plugins a Unity Install can have. But I don't know how to proceed from here. If I add a new entry to the **modules.json** file, what info do I set in or what do I have to do additionally in order to have my DLLs automatically imported and accessible from scripts in the new project I create with that custom module? ![alt text][1] I really appreciate your help and I hope you could bring some light into this issue. [1]: /storage/temp/178115-unityplatform.png

How to use dll files properly in Unity?

$
0
0
I wrote a program that puts an QR-Code on a PDF page. Now i want it to be part of a Unity project and i am having trouble with implementing it. Used in the project: using System.Drawing; using PdfSharp.Drawing; using PdfSharp.Pdf; using System.IO; Here is the problem: XFont font = new XFont(tkFont, fontSize, XFontStyle.Regular); `new XFont` gets underlined red. It is part of `PdfSharp.Drawing;` but once i try to use it in Unity, Visual Studio tells me that: "The type `'FontFamily'` allegedly has been declared in `System.Drawing` but could not been found", even thoit originates from `PdfSharp.Drawing`. I already tried to set Unity .NET from Version 2.0 to 4.x and i also tried different packages in terms of version numbers. It is the first time that i try to implement external dll files into unity, so maybe the problem could be something related to that. Also other things that originate from `PdfSharp.Drawing` like `XGraphics` seem to work properly All in all, Visual Studio is able to run it, Unity is not able to do so even tho i imported all necessary dll files. I hope somebody can help me with this. Thanks in advance for every bit of hints you can give me.

The assembly reference failed when trying to access Mono.Data.Sqlite to connect to the Sqlite database

$
0
0
I've tried several ways, I've already created the Plugins folder, I've already added the Mono.Data.Sqlite reference, I've already created my database, everything is fine but nothing works, I've added the sqlite dll, but nothing, it seems to me that error and the script doesn't work. . If anyone can help ![alt text][1] [1]: /storage/temp/179678-erro.png

Listen for clicks outside of unity application

$
0
0
Hi, I am building an overlay application for Windows using Unity. I want my overlay to listen for clicks, even when another window is in focus. As far as I experimented, Input.GetMouseButtonDown(0) and other Event KeyCodes only work while unity app is in focus. Soon as I click another window, it stops getting events. I know it does make sense, as recording clicks in another process is uncommon and unthrusted. Anyhow, does someone know of another way to listen for mouse input, with a Unity app running in background ? Maybe using user32.dll or another Windows library?
Viewing all 706 articles
Browse latest View live


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