Unity 3D 2019.2.11f
Easy AR 4.0 Free
I use example sample ImageTargetOnFly. I run my code on Unity Editor and it's working very well and image targets is successfully tracking. But, not working on the Android device. Has anyone solved this problem?
I use file path:"/data/user/0/com.app.package/files" and all images save into this folder.
All files save like this:
- "/data/user/0/com.app.package/files/photo0.jpg"
- "/data/user/0/com.app.package/files/photo0.jpg"
- also i tested with Application.persistentDataPath
```
public IEnumerator LoadTarget()
{
yield return new WaitForSeconds(2);
Debug.Log("Run LoadTarget");
int count = 0;
var imageTargetName = filesManager.GetImageFiles();
foreach (var obj in imageTargetName.Where(obj => !imageTargetDic.ContainsKey(obj.Key)))
{
count++;
GameObject imageTarget = new GameObject(obj.Key);
Debug.LogFormat("Android Path= {0}{1}.jpg", "/data/user/0/com.app.package/files/",obj.Key);
var controller = imageTarget.AddComponent<ImageTargetController>();
controller.SourceType = ImageTargetController.DataSource.ImageFile;
controller.ImageFileSource.PathType = PathType.Absolute;
controller.ImageFileSource.Path = "/data/user/0/com.app.package/files/" + obj.Key + ".jpg";
controller.ImageFileSource.Name = obj.Key;
controller.ImageFileSource.Scale = 1f;
controller.Tracker = Tracker;
imageTargetDic.Add(obj.Key, controller);
var cube = Instantiate(cube3d);
cube.transform.parent = imageTarget.transform;
initImageTargetFunction(controller);
}
Debug.Log("Loaded target =" + count);
}
private void AddTargetControllerEvents(ImageTargetController controller)
{
if (!controller)
{
return;
}
// ----------- all function not fired on Unity Editor,Android.
controller.TargetFound += () =>
{
Debug.LogFormat("Found target {{id = {0}, name = {1}}}", controller.Target.runtimeID(), controller.Target.name());
};
controller.TargetLost += () =>
{
Debug.LogFormat("Lost target {{id = {0}, name = {1}}}", controller.Target.runtimeID(), controller.Target.name());
};
controller.TargetLoad += (Target target, bool status) =>
{
Debug.LogFormat("Load target {{id = {0}, name = {1}, size = {2}}} into {3} => {4}", target.runtimeID(), target.name(), controller.Size, controller.Tracker.name, status);
};
controller.TargetUnload += (Target target, bool status) =>
{
Debug.LogFormat("Unload target {{id = {0}, name = {1}}} => {2}", target.runtimeID(), target.name(), status);
};
}
```
By Android logcat i saw the image target is successfully loading and creates into the Unity scene, but not tracking.
Devices:
- OnePlus 6 Android 10
- Xiaomi MiPad 4 - Android 8
Also, I found a strange log entry when running the application:
Curl error 7: Failed to connect to localhost port 80: Connection refused
(Filename: ./Modules/UnityWebRequest/Implementations/TransportCurl.cpp Line: 734)
02-19 16:51:36.214 15494 15531 E Unity : Curl error 7: Failed to connect to localhost port 80: Connection refused
(Filename: ./Modules/UnityWebRequest/Implementations/TransportCurl.cpp Line: 734)