Ios runtime gameobjects not showing up

I have a GameObject in my scene with a script on it that reads data from an xml and creates a variety of cube primitives (and applies other components to them like textures, etc) based on that xml data. I am doing this:

GameObject gobj = GameObject.CreatePrimitive(PrimitiveType.Cube);
gobj.transform.parent = this.transform;
gobj.name = name;

gobj.transform.position = position;
gobj.transform.localScale = scale;

This works fine in the editor, and in unity remote viewer. However when I build to my device, none of these cubes are showing up.

How do I get this to work? Is there some unity restriction I am hitting here?

I searched for answers to this, but haven’t found anything yet. Maybe its not allowed to CreatePrimitives at run-time on ios and parent them to existing gameobject transforms???

Thanks

Seems to me there’s an issue with loading the XML on device here. You might want to debug exactly what is being loaded in with the XML (print and check log).

unity remote viewer IS the editor with different input.

not sure what you mean hippocoder. Is there a problem reading in xml on the iPhone? or are you suggesting there is a problem with some other content?

All I’m doing is applying some size and position information from the xml data and a texture reference later on. The texture itself is referenced in an serialized array property somewhere else in the scene. Even so, before I had the textures in, I was simply specifying a color and they still were not showing up.

I’m suggesting there’s a problem with your chosen method to load XML on the device.

Ah, I see what you are getting at. I can’t just use a relative path in the assets folder. Where can I put XML so I can read it off the device? Is there somewhere in the xcode project I should put them? then how do I access them while running? I assume I need to use the WWW method for getting at local files, but whats the path for something inside the archive?

If you remove the extension you should be able to use Resources.Load and pass it through an xml parser. It’s just text after all. Maybe it recognises it, I don’t know. You’ll need to research a bit, I’m sure there’s more than a few examples on forum.

Ok I see how that is done. I had been taking a slightly different approach before I saw your last reply. I created an array of TextAssets on a component attached to a gameobject in the scene, and retrieved and read in the one that was called for at the time.

I assume that doing this basically loads every one of the xml files at run time when the scene is loaded. Is this correct?
Using the Resouces folder will package up all of the xml into the iPhone build archive and Resources.Load method will load them at run time, so what you suggest is slightly more efficient because they won’t ALL be loaded at run time.

Are my assumptions correct? Is this how unity behaves?

If both methods indeed load every one of those xml files while the app is starting up, then could I use locally packaged asset-bundles to speed up load times?

I know this is ridiculous for smallish text files, but the game I am working on has a large collection of assets that I’ll only want about 5% of them loaded in any particular game session.

Thats right - it will only load anything in resources folder when you ask it to - unless of course stuff already uses it in the scene. Afterwards you can unload as well. I do this a lot with samples. I haven’t worked with more than text files for loading though.