Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Windows Phone SDK

Discussion in 'Windows' started by caldofran, Aug 9, 2013.

  1. caldofran

    caldofran

    Joined:
    Aug 7, 2013
    Posts:
    45
    Hi,

    I'm having troubles with the different SDKs used for compiling for Windows Phone 8. The problems comes when trying to use the XElement class of System.Xml.Linq namespace.

    This class has different methods declaration in mono framework and in windows phone SDK, specifically the Save method:

    In mono: XElement.Save (Method) (String)
    In WinPhone 8 SDK: XElement.Save (Method) (Stream)

    I've tried to reference each assembly (System.Xml.Linq of 3.5 and System.Xml.Linq of 4.0)
    The problem is that if i use the first method (with a string) Mono compiles, Unity builds correctly the VS2012 project, but when it deploys to the phone it throws an exception like "Method save does'nt exists".
    If i use the second method (with a stream) Mono compiles, but Unity does'nt build the VS2012 because it does not references correctly the WinPhone SDK library (throws an exception "cannot convert stream to string")

    here is a snippet of my method (wich compiles in both Mono and Unity, but crashes in the phone):

    string filename = Application.persistentDataPath + "/" + "Options.xml";

    XElement rootNode = new XElement("Options");

    XElement nodoQuality = new XElement("Quality", (opciones.Shadows) ? "1" : "0");
    rootNode.Add(nodoQuality);

    XElement nodoShadows = new XElement("Shadows", (opciones.Shadows) ? "1" : "0");
    rootNode.Add(nodoShadows);

    XElement nodoEffects = new XElement("Effects", (opciones.Effects) ? "1" : "0");
    rootNode.Add(nodoEffects);

    rootNode.Save(filename);

    Maybe i'm doing something wrong or i have a wrong concept of the different subsets of the .NET framework. I can change this method in any suggested way, is there a tutorial or a workaround for saving XML in windows phone?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,702
    Hello.

    Unfortunately, you cannot use .NET 4.5 methods in scripts. In order to make it work, you'll have to create a Windows Runtime Component and in through it you'll be able to use all the magic of .NET 4.5 and WinRT :).
     
  3. caldofran

    caldofran

    Joined:
    Aug 7, 2013
    Posts:
    45
    That's quite tricky to solution this stupid trouble... :D so i'll try to do it in a more "simple" way...

    thanks anyway Tautvydas Zilys!
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,702
    No problem ;).