Ejemplo n.º 1
0
 void Start()
 {
     imageTrackableBehaviour = GetComponent <ImageTrackableBehaviour>();
     if (imageTrackableBehaviour)
     {
         imageTrackableBehaviour.RegisterTrackableEventHandler(this);
     }
 }
    public override void OnInspectorGUI()
    {
        if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab)
        {
            return;
        }

        imageTrackableBehaviour = (ImageTrackableBehaviour)target;
        imageTrackableBehaviour.UpdateDatabaseInfo();

        isDirty = false;

        int prevDBIdx = imageTrackableBehaviour.DBIndex;
        int newDBIdx  = EditorGUILayout.Popup("Database Name", imageTrackableBehaviour.DBIndex,
                                              imageTrackableBehaviour.DBNameList);

        if (prevDBIdx != newDBIdx)
        {
            isDirty = true;
            imageTrackableBehaviour.SetGroupIndex(newDBIdx);
        }

        int prevTrackableIndex = imageTrackableBehaviour.TrackableIndex;
        int newTrackableIndex  = EditorGUILayout.Popup("Trackable Name", imageTrackableBehaviour.TrackableIndex,
                                                       imageTrackableBehaviour.TrackableList);

        if (prevTrackableIndex != newTrackableIndex)
        {
            isDirty = true;
            imageTrackableBehaviour.SetTrackableIndex(newTrackableIndex);
        }

        if (GUI.changed)
        {
            if (imageTrackableBehaviour != null)
            {
                if (isDirty)
                {
                    EditorUtility.SetDirty(imageTrackableBehaviour);
                }
            }

            SceneManager.Instance.SceneUpdated();
        }
    }
    void Start()
    {
#if UNITY_ANDROID
        AndroidJavaClass javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        currentActivity        = javaUnityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
        AndroidExtensionClass  = new AndroidJavaClass("com.maxst.ar.android_extension.AndroidExtension");
        AndroidExtensionObject = AndroidExtensionClass.CallStatic <AndroidJavaObject>("init", currentActivity);
#endif

        imageTrackable = FindObjectOfType <ImageTrackableBehaviour>();

        if (Application.platform == RuntimePlatform.Android)
        {
            TrackerManager.GetInstance().AddTrackerData(imageTrackable.TrackerDataFileName, true);
        }
        else
        {
            TrackerManager.GetInstance().AddTrackerData(Application.streamingAssetsPath + "/" + imageTrackable.TrackerDataFileName);
        }

        TrackerManager.GetInstance().LoadTrackerData();
    }