[SOLVED] ProxyNode handmade: LoadXML not work!

General discussion around Urho3D.

[SOLVED] ProxyNode handmade: LoadXML not work!

PostPosted by f1af » 14 Dec 2016, 16:30

Hellow! I have
vehicle.xml and vehicle.as
It's _one_ vehicle for one million level locations.
I have level_00.xml, it have Node, Node have ScriptInstance component and this script:
Code: Select all
class ProxyNode : ScriptObject
{
    String sourceXML;

    void DelayedStart()
    {
        log.Info("ProxyNode: sourceXML = " + sourceXML);
        XMLFile@ xmlfile = cache.GetResource("XMLFile", sourceXML);
        if ((xmlfile !is null) and (node.GetComponents().length == 1))
        {
            if (node.LoadXML(xmlfile.GetRoot(), true))
            {
                log.Warning("LoadXML!!!");
            }
        }
    }
}


And I load scene like this:
Code: Select all
    scene_ = Scene("level_00");
    scene_.LoadXML(cache.GetFile("Scenes/level_00.xml"));


And Urho is crashed =(

It's bug or I do somthing wrong?
User avatar
f1af
New user
New user
 
Posts: 4
Joined: 14 Dec 2016, 16:24

Re: [SOLVED] ProxyNode handmade: LoadXML not work!

PostPosted by f1af » 15 Dec 2016, 08:00

I resolve this problem!
Scheme of my code was hare:

Code: Select all
main.as, load ->
level.xml, have ->
Node + ScriptInstance component, linked ->
ProxyNode.as, loadXML ->                     // Not work, becouse:
PlayerVehicle.xml, have ->
Node + ScriptInstance component, linked ->  // Error is here!
main.as, include ->                         // Error is here!
PlayerVehicle.as


And loadXML is crashed Urho.

I just change last step:

Code: Select all
PlayerVehicle.xml, have ->
Node + ScriptInstance component, linked ->
PlayerVehicle.as


and all works fine.

------------------------------------

But now I need handle and change Save process of this node.. Mayde someone have similar ProxyNode class?
User avatar
f1af
New user
New user
 
Posts: 4
Joined: 14 Dec 2016, 16:24

Re: [SOLVED] ProxyNode handmade: LoadXML not work!

PostPosted by f1af » 15 Dec 2016, 11:03

It's worked solution:

Code: Select all
class ProxyNode : ScriptObject
{
   String sourceXML;

   void DelayedStart()
   {
       XMLFile@ xmlfile = cache.GetResource("XMLFile", sourceXML);
       if (xmlfile !is null)
       {
           Node@ newNode = scene.CreateChild();
           if (newNode.LoadXML(xmlfile.GetRoot(), true))
           {
               newNode.SetTransform(node.position, node.rotation);
               log.Info("ProxyNode: load successful, filename \"" + sourceXML + "\"");
           }
           newNode.temporary = true;
       }
   }
}
User avatar
f1af
New user
New user
 
Posts: 4
Joined: 14 Dec 2016, 16:24


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron