Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Access resources from Visual Studio code?

Discussion in 'Windows' started by pumpkinszwan, Jun 16, 2014.

  1. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    How can I (if it's possible) access my game's resources from my Visual Studio code?

    For example I want to access images stored in my Assets\Textures folder so I can use them in a live tile. Is there a way I need to reference them from Visual Studio code?

    I want to make a live tile plugin that uses images from the Unity project rather than having to add images to the Visual Studio solution.

    I would normally use a string with the path to an image in my solution to, e.g., populate an image control. Can I reference an asset in my Unity project in the same way? If so what is the path structure?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Hi,

    it's not possible to achieve directly - once you build the project, Unity packs the images into its own format for use with DirectX. They are no longer the .jpg/.png images you've added to Assets\Textures folder.

    However, you can use streaming assets for that purpose:

    http://docs.unity3d.com/Manual/StreamingAssets.html

    On Windows Phone/Windows Store platforms, use Application.streamingAssetsPath to access it.
     
  3. felartu

    felartu

    Joined:
    Jun 19, 2014
    Posts:
    3
    One question related to this one:

    How can change public variables of my Unity game from Visual Studio?
     
  4. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    I'd recommend not doing that if you can avoid it. I try to keep as much of my code in Unity as possible. That makes it easier to port the game if that becomes a requirement.

    Go and grab the prime31 plugins - they are currently free (there's a link in this forum somewhere), and they include a simple way to access isolated storage settings. You can read and write the settings in Unity via the plugin, and you can access these as usual from Visual Studio code.

    If you set an isolated storage value to match your public variables (e.g. by creating a property that gets/sets the value using isolated storage) you can treat your stored values as a variable from Unity and Visual Studio.
     
    felartu likes this.
  5. felartu

    felartu

    Joined:
    Jun 19, 2014
    Posts:
    3
    thanks for your reply, in my scenario I need to pass the IsTrial property to Unity from Visual Studio to allow Access to the full version of my game.

    Is there any other way to accomplish it without accesing storage? I rather feel insecure storing the trial/full information on a file.
     
  6. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214

    Yes, get the prime31 plugin I mentioned previously. It's free and it includes the functionality to check the game licence.