Adding a class to a unity script

I am working with an external IMU and wanted to do some testing. I have created a C# class that has a method to initialize the IMU and a method to collect data from the IMU and add it to class properties so I can access the data through the class. I have put the class .dll in the Lib folder for unity and it recognizes the class because using TFClass; does not generate an error. Also the reference to the class methods is correctly recognized. The code for the unity script is:

using UnityEngine;
using System.Collections;
using TFClass;

public class IMUConnectiontoCube : MonoBehaviour
{
Vector3 cubePosition;
float cubeX = 0.0f;
float cubeY = 0.0f;
float cubeZ = 0.0f;
float cubeXVel = 0.0f;
float cubeYVel = 0.0f;
float cubeZVel = 0.0f;
float deltaT = .1f;
TinkerForge TF;
//
// Use this for initialization

void Start()
{
TF = new TinkerForge();
TF.imuInit(“6CPiac”);
cubePosition = transform.position;
Time.fixedDeltaTime = deltaT;
}
// Update is called once per frame
void FixedUpdate()
{
TF.imuGet();
cubeXVel = cubeXVel + TF.LinAccel[0]*deltaT;
cubeYVel = cubeYVel + TF.LinAccel[1]*deltaT;
cubeZVel = cubeZVel + TF.LinAccel[2]*deltaT;
cubeX = cubeX + cubeXVel * deltaT + .5f * TF.LinAccel[0] * TF.LinAccel[0];
cubeY = cubeY + cubeYVel * deltaT + .5f * TF.LinAccel[1] * TF.LinAccel[1];
cubeZ = cubeZ + cubeZVel * deltaT + .5f * TF.LinAccel[2] * TF.LinAccel[2];
cubePosition.x = cubeX;
cubePosition.y = cubeY;
cubePosition.z = cubeZ;
transform.position = cubePosition;
}
}

However with I try to run the script and attach it to unity I get the following:

Severity Code Description Project File Line Suppression State
Warning The primary reference “TFClass” could not be resolved because it has an indirect dependency on the .NET Framework assembly “mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089” which has a higher version “4.0.0.0” than the version “2.0.0.0” in the current target framework. IMU Interface Test.CSharp

Warning The primary reference “TFClass” could not be resolved because it was built against the “.NETFramework,Version=v4.5.2” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v3.5,Profile=Unity Subset v3.5”. IMU Interface Test.CSharp

I have rebuilt the class targeting the .NET 2.0 and replace the original .dll file in the Lib folder with the new .dll file but still get these warning messages. What do I need to do to get a clean build?

Thanks for any help,

code tags, use them, PLEASE

The Lib folder? Where’s that? You should place managed dlls somewhere in your project’s Assets folder.

There are a couple of things you could try:

  • set the api compatibility level to .NET 2.0 instead of .NET 2.0 subset
  • Built it against .net 3.5
  • add the source files to the project instead of building a dll