- Home /
Question by
aagren · Dec 05, 2015 at 06:09 PM ·
script.error messagedllc++
cant add script component, because the script class cannot be found
my unity script is crashing when trying to run. im trying to access .dll files since i use c++ code and the script is suppossed to call these. the code does not give any errors but when running i get this message "cant add script component, because the script class cannot be found" this is my code, can anyone see why it refuses to run
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System.IO;
public class UseDll : MonoBehaviour
{
// Straight From the c++ Dll (unmanaged)
[DllImport("SpheroDefender15338", EntryPoint = "TestDivide")]
public static extern float StraightFromDllTestDivide(float a, float b);
// Use this for initialization
void Start()
{
/* */
// Call the C# DLL SharpMultiply function
float multiplyResult = TestCSharpLibrary.TestCSharpLibrary.SharpMultiply(3, 5);
// Call the C# DLL TestDivide function which relies on the C++ DLL for this functionality
float divideResult = TestCSharpLibrary.TestCSharpLibrary.TestDivide(15, 3);
float straightFromDllDivideResult = StraightFromDllTestDivide(20, 5);
// Print it out to the console
Debug.Log(multiplyResult);
Debug.Log(divideResult);
Debug.Log(straightFromDllDivideResult);
// Write the result into a file, so we can even see it working in a build
using (StreamWriter writer = new StreamWriter("debug.txt", true))
{
writer.WriteLine(multiplyResult);
writer.WriteLine(divideResult);
writer.WriteLine(straightFromDllDivideResult);
}
/* */
}
// Update is called once per frame
void Update()
{
}
}
Comment
not near anywhere to test/confirm but you might need a using
statement for the your dll's namespace.