- Sort Posts
- 7 replies
- Last post
Saving the Image Target names as xml documents
Saving the Image Target names as xml documents
I'd recommend using Application.persistentDataPath+"/" as the base of your path. That will resolve to the appropriate directory across device contexts.
http://docs.unity3d.com/Documentation/ScriptReference/Application-persistentDataPath.html
Saving the Image Target names as xml documents
You can, though if you anticipate a lot of read / writes to the file, it would probably be a good idea to implement this in another script which inherits from MonoBehaviour and have it perform these operations within its update method - e.g. it would receive the trackable name and status from the event handler and then peform the file operation within its own update callback. That way the event handler isn't blocked w/ the file operation.
Saving the Image Target names as xml documents
Thank you David i wrote this code and it worked on my computer i wil test it on my phone see where it goes and after ill add the Datapath but for now it works thank you
import System;
import System.IO;
var fileName = "chips.txt";
class MyCoolObject extends MonoBehaviour {
var myCoolInt : int;
var myCoolFloat : float;
}
function Start() {
if (File.Exists(fileName)) {
Debug.Log(fileName+"already exists.");
return;
}
var sr = File.CreateText(fileName);
sr.WriteLine("Chips");
sr.Close();
}
You can obtain the TrackableName by referencing its TrackableBehaviour. See the DefaultTrackableEventHandler script for an example.
Here are some examples of how to read and write files using System.IO - http://forum.unity3d.com/threads/8864-How-to-write-a-file