Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: artician on March 03, 2015, 11:54:21 AM

Title: DataMaker/XPath
Post by: artician on March 03, 2015, 11:54:21 AM
I'm trying to use Data Maker and learn XPath syntax at the same time.  I've never worked with it before.  I was hoping someone could help me with the xPath syntax.

The XML files I'm processing have a slightly different format than those used in DataMakers examples.  My XML output looks like this:

Code: [Select]
<layer name="H_2_Poppy" xPos="260.5"  yPos="-342"  layerwidth="91" layerheight="66" fileName="H_2_Poppy.png"/>
How would I query this and store the xPos, yPos and fileName?

Many thanks in advance!
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 04, 2015, 03:04:50 AM
Hi,

 I'll reply with a working sample, please bump me towards the end of the week . Hyper busy right now :)

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on March 05, 2015, 10:28:06 AM
Bump! 
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 06, 2015, 03:31:46 AM
Hi,

 Thanks for the bump :)

Please find attached the sample ( published with U4.3.4)

I store the xml in a text file and use a proxy to reference that asset.

then I use the action only :)  XmlSelectSingleNode

The actual xpath query is:

//layer[@name='H_2_Poppy']

but since you likely want the name to be dynamic and hosted in an fsm variable, you change it to:

//layer[@name='_0_']

and add a variable associated to the xpath query. Check the "XmlSelectSingleNode" in the demo to see how the xpath si then parsed using the variable values

this XmlSelectSingleNode action can in one go also retrieve properties of the found node ( only if found obviously), and the last part of the action gets the various informations you need, notice the automatic conversion of variable tapes, since in xml everything is a string, you can still however store values inside any fsm variable, the conversion will be done automatically or warn if impossible.

The "Store Reference" property of the action is simply a way to save in memory the found node so that later in the game, ANYWHERE in your scenes on any fsm, you can query again that node simply by reference the value of "Store Reference".

 hopefully, that will explains the process clearly, search the web for tutorials on xml xpath and experiment online, you'll find numerous xpath testers to validate your queries quickly. However, the context is slightly different in XmlMaker so it's usefull also to check out the various examples to really get a feeling of the most used types of xpath queries.

Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on March 06, 2015, 11:04:33 AM
Thank you for your help!  Unfortunately my console won't stop spamming the following errors when I import your package:

Unable to find style '' in skin 'DarkSkin' Layout
UnityEngine.GUIStyle:op_Implicit(String)
DataMakerActionEditorUtils:EditFsmXmlSourceField(Fsm, FsmXmlSource) (at Assets/PlayMaker DataMaker/_internal_/Editor/DataMakerActionEditorUtils.cs:122)
XmlSelectSingleNodeEditor:OnGUI() (at Assets/PlayMaker DataMaker/Xml/Actions/Editor/XmlSelectSingleNodeEditor.cs:23)
HutongGames.PlayMakerEditor.ActionEditor:OnGUI(FsmStateAction)
HutongGames.PlayMakerEditor.StateInspector:DoActionGUI(FsmStateAction)
HutongGames.PlayMakerEditor.StateInspector:DoActionsListGUI(FsmState)
HutongGames.PlayMakerEditor.StateInspector:DoActionsPanel()
HutongGames.PlayMakerEditor.StateInspector:OnGUI()
HutongGames.PlayMakerEditor.InspectorPanel:OnGUI(Rect)
HutongGames.PlayMakerEditor.FsmEditor:OnGUI()
FsmEditorWindow:DoGUI() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:94)
HutongGames.PlayMakerEditor.BaseEditorWindow:OnGUI()
UnityEditor.DockArea:OnGUI()
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 09, 2015, 02:28:20 AM
Hi,

 Ignore this, It's a warning, and it doesnt' affect your game. I know it's a pain. The new DataMaker Package will be out soon.

 Bye,

 Jean

 
Title: Re: DataMaker/XPath
Post by: artician on March 09, 2015, 11:38:30 AM
Unfortunately that means there's something else wrong.  After importing your example package into a project and looking at the FSM in the editor, I see this error:
(http://www.creathcarter.com/site_media/hpspmt/xmlMaker.jpg)

To test this I've imported the package into a new project and two existing projects, but all show the same error.  Other than the 999+ warning messages I mentioned above, there is one error:

Quote
Query: Select Single Node and get properties: State 1: XmlSelectSingleNode: Failed to convert Array: xPathVariables From: CustomClass To: FsmString
UnityEngine.Debug:LogError(Object)
HutongGames.PlayMaker.ActionReport:LogError(PlayMakerFSM, FsmState, FsmStateAction, Int32, String, String)
HutongGames.PlayMaker.ActionData:LogError(String)
HutongGames.PlayMaker.ActionData:TryConvertParameter(FsmStateAction, FieldInfo, Int32)
HutongGames.PlayMaker.ActionData:TryRecoverAction(Type, FsmStateAction, Int32)
HutongGames.PlayMaker.ActionData:CreateAction(FsmState, Int32)
HutongGames.PlayMaker.ActionData:LoadActions(FsmState)
HutongGames.PlayMaker.FsmState:LoadActions()
HutongGames.PlayMaker.Fsm:InitData()
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckFsmForErrors(Fsm)
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckForErrors()
HutongGames.PlayMakerEditor.FsmErrorChecker:Update()
HutongGames.PlayMakerEditor.FsmEditor:Update()
FsmEditorWindow:Update() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:319)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Any help is appreciated!
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 10, 2015, 02:11:03 AM
Hi,

 ok, let me quickly wrap up the xmlData with a new package, I'll publish it today.

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on March 11, 2015, 12:52:07 PM
*bump*

Sorry for the bother Jean.  I'm almost done!  Just need a bit more help to finish this.  Let me know if you get time to publish/fix the example package at least.

Thank you as always!
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 11, 2015, 01:43:41 PM
Hi,

 yeah, I got carried away updating arrayMaker and uGui, sorry :) this is coming next.

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 12, 2015, 04:58:26 AM
Hi,

 some examples got corrupted, so I only sharing this here for now, until I can go over ll samples and clean them up.

"Books" and "Queries" ( your sample) was verified.

 Please download here (https://github.com/jeanfabre/PlayMaker--DataMaker/raw/master/Packages/DataMakerSamples.unitypackage)

BACKUP as always, this is an edgy time between u4, u5, playmaker updates and addons, so make sure you are safe when you import updated packages.

Let me know how it goes.


 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on March 12, 2015, 11:54:00 AM
Hi Jean,

Thanks for the quick answers.  I'm looking at the new examples now.  I created a clean project, and only imported: 1-Playmaker, 2-ArrayMaker, 3-DataMaker and 4-DataMakerSamples, in that order.

After importing the DataMakerSamples, Unity reports one error:
Quote
Assets/Photon Unity Networking/Editor/PhotonNetwork/AccountService.cs(181,45): error CS0433: The imported type `Newtonsoft.Json.JsonConvert' is defined multiple times

I then loaded the scene "SelectSingleNodeAndGetProperties" under the XML/Examples/Queries folder.  Once loaded Unity reports this error:
Quote
Query: Select Single Node and get properties: State 1: XmlSelectSingleNode: Failed to convert Array: xPathVariables From: CustomClass To: FsmString
UnityEngine.Debug:LogError(Object)
HutongGames.PlayMaker.ActionReport:LogError(PlayMakerFSM, FsmState, FsmStateAction, Int32, String, String)
HutongGames.PlayMaker.ActionData:LogError(String)
HutongGames.PlayMaker.ActionData:TryConvertParameter(FsmStateAction, FieldInfo, Int32)
HutongGames.PlayMaker.ActionData:TryRecoverAction(Type, FsmStateAction, Int32)
HutongGames.PlayMaker.ActionData:CreateAction(FsmState, Int32)
HutongGames.PlayMaker.ActionData:LoadActions(FsmState)
HutongGames.PlayMaker.FsmState:LoadActions()
HutongGames.PlayMaker.Fsm:InitData()
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckFsmForErrors(Fsm)
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckForErrors()
HutongGames.PlayMakerEditor.FsmErrorChecker:Update()
HutongGames.PlayMakerEditor.FsmEditor:Update()
FsmEditorWindow:Update() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:319)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I'm still not able to learn anything from the sample either.  When I look at the FSM in the example scene, the Xml Select Single Node action has the same error I reported above with the "Error Editing Action.  Array index is out of range."

The action seems self explanatory, but even if I copy your xPath syntax it does not work for me in my scene.  Just for the record: all my packages are up to date and I'm on Unity 4.6.2.

Thank you as always.
Title: Re: DataMaker/XPath
Post by: jeanfabre on March 12, 2015, 01:58:46 PM
Hi,

 Yeah, the Newtonsoft dll can't be imported twice, simply delete either my version of this dll or Photon's one, it doesn't matter which.

 then it should all compile properly after that ( you may have to close and reopen the project for Unity to be happy.

We'll sort it out!!!  :P

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: lkmad on April 24, 2015, 04:00:38 AM
Having similar issues, adding DataMakerXml to my Unity project that already has ArrayMaker. Using Unity 5.

Is DatamakerXml updated to Unity 5 like ArrayMaker was? Could I just install DatamakerXml and skip ArrayMaker?

It messed up my project with various compiling errors (it created duplicates for some files, and then it said something about assigning different GUID to two files) and the Playmaker window has since disappeared.  :/
Title: Re: DataMaker/XPath
Post by: jeanfabre on April 28, 2015, 04:11:28 AM
Hi,

 Yeah, simply delete the ArrayMaker folder and the dataMaker folder and reimport clean.

The duplicated guid is a know issue when you go from unity 4 to unity 5, after that it will be ok.


Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 10:23:36 AM
Hi,

I deleted the ArrayMaker & imported DataMaker. Got the GUID error which I ignored, closed Unity, reopened got an error about "Failed to load window layout - This can happen if layout contains custom windows and there are compile errors in the project." and now my Playmaker windows are gone and no idea how to get them up again. They're missing from the top menu.

What now?!

Lydia

13 compilation errors that appeared:
1. Assets/PlayMaker Utils/PlayMakerUtils_Events.cs(14,28): error CS0111: A member `PlayMakerUtils.SendEventToGameObject(PlayMakerFSM, UnityEngine.GameObject, string)' is already defined. Rename this member or use different parameter types
2. Assets/PlayMaker Utils/PlayMakerUtils_Events.cs(19,28): error CS0111: A member `PlayMakerUtils.SendEventToGameObject(PlayMakerFSM, UnityEngine.GameObject, string, HutongGames.PlayMaker.FsmEventData)' is already defined. Rename this member or use different parameter types
3. Assets/PlayMaker Utils/PlayMakerUtils_FsmVar.cs(25,28): error CS0111: A member `PlayMakerUtils.RefreshValueFromFsmVar(HutongGames.PlayMaker.Fsm, HutongGames.PlayMaker.FsmVar)' is already defined. Rename this member or use different parameter types
4. Assets/PlayMaker Utils/PlayMakerUtils_FsmVar.cs(82,30): error CS0111: A member `PlayMakerUtils.GetValueFromFsmVar(HutongGames.PlayMaker.Fsm, HutongGames.PlayMaker.FsmVar)' is already defined. Rename this member or use different parameter types
5. Assets/PlayMaker Utils/PlayMakerUtils_FsmVar.cs(163,28): error CS0111: A member `PlayMakerUtils.ApplyValueToFsmVar(HutongGames.PlayMaker.Fsm, HutongGames.PlayMaker.FsmVar, object)' is already defined. Rename this member or use different parameter types
6. Assets/PlayMaker Utils/PlayMakerUtils_Serialization.cs(109,30): error CS0111: A member `PlayMakerUtils.ParseValueToString(object, bool)' is already defined. Rename this member or use different parameter types
7. Assets/PlayMaker Utils/PlayMakerUtils_Serialization.cs(114,30): error CS0111: A member `PlayMakerUtils.ParseValueToString(object)' is already defined. Rename this member or use different parameter types
8. Assets/PlayMaker Utils/PlayMakerUtils_Serialization.cs(197,30): error CS0111: A member `PlayMakerUtils.ParseValueFromString(string, bool)' is already defined. Rename this member or use different parameter types
9. Assets/PlayMaker Utils/PlayMakerUtils_Serialization.cs(467,30): error CS0111: A member `PlayMakerUtils.ParseValueFromString(string)' is already defined. Rename this member or use different parameter types
10. Error while reading window layout: window #11 is null
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
11. Failed to load window layout: System.Exception: Exception of type 'System.Exception' was thrown.
  at UnityEditor.WindowLayout.LoadWindowLayout (System.String path, Boolean newProjectLayoutWasCreated) [0x00113] in C:\buildslave\unity\build\Editor\Mono\GUI\WindowLayout.cs:507
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
12. Failed to destroy editor windows: #8
AnimatorControllerTool
AnimationWindow
ProjectBrowser
InspectorWindow
SceneHierarchyWindow
SceneView
GameView
ConsoleWindow
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
UnityEditorInternal.InternalEditorUtility:LoadDefaultLayout()
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
13. Failed to destroy views: #10
SplitView
DockArea
DockArea
DockArea
MainWindow
Toolbar
AppStatusBar
SplitView
SplitView
DockArea
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
UnityEditorInternal.InternalEditorUtility:LoadDefaultLayout()
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)


Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 10:59:44 AM
I'm trying to create a new clean project where I load DataMaker from the beginning and I get these warnings in the attachment. Why are these issues happening? Is DataMaker not updated to Unity 5? How do I overcome them?
Title: Re: DataMaker/XPath
Post by: artician on May 12, 2015, 11:01:24 AM
Arraymaker and Datamaker are in the same package, so there's some confusion there as to what you're removing and replacing. 
The problem is an easy fix though:
Unity takes a poop whenever a script throws errors at startup (or in this case, if a script is looking for other components and doesn't find them because they've been removed, or changed).  The Editor immediately stops loading other plugins, which affects the Editor window layout.
The way to fix this is to delete your PlayMaker folders entirely and reimport both PlayMaker, ArrayMaker (which includes DataMaker), and any other PlayMaker add-ons you need. 
Unless you've introduced errors into the PlayMaker code, or there are other errors in your project, that should fix you right up.  Always make backups of your projects!
Title: Re: DataMaker/XPath
Post by: artician on May 12, 2015, 11:02:08 AM
I'm trying to create a new clean project where I load DataMaker from the beginning and I get these warnings in the attachment. Why are these issues happening? Is DataMaker not updated to Unity 5? How do I overcome them?

Are you importing PlayMaker before you import ArrayMaker?
Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 11:07:01 AM
Oh hang on, so Datamaker is now inside ArrayMaker?! I thought it was the other way round. I've been trying to load Datamaker instead of the ArrayMaker (which says updated to Unity5) and was getting these issues.

Yes, I'm importing Playmaker first.

Thanks so much for trying to help me out with these issues. :)
Title: DataMaker XML
Post by: lkmad on May 12, 2015, 11:10:32 AM
Loaded my back up with the updated ArrayMaker, don't see the XML commands that DataMaker introduces. :/
Title: Re: DataMaker/XPath
Post by: artician on May 12, 2015, 11:28:37 AM
Oh jesus, I'm so sorry.  In my attempt to help you I just mixed things up.  Let me start over.

ArrayMaker and dataMaker are not the same, that's my fault.

Just delete the PlayMaker folder and all it's associated folders (be sure to back up any custom actions or templates within).
Then reimport PlayMaker first, then import DataMaker.  Evidently DataMaker includes Arraymaker now (@JeanFabre?) so let's leave ArrayMaker out of the scenario; that was just me getting mixed up myself.

Regardless that should fix any errors you encounter, but please paste any that do popup or mention if they're the same ones above.
Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 11:35:41 AM
Hey! Thanks again for taking the time to help me. :)

That's what I did with a clean file just in case and got the attachment errors (same as above but including them here again to avoid confusion).

DataMaker's page says that it was last updated in 2013, but ArrayMaker's in 2015. That's why I'm wondering, whether ArrayMaker within DataMaker is the old one hence the 6 problems I'm having. 7th is a DataMaker outdated issue with Register vs Record. :/
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 12, 2015, 12:31:44 PM
Hi,

 no DataMaker doesn't include ArrayMaker, but it does include PlayMakerUtils ( which is shared with ArrayMaker, it's a common set of functions basically).

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on May 12, 2015, 12:37:20 PM
Hi Jean,

May I make a couple of suggestions?

The DataMaker page states this:
Quote
Download
DataMakerXml.unitypackage
ArrayMaker is provided in this package. It features an xml extension to parse xml in hashtables for convenience.

Also, the DataMaker page is actually titled XmlMaker, which adds to the confusion.

Lastly, DataMaker and ArrayMaker are two packages none of my projects go without.  May I suggest bundling them all in one package?  Maybe renaming it to "PlayMaker-CriticalPack", (because really it should be part of the core toolset, it's so useful).

Anyway, thanks for the reply because I didn't have much else I could suggest for Ikmad.
Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 01:53:45 PM
Umm, it does indeed include Arraymaker (old version) see attachment. As artician also pointed out (thanks!!), the extension page explicitly states that it does. Hence all these issues & confusion! :/

If it can either be updated to include the new Arraymaker or Arraymaker is removed from the package, that way we can have the newer version installed separately?!

Then the only final issue will be this error: Assets/PlayMaker DataMaker/Xml/__internal__/Editor/DataMakerXmlEditor.cs(38,18): warning CS0618: `UnityEditor.Undo.RegisterUndo(UnityEngine.Object[], string)' is obsolete: `Use Undo.RecordObjects instead'

which I assume DataMaker will need to have it updated for Unity 5?! Or if there's some help with what script we need to update or something?!

Agreed with artician re: the importance of these extensions, they will be integral to my project and I would love to be able to use them!

Many thanks for all your hard work!
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 12, 2015, 02:55:35 PM
Hi,

 ah yes sorry, my mistake.., I was checking the wrong rep for this..

 I am currently doing a lot of work on arrayMaker and dataMaker, so there will be soon a new set of packages.

I may bundle ArrayMaker, XmlMaker, etc inside DataMaker yes, that is something I woudl like to do, but I fear it will bring too much problems to drag from platforms to platforms...

ignore the warning for now, it's totally harmless.

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: lkmad on May 12, 2015, 03:36:07 PM
I can't ignore the Datamaker errors as they corrupt my project & Playmaker no longer works. :/

I will have to stay without Datamaker XML for now until there's an update. When you say soon, is it week(s) or month(s)?

Many thanks.
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 13, 2015, 03:07:11 AM
Hi,

 Your errors are only because of the Untiy 4/5 upgrade. Simply remove all ArrayMaker/DataMaker/PlayMakerUtils folders and import again, these issues will go away. As long as you will have duplicated files ( "xxx 1" then you'll get issues).

 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: lkmad on May 13, 2015, 05:56:35 AM
Hi Jean,

If I import Datamaker & ArrayMaker in again, of course I will have duplicates again since ArrayMaker (old version) is included inside Datamaker. You are asking me to re-import XMLMaker & ArrayMaker (DatamakerXML) + ArrayMaker (Unity 5 update).

So either I need to try working with old Datamaker (and old ArrayMaker) or I need to manually figure out how to import Datamaker and uncheck every single ArrayMaker reference so that I can install the new ArrayMaker and I will not have duplicates. That's why we said about the Datamaker either bundled with ArrayMaker (but updated) or remove the ArrayMaker from Datamaker so that we won't be having these issues in the future.

Thx.
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 13, 2015, 06:17:12 AM
Hi,

Yeah, you are better off using datamaker as is currently. Does that work for you if you just have DataMaker package imported?


 Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: lkmad on May 13, 2015, 07:10:39 AM
Hey,

Just loaded things. Missing a few of ArrayMaker & Hashtable commands from the Playmaker Actions menu but otherwise seems ok. :)

Any idea on when DataMaker will be updated?

Many thanks!
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 15, 2015, 08:42:43 AM
Hi,

 ok, did some spring clean up (https://twitter.com/JeanAtPlayMaker/status/599190893153918977) :)

 it's now on the Ecosystem, all with the latest and unity 5 ready, etc etc, as well as json converted to xml :)

Bye,

 Jean
Title: Re: DataMaker/XPath
Post by: artician on May 15, 2015, 11:30:21 AM
Awe, man, see..?  This is why I got a tattoo of Jean's portrait on my butt.  He's a hero!

(I didn't really get a tattoo of your portrait, but I've run out of ways to express my thanks).
Title: Re: DataMaker/XPath
Post by: lkmad on May 15, 2015, 12:25:15 PM
cool! thanks so much! :)
Title: Re: DataMaker/XPath
Post by: jeanfabre on May 16, 2015, 01:40:23 AM
Hi,

 You made my day! :)

 I just read your post and laughes out loud... then my wife asked me and was very curious what made me laugh so much... so it was kind of awkward to explain the situation and the tatoo and where you wanted it...

 :o :o ;D

I think that you are now officially #1 in the "leaderboard" of 'thanking' :) and that is going to be difficult to beat :)

Awe, man, see..?  This is why I got a tattoo of Jean's portrait on my butt.  He's a hero!


(I didn't really get a tattoo of your portrait, but I've run out of ways to express my thanks).
Title: Re: DataMaker/XPath
Post by: artician on May 18, 2015, 12:28:11 AM
I am happy to be of service.  :)