Getting UART to work in 3.5

Hello.
I’m trying to get uart to work in unity 3.5.
There seems to be a problem importing Plugins.
As it requires Unity3D 3.1, I’m pretty stuck.
there is nothing that help document how it works, but basically, the problem is when loading plugins…
here is the script :

using UnityEngine;
using System;
using System.IO;
using System.Runtime.InteropServices;

public class Plugins : MonoBehaviour {

    public string[] PluginNames = {"VideoWrapper","TrackerWrapper"};

	// Use this for initialization
	void Awake () {
		AddToPATH("", true);
        for (int i=0; i<PluginNames.Length; i++) 
			AddToPATH(PluginNames*, true);	*
  • }*

  • void AddToPATH(String subpath, bool useProjectDir)*

  • { *

  •  //.NET 1.1 has no string.Contains method or System.Environment class*
    
  •  #if !UNITY_IPHONE*
    
  •  string cwd = ApplicationDataPath();*
    
  •  Debug.Log("[CWD]"+cwd);*
    
  •  string dataDirName = "Plugins";*
    
  •  String dataDirectory = Path.Combine(cwd,dataDirName);*
    
  •  string separator;*
    
  •  string environVar;*
    
  •  if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)*
    
  •  {*
    
  •  	environVar = "PATH";*
    
  •  	separator = ";";*
    
  •  }*
    
  •  else if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)*
    
  •  {*
    
  •  	environVar = "DYLD_LIBRARY_PATH";*
    
  •  	separator = ":";*
    
  •  }*
    
  •  else*
    
  •  {*
    
  •  	Debug.Log("Not using native platform app");*
    
  •  	return;*
    
  •  }*
    
  •  string oldPath = System.Environment.GetEnvironmentVariable(environVar);*
    
  •  Debug.Log("[Old Path]"+oldPath);*
    
  •  String pluginPath;*
    
  •  if (useProjectDir)*
    
  •  	pluginPath = Path.Combine(dataDirectory,subpath);*
    
  •  else*
    
  •  	pluginPath = subpath;*
    
  •  if(oldPath == null || !oldPath.Contains(pluginPath))*
    
  •  {*
    
  •  	string newPath = oldPath + separator + pluginPath +"/";*
    
  •  	Debug.Log("[New Path]"+newPath);*
    
  •  	System.Environment.SetEnvironmentVariable(environVar,newPath);*
    
  •  	System.Environment.SetEnvironmentVariable("PATH",newPath);*
    
  •  }else{*
    
  •  	Debug.Log("Path already contains plugin dir");*
    
  •  }*
    
  •  #endif*
    
  • }*

  • public static string ApplicationDataPath()*

  • {*

  •  #if UNITY_IPHONE*
    
  •  // Application.dataPath returns something like "/var/mobile/Applications/30B51836-D2DD-43AA-BCB4-9D4DADFED6A2/Data"*
    
  •  // Unity 1.6 dataPath returns something like "/var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/myappname.app/Data"*
    
  •  // Strip the "Data" part and add "Documents" instead*
    
  •  string path = Application.dataPath.Substring(0,Application.dataPath.Length-5);*
    
  •  if (path.Substring(path.Length-4) == ".app") //Unity 1.6*
    

path = path.Substring(0, path.LastIndexOf(‘/’));
return path + “/Documents”;

  •  #else*
    
  •  return Application.dataPath;*
    
  •  #endif*
    
  • }*

  • public static string CreateFileFromAsset(string filename)*

  • {*

  •  TextAsset textAsset = (TextAsset)UnityEngine.Resources.Load(filename);*
    
  •  string filepath = ApplicationDataPath() + "/" + filename;*
    
  •  BinaryWriter binWriter = new BinaryWriter(File.Open(filepath, FileMode.Create));*
    
  •  binWriter.Write(textAsset.bytes);*
    
  •  binWriter.Close();*
    
  •  return filepath;*
    
  • }*

}
Thanks for viewing…
Any other AR based plugins. for desktop PC are welcome… this however is the only one I can find…

Are you able to get the plugins working in the editor? You need to add a folder to the Assets directory called Plugins and then add the UART files, add .cs files to the gameobjects in the scene and it seems to work just fine for me (using the Intersense 900 tracker). Only problem I’m having right now is getting VRPN to work properly when it’s compiled in a OS X standalone application. Adding the plugin folder to the App contents directory begins to work but then VRPN fails to detect the tracker… Pretty sure it’s not communicating with the libisense.dylib.

Hope this helps.