Esempio n. 1
0
    void OnEnable()
    {
        if (initialized) return;
		
		
		
		string dfgString="";	  		
        if (ubitrackComponentsPath == null )
        {
            throw new MissingMemberException("ubitrack component path is empty, ubitrack can't work");
        }
		
		#if !UNITY_ANDROID || UNITY_EDITOR		

		string dir = Path.GetFullPath(Application.dataPath+Path.DirectorySeparatorChar+"..")+Path.DirectorySeparatorChar;
		
		DirectoryInfo dirInfo = new DirectoryInfo(dir);
		FileInfo[] filesInDir = dirInfo.GetFiles();
		
		foreach(FileInfo f in filesInDir) 
		{			
			if(f.Extension.Equals(".dfg")) 
			{
				Debug.Log("Found dfg in project folder:"+f.FullName);
				StreamReader reader = f.OpenText();				
				dfgString = reader.ReadToEnd();
				reader.Close();
				break;
			}
				
		}
		
       
		
		if(logConfig.Length > 0) {			
			string logfile = dir+logConfig;
			if(File.Exists(logfile))
			{
				Debug.Log("Init UbiTrack Logging with file:" + 	logfile);
                Ubitrack.ubitrack.initLogging(logfile);
			} else {
				Debug.LogError("UbiTrack log file does not exist: "+logfile);
			}
			
		}
		#else
		var unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		var activity = unity.GetStatic<AndroidJavaObject>("currentActivity");
		// Retrieve ApplicationInfo and nativeLibraryDir (N.B. API-9 or newer only!)
		var info = activity.Call<AndroidJavaObject>("getApplicationInfo");
		ubitrackComponentsPath = info.Get<String>("nativeLibraryDir");		
		
		Ubitrack.ubitrack.initLogging("TRACE");
		#endif
		
		
		
		if (dfgString.Length == 0)
        {
			if(dataflowFile != null) 
			{
				dfgString = dataflowFile.text;
			} 
			else 
			{
            	throw new MissingMemberException("ubitrack dataflow is empty, ubitrack can't work");
			}
        }
		
		
                
		m_facade = new Ubitrack.SimpleFacade(ubitrackComponentsPath);

        dfgParser = new DFGParser(dfgString);
	
		
		

        
		
        
        
	}
Esempio n. 2
0
	public void stopUbiTrack(){
		if (m_facade == null)
            return;
    
        Debug.Log("stopUbiTrack, Shutting down ubitrack, components:" + appComponents.Count);

        foreach (UbiTrackComponent comp in appComponents)
        {
            if (comp != null)
            {
                comp.utStop();
            }

        }

        m_facade.stopDataflow();
        
        
        

        foreach (UbiTrackComponent comp in appComponents)
        {
            if (comp != null)
            {
                comp.utDestroy();
            }

        }

        m_facade.clearDataflow();


        //m_facade.killEverything();
    	m_facade = null;
		Debug.Log("Ubitrack shut down");
	}