Author Topic: Need to pull a variable from an online (xml?) file...HELP  (Read 1486 times)


  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Need to pull a variable from an online (xml?) file...HELP
« on: September 13, 2016, 08:26:39 AM »
I need to start/stop an animation in my project based on a true/false value that would ideally be stored in an file that's external to the project build.

The task I have been given is we have an animation looping in my program. For the sake of illustration think of it as a pendulum swinging back and forth. We need the Unity program to check the state of an external source (like an XML, TXT, or HTTP status code) at a regular interval – let's say once a second.

If the value retuned is TRUE then the pendulum keeps swinging. If the value is altered externally (say I open the XML file and replace "true" with "false") then the animation stops.

And so on every second.

I started with the WWW object but all I get are errors about a movie texture not being loaded. I see the "Store Text" feature but not sure how to go about using that and getting past the error about the movie texture...if that's even required.

I've been trying the DataMaker Xml nodes but "Xml Get Node Properties" only seems to want to point at a local XML file.

Once I compile/build the project, that local XML file gets bundled up somewhere. Is there a way to store the XML file in the "_Data" folder so it's still accessible?

Is there a way in the Datamaker nodes to point to an online XML file? I tired "Source Selection" as "Use Variable" and I stored the URL in a variable but that didn't seem to function. When i try and select my variable under the "FSM String" dropdown it won't let me select it.


The reason for all this is we are trying to use OpenCV to register if someone's eyes are open or closed on a webcam. The developer handling the facial recognition part of the project wants to provide me with a 0/1 or true/false statement in some from or location that I can pull into Unity to alter the state of my animation. Their initial question to me was, "Can you have a background timer (e.g. once a second) that calls a specific URL and looks for a return code - either 1 or 0. If not can you get HTTP Status code?"

I thought Unity only worked with GET and POST which made me start looking at pulling the value from a TXT or XML file. But I'm no coder so any guidance, help or ideas would be greatly appreciated. Thanks.


  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Need to pull a variable from an online (xml?) file...HELP
« Reply #1 on: September 13, 2016, 11:01:35 PM »
You can do this at runtime, by Using the the www component and parsing the xml into a string variable, then use datamaker to to add this to a datamaker xml proxy on an object (optional), you can then use the datamaker get node action to get the "True/False" node.

Checking its status every frame may be overkill for what you need and cause performance issues, I would add a loop to the above with a wait and run it every 1-2 seconds. 

I used exactly the same process for pulling a list of places from google places API at runtime, and it works great.

Let me know if you need anything else, happy to share screenshot if needed.

« Last Edit: September 13, 2016, 11:03:17 PM by Revitspace »


  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: Need to pull a variable from an online (xml?) file...HELP
« Reply #2 on: October 03, 2016, 05:18:40 AM »
Just seen this and a screenshot would be wonderful as it would help others doing similar things.