- Home /
How to pass path to plugin?
Hi guys, I'm writing my first plugin, it is a Windows Phone 8 one, how can I send a the path of a texture to a function so it can access the texture?
I want it to update the live tile and couldn't found sample codes.
Edit:
The plugin is a DLL that will update the Live Tile of the app, for this I must supply to it some parameters, but the DLL will be running device code, even if it is still C# it is not Unity C# anymore, so only have access to classes available in the Windows Phone 8 SDK.
Here is the DLL code:
public static void Update(string title, int count, string imgPath)
{
ShellTile PinnedTile = ShellTile.ActiveTiles.First();
FlipTileData updatedTileData = new FlipTileData
{
Title = title,
Count = count,
BackTitle = "de traz",
BackgroundImage = new Uri(imgPath)
};
PinnedTile.Update(updatedTileData);
}
And this is my code in Unity
LiveTilesPlugin.UpdateTile.Update("Title App", 55, "doge.jpg");
What should I pass to the imgPath parameter so it can access the file? Just the file name resulted in crash.
Edit 2:
Still with error using
path = System.IO.Path.Combine(Application.streamingAssetsPath, "doge.png");
The result string on the Emulator is the following: "C:/Data/Programs/{7545C7EA-396B-4ECA-9306-5E095280BB60}/Install/Data/StreamingAssets\\doge.png"
Are these double \\ correct?
You should provide a lot more details on what you are trying to do.
But you probably want to use the **WWW** class. It supports the file:// protocol to load files.
Sorry @GameVortex , I've added some detail. Please let me know if these suffice.
Answer by GameVortex · Dec 13, 2013 at 10:53 AM
To get the path of a file in the built version of a Unity Project you have to put your files in a folder named "StreamingAssets" before you build. After that you can access the files using: Application.streamingAssetsPath.
string path = System.IO.Path.Combine(Application.streamingAssetsPath, "doge");
Read more in the Manual about **StreamingAssets**.
Still with error, I've updated the question with further details, thanks for your help.