Log in or register to post comments

Object not augmenting correctly on IOS works on Android

August 15, 2012 - 9:35pm #1

I was trying the swappable datasets part and it works perfectly on Android. But is somewhat glitchy in IOS. First of all the workflow of my project is as follows:

1.Download .xml and .dat from server.

2.Download objects to be augmented from server in the form of assetBundles.

3.Instantiate these models(On a Button click) and make it a child of an Empty gameObject (This part is important and I cannot consider to undo it.)

4.Load the downloaded DataSet.

5.And Make the Empty gameObject a child of DataSetTrackableBehaviour dstb.

This is the code that I am using:

Quote:

DataSetTrackableBehaviour dstb = dataSet.GetTrackable(i);

GameObject go = dstb.gameObject;

go.AddComponent<DefaultTrackableEventHandler>();

GameObject parent = GameObject.Find ("Parent");

parent.transform.parent= dstb.transform;//make Parent GameObject a Child of ImageTarget for augmentation

parent.transform.localScale = new Vector3 (0.25f,0.25f,0.25f);

parent.transform.localPosition = new Vector3 (0.0f,0.0f,0.0f);

parent.transform.localRotation=Quaternion.identity;

parent.active=true;

 

dstb.gameObject.active=true;

}

imageTracker.ActivateDataSet(dataSet);

This setup works perfectly on Android. But in IOs when I instantiate my "Object to be Augmented", the model just appears on the screen and mounts the trackable only when its visible/found by ARCamera. Otherwise the model just sits on the screen idly. I did these scripts on PC for android and now I am trying to migrate my whole project to IOs. The Unity version on PC is 3.5.3f3 but On Mac the unity version is 3.5.2f2.Could that be a problem?

Please Help!

Object not augmenting correctly on IOS works on Android

August 26, 2012 - 11:46am #8

Can you post the code that you're using?

Also see - http://docs.unity3d.com/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html to review calling between C# and JS.

and - http://answers.unity3d.com/questions/228518/desktopios-and-android-script-differences.html

Be sure to use explicit typing.

Object not augmenting correctly on IOS works on Android

August 26, 2012 - 11:45am #7

You're welcome - so you got it working on iPhone?

Object not augmenting correctly on IOS works on Android

August 22, 2012 - 6:37am #6

Thanks David and Nalin for giving me your precious time. I posted the code earlier but somehow its not visible as you can see my previous post was blank.

The problem and the main difference between android and ios is (what i think) that Ios takes pragma strict more seriously than android. And that was the case here. The java script could easily call the c sharp script that handles the behaviour but in Iphone it had problems accessing variables c sharp script.

Thanks for pointing that out David.

Object not augmenting correctly on IOS works on Android

August 20, 2012 - 11:43pm #5

This is the javascript that downloads and instantiates the object and makes it a child of Empty GameObject "Parent"

 #pragma strict

var www : WWW;

var download : WWW;

var url : String;

var guiOffset = 20;

var assetBundle : AssetBundle;

var instanced : GameObject;

var customGUIstyledownload : GUISkin;

private var goParent : GameObject;

function StartDownload () {

www = new WWW ("file:///mnt/sdcard/AssetBundles/selected.txt");

        yield www;

        url = www.text;

if (Application.platform==RuntimePlatform.Android)

download = WWW.LoadFromCacheOrDownload("file:///mnt/sdcard/AssetBundles/"+url,1);

yield download;

 

assetBundle = download.assetBundle;

    

if (assetBundle != null)

{ var go : GameObject = assetBundle.mainAsset;

goParent = GameObject.Find("Parent");

if (go != null)

{

instanced = Instantiate(go);

instanced.transform.parent = goParent.transform;

instanced.transform.localPosition = new Vector3(0.0f,0.125f,0.0f);

instanced.transform.localScale= new Vector3(0.5f,0.5f,0.5f);

instanced.transform.localRotation = Quaternion.identity;

}

else

Debug.Log("Couldnt load resource");

}

else

{

Debug.Log("Couldnt load resource");

}

}

 

function Destroydownload()

{

                Destroy(instanced);

// Dispose the WWW class

download.Dispose();

download = null;

// Unload the whole asset bundles and any loaded assets

assetBundle.Unload (true);

assetBundle = null;

        }

function OnGUI()

{

 

if (download == null)

{

if (GUI.Button(Rect(40,20,200,40),"Download ",customGUIstyledownload.button))

{StartDownload();

 Debug.Log("Start Download");

}

}

else

{

if (download.error == null)

{

var progress = parseInt(download.progress * 100);

GUILayout.Label(progress + "%");

 

if (download.isDone && GUI.Button(Rect(40,20,200,40),"Unload Resource",customGUIstyledownload.button))

{

Destroydownload();

}

}

else

{

GUILayout.Label(download.error);

}

}

}

 

and further I am making the Empty GameObject a child of DataSetTrackableBehaviour.gameObject as posted earlier. This setupt works fine in android but for Ios I've applied a workaround by observing a value that changes in OnTrackingFound() and OnTrackingLost() and making my gameObject visible/invisible accordingly.

Object not augmenting correctly on IOS works on Android

August 19, 2012 - 9:18pm #4

Thanks for the info.I'll try that.

Object not augmenting correctly on IOS works on Android

August 17, 2012 - 1:26am #3

Not sure what this problem is, but best practice is to sync up Unity versions between PC and MAC, so you might want to give it a try.  It's also possible to install multiple Unity Versions on a mac by just renaming the existing installation in the Applications directory prior to installing.

N

Object not augmenting correctly on IOS works on Android

August 16, 2012 - 9:34pm #2

The only odd thing is that my script for instantiating the object from assetBundle is written in js. And in it I am not making the downloaded model a child of trackable instead I am making it a child of Empty GameObject and then in another script I am making the Empty GameObject the child of Trackable. Something like this...

1.Downloaded Model(Child of)---2.Empty GameObject(Child of)----Trackable. The first part is wriiten in js and the second part is written in cs.

This setup works fine in Android but why not in Ios? Although this is more of a Unity Question but I wanted to know the difference in Both of these Platforms. 

Or is it totally different? I am really confused...for now I've applied a workaround for this problem but would really wanna know what is the core problem. Is it something related to the version of Unity?

Please have your thoughts over it....

Log in or register to post comments