Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by naf456 · Jan 14, 2012 at 04:09 PM · plugins3.5aruart

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[i], 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...

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image naf456 · Jan 14, 2012 at 04:11 PM 0
Share

if you run this in unity- it crashes the whole app (unity that is), producing no error messages...

avatar image Zied-M · Jan 16, 2012 at 10:06 AM 0
Share

Hi naf456 i was resarching for any AR plugin for unity desktop aplication since 2 weeks. but it seems the only one is UART. all the other works for andoid or iOS platforms.

I m about to start working with UART to make a desktop application (unity 3.4) so if i have any information i will share it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cap10subtext · Mar 20, 2012 at 10:08 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

help me Create game AR 0 Answers

C# static class not in Plugins folder 1 Answer

Updating a texture from a plugin for Unity 3.5 and later 3 Answers

How can I access unity android res folder from jar? 1 Answer

Plugins don't play nicely 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges